Skip to content

fix(code): fix subagent sessions#1464

Open
adboio wants to merge 1 commit intomainfrom
04-02-fix_code_fix_subagent_sessions
Open

fix(code): fix subagent sessions#1464
adboio wants to merge 1 commit intomainfrom
04-02-fix_code_fix_subagent_sessions

Conversation

@adboio
Copy link
Copy Markdown
Contributor

@adboio adboio commented Apr 2, 2026

disclaimer: i hate this

this solution is pretty bad, but it works, and it (unfortuntaely) might be the best we've got right now. i've spent ~4 hours on this and don't think it's worth sinking more time into it right now, unless someone has a strong opinion against this approach.

Problem

closes #1371

explore sub-agents are very slow and constnatly run out of context.

this happens becuase each one is running haiku with 200k context, and they all start with 180k+ tokens filled with mcp tool instructions.

our primary sessions have tool search enabled, which solves this problem. explore agents specifically use haiku, which does not support tool search, hence the massive ~90+ tool injection.

so, our options are:

  1. strip tools from the explore agent
  2. or bump the explore agent up to a model that supports tool search (sonnet or opus)

either option requires fully overriding the explore agent definition in the agent sdk, because it does not support partial overrides.

the problem then becomes a bug(?) in the agent sdk: you can't actually override built-in agent names. the docs say you should be able to, and the primary session actually initializes with the overrides, but then when the subagents are invoked, they still use the defaults.

Changes

  1. writes a new definition for the explore agent: minimal tool list, on haiku
  2. patches the agent sdk to ensure the override makes it through

alternatives considered

  1. there's a global env var we can set to override all sub-agent models, and it works, but means we'd be downgrading other agents (plan, general purpose, etc) which default to inheriting the model from the parent session
    1. if we want to do this: https://app.graphite.com/github/pr/PostHog/code/1465/fix(code)-force-sub-agents-to-use-sonnet
  2. we could just rewrite all models from haiku -> sonnet in the proxy but there's no good way to check "is this request coming from the explore agent?" so we effectively drop support for haiku across the board. but maybe that's not a bad thing, if even primary sessions with haiku end up with massive bloated context?

How did you test this?

manually

Copy link
Copy Markdown
Contributor Author

adboio commented Apr 2, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@adboio adboio requested a review from a team April 2, 2026 20:26
@adboio adboio marked this pull request as ready for review April 2, 2026 20:26
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.

Subagents run significantly slower than main agent and silently stop or cancel

1 participant