release: bash sandbox tool + DRY stop condition (#583)
Merged
SW
5mo ago+615+615+012345678901234567890123456789-30-30-01234567890123456789
Summary
Release of PR #583 — ports the `bash` sandbox tool from open-agents and wires the entire tool-execution machinery end-to-end through Vercel Workflow.
PR 4 of N for the open-agents → api chat-workflow port (slim scope — 1 tool + wire-up to prove the machinery; remaining 10 tools port in follow-ups).
What's now live
- Full agentic loop: `user → model → bash(cmd) → real sandbox exec → tool result → model wrap-up → stop`
- `lib/agent/tools/` — `AgentContext` type + `isAgentContext` guard + `getSandbox` reconnect helper + `buildRecoupExecEnv` (RECOUP_ORG_ID only — no token exposure) + `bashTool`
- `lib/agent/buildAgentTools.ts` factory (one-line append for future tools)
- `runAgentStep` accepts `agentContext`, passes via `streamText`'s `experimental_context`
- `handleChatWorkflowStream` derives `recoupOrgId` from session clone URL, builds `AgentContext`, passes to `start(workflow)`
- `CHAT_AGENT_STOP_WHEN = stepCountIs(111)` shared via `lib/chat/const.ts` — used by both `/api/chat` (legacy MCP agent) and `/api/chat/workflow` (workflow agent)
Verification
- Full suite: 2980/2980 pass, lint clean, production build succeeds
- E2E verified on preview: real `wrun_` workflow + real `bash ls` execution against sandbox + real LLM wrap-up turn interpreting the file listing
🤖 Generated with Claude Code
Summary by cubic
Ports the bash sandbox tool and wires tool execution end-to-end in the chat workflow, enabling real shell commands inside the sandbox with model wrap-up in one workflow turn. Also DRYs the agent stop condition via CHAT_AGENT_STOP_WHEN shared by /api/chat and /api/chat/workflow.
-
New Features
bashtool: runs commands in the sandbox (supportscwd,detached), returns stdout/stderr, marks truncated output.- Full tool loop via
streamTexttools withexperimental_context. buildAgentToolsfactory to register tools (currentlybash).AgentContext+isAgentContext,getSandboxreconnect per call, andbuildRecoupExecEnvinjecting onlyRECOUP_ORG_ID.
-
Refactors
runAgentStepnow acceptsagentContext, passes tools andstopWhen: CHAT_AGENT_STOP_WHEN.handleChatWorkflowStreamderivesrecoupOrgIdfrom the session clone URL and buildsAgentContextfrom sandbox state.- Removed token exposure (
recoupAccessToken) from context; tightenedisAgentContextchecks. - Stream writing made safer by acquiring the writer once per run.
Summary by CodeRabbit
Release Notes
- New Features
- Agents can now execute bash commands within sandboxed environments
- Added persistent sandbox context support across agent workflow steps
- Organization context automatically forwarded to sandboxed command execution
- Agent step execution is now governed by step limits