-
Notifications
You must be signed in to change notification settings - Fork 102
feat(orchestrator): real ClaudeAgentHarness via the Claude Agent SDK — P1b-iv (7/7) - #1123
Draft
najmuzzaman-mohammad wants to merge 1 commit into
Draft
Conversation
...(P1b-iv) Makes the inner-execution seam real: ClaudeAgentHarness drives Claude Code for one turn via the Claude Agent SDK, wired to teammcp. Env-var NAMES arrive on the wire (McpServer.env_passthrough) and are resolved to values HERE from the orchestrator's own environment, never on the wire — same trust model as internal/provider/claude.go. The intellectual content is a PURE outcome classifier: classify_outcome keys on the agent's real team_task actions (grounded in the broker's vocabulary — complete/done -> completed, submit_for_review -> review, block -> blocked, planning-without-a-terminal-action -> plan_ready, else continue). Claude Code namespaces MCP tools as mcp__<server>__team_task, so the classifier matches the tool-name suffix. This keeps the policy fully unit-tested without a model key or the SDK installed; only the thin SDK glue (build options, run query, collect transcript) is lazy + pragma-no-cover. build_harness degrades to FakeHarness when the SDK is absent, so the service stays runnable key-free and existing tests are unchanged. This also closes the P1b-iii FakeHarness gap: the real harness returns a real gate state instead of re-projecting running. Renumbered from 'P2' to P1b-iv to avoid colliding with the migration plan's P2 (the CEO decompose node); this work completes the single-task §5b seam. - classify_outcome + TurnTranscript/ToolCall (pure, 11 cases incl. priority + mcp-prefix matching + non-team_task action ignored). - _mcp_servers_config resolves env names from a provided env (value present, unset -> , ungranted vars absent). - run_turn fails loud with install guidance when the SDK is absent (CI path). - _prompt_for / _permission_mode_for (planning -> read-only 'plan'). - 43 pytest green; live smoke still SMOKE OK (degrades to FakeHarness). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Important
Review skipped
Draft detected.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 629878a0-e399-4953-937a-f0287d1d0ac0
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
- 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
deepagents/07-claude-agent-harness
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Real inner harness — P1b-iv (7/7 in stack)
Makes the inner-execution seam real:
ClaudeAgentHarnessdrives Claude Code forone turn via the Claude Agent SDK, wired to teammcp. This completes the
single-task path (§5b) — the orchestrator now drives an actual Claude turn
instead of
FakeHarness.The heart of it: a pure classifier
The turn outcome is decided by
classify_outcome— a pure function keyed on theagent's real
team_taskactions (grounded in the broker's vocabulary):complete/done→completed,submit_for_review→review,block→blocked,planning-without-a-terminal-action→plan_ready, else continue. Claude Code
namespaces MCP tools as
mcp__<server>__team_task, so the classifier matches thetool-name suffix. No prose parsing. This keeps the policy fully unit-tested
without a key or the SDK installed — only the thin SDK glue (build options, run
query, collect transcript) is lazy +
pragma: no cover.Secrets stay names-only
Env-var names arrive on the wire (
McpServer.env_passthrough) and areresolved to values here from the orchestrator's own environment — same trust
model as
internal/provider/claude.go. Tested: granted names resolve, unset →"", ungranted vars never appear.Degrade-safe
build_harnessreturnsFakeHarnesswhen the SDK is absent, so the servicestays runnable key-free and existing tests are unchanged. This also closes the
P1b-iii FakeHarness gap — the real harness returns a real gate state instead of
re-projecting
running.Verify
Live agent run needs
pip install claude-agent-sdk+ a model key.Base:
deepagents/06-orchestrator-e2e(PR #1122).🤖 Generated with Claude Code