Skip to content

Sub-agents: the brief survives a long transcript, and the main agent's roster - #333

Merged
shoom1 merged 12 commits into
developfrom
feature/subagent-roster
Nov 20, 2026
Merged

shoom1 merged 12 commits into
developfrom
feature/subagent-roster

Conversation

@shoom1

@shoom1 shoom1 commented Nov 20, 2026

Copy link
Copy Markdown
Owner

This PR keeps a sub-agent instance's brief through a growing transcript and adds the main agent's roster of its open sub-agents, on both backends.

The brief survives
A follow-up's own message is not its instance's brief, so a long transcript could lose the brief from the requests: on Deep Agents a summary of the instance's thread stood for it, and on ADK the fit guard could leave it out of a follow-up's request. An instance's first run now marks its message as the brief, and every later request keeps it.

  • Deep Agents: the instance's own summarization (on its model, against its budget) writes each summary that stands for the brief as a message that opens with the brief's text. A summary that would save less than MIN_SAVING of the trigger is skipped, so a long brief does not cause one summary per call. A request is still summarized when it would go past the budget, or when the budget is not known.
  • ADK: summaries stay the main agent's. The fit guard and the overflow retry keep the brief whatever else they leave out, as they keep the run's task message.
  • Backend difference (in the CHANGELOG): a Deep Agents summary also stands for a follow-up's own message once that message is older than what a summary keeps word for word, while ADK's trim keeps it. The main agent's summaries are unchanged.

The main agent's roster
With SubAgentPolicy(follow_ups=True), a main agent with sub-agents (it has message_agent) is told which of its sub-agents are open:

<agents>
Your sub-agents in this conversation (message_agent continues one):
- <id> (<type>, <status>): <title> — <first line of its last result>
</agents>
  • It lists idle, stopped or running instances, newest first, in at most 2,000 characters. The oldest lines are left out whole, never cut.
  • It is a snapshot per conversation, taken and dropped where the memory index's is (the conversation opened, a summary written, /compact), so the head of the request stays the same for prompt caching.
  • ADK: it is a user content of its own after the index (RosterPlugin). The fit guard never drops it, and folds the index, the roster and a summary into the first user text, in that order. The overflow retry keeps it.
  • Deep Agents: it is the text block after the index's in the first human message (RosterMiddleware), counted by the summarization.
  • There is no roster with the policy's defaults, or when every sub-agent is closed.

Tests: written first and seen failing. The shared contract suite runs on both backends and covers:

  • a follow-up after a summary or a trim still holding the brief, once;
  • the roster after a delegation once the snapshot is retaken;
  • a summary in a turn retaking the roster;
  • its text and cap;
  • no roster with the defaults or when every sub-agent is closed.

Unit tests cover the brief on each backend, the long-brief case, the roster plugin and middleware, and the fold order. A pin test fails first if Deep Agents moves the two private summarization methods the override uses. Removing the roster's snapshot, or dropping the brief, fails the contract on both backends.

The full offline suite passes in the worktree, except TestChildImportOrigin::test_child_resolves_the_checkout, which fails the same way on develop under the worktree wrapper. The summarization, brief and contract files also pass on CI's library versions (deepagents 0.7.41, google-adk 2.15) in a scratch virtualenv.

roster_text lists a conversation's open instances newest first, one line
each with its type, status, title and the first line of its last result,
at most 2,000 characters in whole lines. Rosters keeps one snapshot per
conversation, taken at its first request and kept until dropped, as the
memory index is, so the head of the request stays cached.
A root with message_agent carries its roster (_roster_wanted); the
manager holds one snapshot per conversation (_rosters, _roster_now),
dropped wherever the memory index's is (_forget_memory_index: the
conversation opened, a summary, /compact), cleared by the release and
forgotten with a deleted conversation.
A follow-up whose request outgrew its small model, summarized on Deep
Agents and trimmed on ADK, still holds its instance's brief once. The
main agent's requests carry the roster of its open sub-agents once the
snapshot is taken again (the conversation opened): its text, the same
for the whole turn, its cap in whole lines newest first; none with the
policy's defaults and none when every instance is closed. make_crew takes
models entries; Crew.opening reads a request's first user message.
RosterPlugin, for a root with message_agent, puts the conversation's
roster first in its requests, before MemoryIndexPlugin puts the index
ahead of it. The fit guard keeps what opens a request, the index, the
roster and a summary, and folds them into the first user text in that
order; the overflow retry keeps the index and the roster first.
A first run marks its message as its instance's brief (BRIEF_KEY in the
state delta of its own event); a follow-up's message is not the brief.
The fit guard and the overflow retry of a sub-agent type's chain keep the
brief as they keep the task message: the turns after it go, and what is
kept opens with it, the note, then the task message when that went too.
…ents

RosterMiddleware, for a root with message_agent, puts the roster first in
the first human message, outside MemoryIndexMiddleware, which puts the
index ahead of it. The summarization counts it as it counts the index,
and a summary drops its snapshot, with or without a memory tool.
A first run's task message is marked as its instance's brief. Each
summary of the instance's thread that stands for the brief opens with
it: the summary message Deep Agents builds and stores gets the brief's
text first, so every later request, and every reader of the stored
summary, holds it. The main agent's summaries are unchanged.
A brief restated in every summary can keep a request near the trigger,
and a summary at every model call saved nothing. In a thread with a
brief, a summary at the trigger that would stand for less than a fifth
of it is skipped, as ADK's is; a request over the input budget is still
summarized.
… pass the budget

The skip trusted Deep Agents' own over-budget check, which has no budget
for a model whose window its profile does not give. The summarization
now holds the agent's input budget and skips only below it.
@shoom1
shoom1 merged commit 32b495e into develop Nov 20, 2026
6 checks passed
@shoom1
shoom1 deleted the feature/subagent-roster branch November 20, 2026 12:16
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.

1 participant