Repository navigation
Sub-agents: the brief survives a long transcript, and the main agent's roster - #333
Merged
Merged
Conversation
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.
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.
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.
MIN_SAVINGof 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.The main agent's roster
With
SubAgentPolicy(follow_ups=True), a main agent with sub-agents (it hasmessage_agent) is told which of its sub-agents are open:/compact), so the head of the request stays the same for prompt caching.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.RosterMiddleware), counted by the summarization.Tests: written first and seen failing. The shared contract suite runs on both backends and covers:
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.