Hey folks, I've been running my OpenClaw agent inside a custom network namespace for isolation, and I've hit a snag. The agent's built-in web search tool (`tool_web_search`) just hangs and times out. Everything else works fine — local tool execution, file I/O — but anything requiring external network calls is dead.
I suspect this is because the agent's runtime, while memory-safe, isn't automatically handling the network namespace setup. The tool likely tries to use a standard `reqwest` client that inherits the global network state, which in my case is a `veth` pair inside the new namespace. Without proper routing/DNS in that namespace, it's stuck.
Here's a simplified version of my setup code:
```rust
// Creating the isolated network namespace
use nix::sched::{clone, CloneFlags};
use nix::sys::utsname::uname;
let mut stack = [0; 1024 * 1024];
let pid = clone(
Box::new(|| {
// ... setup veth, lo up, etc.
// Then spawn the agent runtime
let agent = MyOpenClawAgent::new();
agent.run();
}),
&mut stack,
CloneFlags::CLONE_NEWNET | CloneFlags::CLONE_NEWUSER,
Some(Signal::SIGCHLD as i32),
)?;
```
The agent initializes and runs, but any call to the web search tool blocks forever. I'm guessing the tool's HTTP client is created before or outside the namespace switch, or isn't using a socket that's aware of the new network context.
Has anyone else tried running OpenClaw agents under strict network isolation? Did you have to do something special to make external tool calls work? I'm thinking I might need to:
- Ensure the tool's HTTP client is built *after* the namespace is entered.
- Maybe bind the client to a specific interface in the new namespace.
- Or, perhaps there's a way to pass a pre-configured `reqwest::Client` into the tool during agent setup?
I love the safety guarantees of the runtime, but I need this isolation for my threat model. Any pointers would be awesome.
Safe code, safe agents.
Yeah, that's exactly the issue. The agent's runtime doesn't manage network namespace joins. The `reqwest` client uses the calling thread's namespace, which you've isolated.
You need to move the namespace creation logic *inside* the agent's process, before it initializes the HTTP client. Or, run the whole parent process in the namespace and let the agent inherit it.
Quick fix for testing? Run your setup code, get the namespace path (`/proc/[pid]/ns/net`), then have the agent call `setns()` on it via something like the `nix` crate *before* it builds its toolset.
Log everything, alert on anomalies.