Repository navigation
Description
Describe the bug
With the app running, GET /api/agents/{agentId}/sessions/{key} returns HTTP 500. SessionController reads the session transcript through the agent's own sandbox-backed workspace filesystem (HarnessAgent.getWorkspaceManager()), which is only valid inside an agent call context. For an out-of-band REST read there is no active sandbox, so it throws:
SandboxConfigurationException: No active sandbox — sandbox filesystem used outside of a call context
The session list endpoint hits the same read path but swallows the exception, so it still responds — but every "last message preview" comes back null.
Every other workspace/skills/tools endpoint is unaffected because it correctly goes through WorkspaceManagerFactory.forAgent(...), which borrows a live sandbox for the read. The session subsystem is the one place that uses getWorkspaceManager() directly.
Note: reaching any endpoint requires the startup fixes from #1600 first — without them the app fails to boot, which is why this was previously masked.
To Reproduce
- Run the app with the default
DockerFilesystemSpecworkspace (needs the [Bug]: agentscope-dataagent fails to start — builderBootstrap throws "requires a non-noop snapshotSpec" (default single-node run) #1600 startup fixes so it boots). - Log in and create a session (send one chat message).
GET /api/agents/data-agent/sessions/{sessionKey}with theAuthorization: Bearer <jwt>header.- → HTTP 500.
Expected behavior
The session detail endpoint returns the parsed transcript; the list endpoint returns real last-message previews — both reading session state regardless of whether an agent call is currently in flight.
Error messages
500 Server Error for HTTP GET "/api/agents/data-agent/sessions/{key}"
io.agentscope.harness.agent.sandbox.SandboxException$SandboxConfigurationException:
No active sandbox — sandbox filesystem used outside of a call context
at io.agentscope.dataagent.web.api.SessionController.readSessionLogContent(SessionController.java:310)
at io.agentscope.dataagent.web.api.SessionController.lambda$turns$3(SessionController.java:130)
Client response:
{ "status": 500, "error": "Internal Server Error",
"path": "/api/agents/data-agent/sessions/634070f2-77fc-48ac-8ec7-e886d73b89d6" }Environment (please complete the following information):
- AgentScope-Java Version: 2.0.0-RC1 (identical to
mainfor theagentscope-dataagentmodule) - Java Version: 17 (Amazon Corretto 17.0.15)
- OS: macOS (arm64), running in a Linux container
Additional context
Root cause: out-of-band reads use the agent's call-context-bound filesystem (getWorkspaceManager()) instead of the borrow-based WorkspaceManagerFactory.forAgent(...) used everywhere else.
Affected call sites (entire blast radius — confined to the session subsystem):
| Location | Endpoint | Symptom |
|---|---|---|
SessionController.readSessionLogContent — ha.getWorkspaceManager() (SessionController.java:305), reads at :310/:316 — called by turns() (:130) |
GET /api/agents/{id}/sessions/{key} |
Hard 500 No active sandbox |
same, called by lastMessagePreview() (:269) from the list loop (:107) |
GET /api/agents/{id}/sessions |
List works but every preview is null (exception swallowed by catch (Exception ignored)) |
SessionAgentManager.resolveSessionFilePath / history — delegate.getWorkspaceManager() (SessionAgentManager.java:956) |
fallback path of readSessionLogContent (:322) |
Same anti-pattern — also relies on the call-bound FS |
Correct pattern used by the unaffected controllers (AgentWorkspaceController :625, AgentSkillsController, AgentToolsController :293, AgentCloneController, the marketplace tools, AgentActivityStore, UserMarketplaceRegistry):
WorkspaceManager wm = workspaceManagerFactory.forAgent(ownerId, agentId, def.workspacePath());
// wm.readManagedWorkspaceFileUtf8(RuntimeContext.empty(), relPath) now has a live (borrowed) sandboxSuggested fix: route the session reads (SessionController.readSessionLogContent, and the SessionAgentManager session-file helpers it falls back to) through WorkspaceManagerFactory.forAgent(...) instead of getWorkspaceManager(), matching the rest of the module.
Related: #1600 (startup blockers) — same root architecture (per-user workspace is a SandboxBackedFilesystem); this is the read-path counterpart.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn progress
Activity
修复 agentscope-dataagent 会话 REST 接口读取 sandbox workspace 导致的 500
fix(dataagent): read session transcript via borrowed sandbox, not cal…
fix(harness/examples): Fix the reading of historical sessions of the …