release: real cwd in system prompt (#597)

Merged
SW
5mo ago
+131-10

Summary

  • handleChatWorkflowStream reuses the already-connected sandbox to read real workingDirectory instead of hardcoding DEFAULT_WORKING_DIRECTORY
  • runAgentStep builds a dynamic system prompt via new buildAgentSystemPrompt(...) — adds an Environment section ("Working directory: . (workspace root), Use workspace-relative paths") so the agent knows it's in a sandbox without running pwd on every turn
  • Wire format matches open-agents byte-for-byte for the cwd portion
  • Branch-handling scope dropped: branch is always main in api's deployment, so per-session branch templating doesn't add information today (re-addable when meaningful per-session branches land)

Cutover progress

#BundleStatus
1C per-message cost/usage✅
2B subagent live progress + transcript✅
3A.7 real cwd in system prompt✅ this release
4A.6 Anthropic prompt cache controlpending
5A.4 forward Privy JWT as recoupAccessTokenpending

Test plan

  • 7 unit tests; full suite 3119/3119 pass
  • E2E on preview: prompt "what's your cwd?" with no tools allowed returns ". (workspace root)" (vs prod "system prompt does not contain")
  • Cross-validated against open-agents production — cwd answer matches byte-for-byte

🤖 Generated with Claude Code


Summary by cubic

Send the real sandbox working directory in the agent’s system prompt so the model knows it’s in the workspace without running pwd. The handler reads cwd from the connected sandbox and runAgentStep builds the prompt via buildAgentSystemPrompt.

  • New Features
    • handleChatWorkflowStream connects the sandbox and uses its workingDirectory; falls back to the default if connect fails.
    • runAgentStep uses buildAgentSystemPrompt to add an Environment section: "Working directory: . (workspace root); Use workspace-relative paths".
    • Matches open-agents wire format for the cwd portion; removed branch templating (branch is always main).