Skip to content

Migrate to deepagents' auto-added general-purpose subagent#265

Merged
alexkroman merged 4 commits into
mainfrom
claude/zen-ritchie-gu4th3
Jun 23, 2026
Merged

Migrate to deepagents' auto-added general-purpose subagent#265
alexkroman merged 4 commits into
mainfrom
claude/zen-ritchie-gu4th3

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Summary

Refactor the general-purpose subagent from a manually-declared spec to leveraging deepagents' auto-added subagent, customized via a harness profile. This simplifies the code by removing explicit subagent declaration while maintaining all write-gating behavior and allowing prose customization for voice turns.

Key Changes

  • subagents.py: Replaced general_purpose_subagent() function (which returned a subagent spec dict) with register_gp_subagent_profile() that registers a harness profile to override the auto-added subagent's prompt and description. The subagent now inherits the gateway-bound model, sandboxed toolset, and top-level interrupt_on automatically.

  • brain.py:

    • Removed the subagents key from _graph_kwargs() — deepagents now auto-adds the general-purpose subagent
    • Added call to register_gp_subagent_profile() in build_graph() before creating the deep agent
    • Updated docstring to clarify that the auto-added subagent inherits interrupt_on so delegated writes still surface at the parent approval gate
  • test_agent_cascade_subagents.py: Rewrote tests to verify the new approach:

    • test_register_gp_subagent_profile_overrides_prompt_and_description() — validates the harness profile registration
    • test_build_graph_registers_the_gp_subagent_profile() — confirms build_graph() calls the registration
    • test_profile_override_lands_on_the_auto_added_subagent() — end-to-end verification that the profile reaches the auto-added subagent
    • test_graph_kwargs_on_gates_writes_without_declaring_a_subagent() — confirms no explicit subagent is declared
    • Removed tests for the old general_purpose_subagent() function
    • Updated _delegating_graph() helper to remove the manual subagent spec, relying on auto-addition instead
    • Updated the HITL regression test comment to clarify the auto-added subagent behavior

Implementation Details

  • The harness profile is registered under the provider key "openai" (not a full provider:model identifier) so the override applies regardless of which OpenAI model is selected via --model
  • The profile only customizes prose (system prompt and description); the subagent still inherits the gateway-bound model, sandboxed tools, and write-gating from the top-level create_deep_agent() call
  • Registration is idempotent and happens once per build_graph() call; the deepagents import stays lazy (off the startup path)
  • All write-gating behavior is preserved: delegated writes still surface at the parent approval gate via the inherited interrupt_on

https://claude.ai/code/session_01LXmmmJ53yfuc3CKemRQi7x

The live cascade hand-built the general-purpose `task` subagent as an explicit
`subagents=[…]` spec, restating `interrupt_on` and the model/tools omissions.
But deepagents already auto-adds a general-purpose subagent and derives its
`interrupt_on` from the top-level `create_deep_agent(interrupt_on=…)` we pass —
so the subagent inherits the write-gating, gateway-bound model, and sandboxed
toolset without us declaring it. A delegated write still surfaces at the parent
approval gate (the HITL invariant), now verified against the *auto-added*
subagent.

The only thing worth customizing is its prose: deepagents' default subagent
prompt asks for a "complete answer", but a live voice turn wants a short,
spoken-length summary. `subagents.py` now collapses to a harness profile
(`GeneralPurposeSubagentProfile`) carrying just that prompt + description,
registered under the gateway model's provider so the override survives a
`--model` change. Drops the explicit subagent spec and the redundant
per-subagent `interrupt_on`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LXmmmJ53yfuc3CKemRQi7x
@alexkroman alexkroman enabled auto-merge June 23, 2026 15:46
@alexkroman alexkroman added this pull request to the merge queue Jun 23, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 23, 2026
@alexkroman alexkroman enabled auto-merge June 23, 2026 15:52
claude added 2 commits June 23, 2026 15:58
The origin/main merge added a two-line module-docstring note, nudging
brain.py to 501 lines and failing the max-file-length gate in CI.
Condense the _graph_kwargs docstring (no logic change) back to 500.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LXmmmJ53yfuc3CKemRQi7x
@alexkroman alexkroman added this pull request to the merge queue Jun 23, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 23, 2026
@alexkroman alexkroman enabled auto-merge June 23, 2026 16:14
@alexkroman alexkroman added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit f3f6715 Jun 23, 2026
20 checks passed
@alexkroman alexkroman deleted the claude/zen-ritchie-gu4th3 branch June 23, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants