You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace the current subprocess.Popen(["claude", "-p", …]) invocation with the official Claude Agent SDK. This is the foundational change — most of the other issues in this initiative become trivial once it lands.
Why this matters
Nous currently shells out to the Claude Code CLI in headless mode (orchestrator/cli_dispatch.py:219-222):
claude -p --model <model> --output-format json --dangerously-skip-permissions --max-turns <turns>
That works, but it's a thin shim with significant downsides:
No native streaming. The orchestrator is blind for up to 7200 seconds. The 5/18 sessions show ~90-minute waits with zero progress signal — directly responsible for the "report progress" tic.
No programmatic prompt caching.prompts/methodology/design.md (266 lines) and execute_analyze.md (199 lines) are static and re-sent uncached on every call.
Retry semantics by subprocess restart. When a connection drops mid-turn, the message context is lost and the next attempt has to rebuild it. The SDK retries with full message history.
Custom JSON parser to maintain.cli_dispatch.py has a hand-rolled parser for --output-format json plus error-classification heuristics.
TL;DR
Replace the current
subprocess.Popen(["claude", "-p", …])invocation with the official Claude Agent SDK. This is the foundational change — most of the other issues in this initiative become trivial once it lands.Why this matters
Nous currently shells out to the Claude Code CLI in headless mode (
orchestrator/cli_dispatch.py:219-222):That works, but it's a thin shim with significant downsides:
prompts/methodology/design.md(266 lines) andexecute_analyze.md(199 lines) are static and re-sent uncached on every call.cli_dispatch.pyhas a hand-rolled parser for--output-format jsonplus error-classification heuristics.What's already shipped this builds on
Proposed approach
claude-agent-sdk(or whichever Anthropic SDK package is current at the time) topyproject.toml.orchestrator/sdk_dispatch.pymirroring theLLMDispatcherinterface (samedispatch()signature, same artifact contract).usageevents directly; keepllm_metrics.jsonlschema for backward compatibility.--agent sdkto the CLI alongside the existingapiandinlineoptions. Promotesdkto default after a release of real-world testing.Acceptance criteria
nous run --agent sdk campaign.yamlruns a campaign end-to-end with parity on the existing test suite.cli_dispatch.pyis unchanged but no longer the default path.docs/architecture.mdupdated.Out of scope
cli_dispatch.pyentirely (do that in a later cleanup PR).Part of #120.