agentscope-java icon indicating copy to clipboard operation
agentscope-java copied to clipboard

Sandbox is created on every agent call even for pure chat turns

Open chcodex opened this issue 3 months ago • 4 comments

Problem

In sandbox filesystem mode, a sandbox session is created/resumed on EVERY agent call, even when the turn is pure chat (no command execution, no file read/write).

This includes turns where the agent only replies to a casual conversation — spinning up (or resuming) a container per turn is expensive and wasteful.

Expected behavior

  • A plain chat turn (no command execution, no file read/write) must NOT create or resume a sandbox.
  • The sandbox should be created/resumed only when the agent actually needs to execute a command or read/write the filesystem, right before the operation runs.
  • A turn that touches only workspace metadata (e.g. MEMORY.md, AGENTS.md, knowledge, memory flush) should not trigger sandbox creation.
  • Once created/resumed, the existing isolation-scope behavior (create vs resume per SESSION/USER/AGENT scope) must be preserved.

chcodex avatar Aug 05 '26 06:08 chcodex

@jujn @chickenlj I'm here to ask a question again 😂

chcodex avatar Aug 05 '26 06:08 chcodex

DeerFlow 2.0: SandboxMiddleware(lazy_init=True) is the default. In before_agent, if lazy mode is enabled it simply returns; initialization is deferred until the first tool call to ensure_sandbox_initialized(), at which point a container is acquired from the Provider. Pure conversation turns never touch Docker/K8s. The exact source comment reads: "avoids spinning up containers for conversation turns that don't invoke tools."

OpenAI Agents SDK + Sandbox: The sandbox is an optional backend bound via a Manifest. The Runner only resolves a session when the run actually requires an execution environment—if a live session is passed, it's reused; if resuming from RunState, it's restored; only if neither is provided does it create a fresh one. No code execution means no container is created.

Convex Sandbox / just-bash: Even more aggressive—it skips containers entirely, using serverless Actions + a virtual filesystem with lazy filesystem hydration, where file contents are pulled from storage only when a command actually reads them.

LangChain Deep Agents / LangSmith Sandbox: FilesystemMiddleware exposes the sandbox as a tool, and the sandbox backend is pluggable at agent construction time. An agent can run pure chat without a sandbox backend attached; when one is attached, it goes through the backend protocol on tool invocation—there is no prewarming at harness startup.

Blaxel / E2B / Daytona (sandbox-as-a-service): These emphasize "warm standby + 25–150ms resume," operating on the premise of reuse by conversation_id, on-demand resume, and idle recycling—rather than cold-starting on every call.

chcodex avatar Aug 05 '26 06:08 chcodex

我也有同样的问题

CyberXavier avatar Aug 05 '26 07:08 CyberXavier

same issue

zoulee24 avatar Aug 12 '26 09:08 zoulee24