release: bash sandbox tool + DRY stop condition (#583)

Merged
SW
5mo ago
+615-30

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

    • bash tool: runs commands in the sandbox (supports cwd, detached), returns stdout/stderr, marks truncated output.
    • Full tool loop via streamText tools with experimental_context.
    • buildAgentTools factory to register tools (currently bash).
    • AgentContext + isAgentContext, getSandbox reconnect per call, and buildRecoupExecEnv injecting only RECOUP_ORG_ID.
  • Refactors

    • runAgentStep now accepts agentContext, passes tools and stopWhen: CHAT_AGENT_STOP_WHEN.
    • handleChatWorkflowStream derives recoupOrgId from the session clone URL and builds AgentContext from sandbox state.
    • Removed token exposure (recoupAccessToken) from context; tightened isAgentContext checks.
    • 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

Review Change Stack