Add spawn_identical_subagents tool to the AI framework#24305
Conversation
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 4415607 | Docs | Datadog PR Page | Give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00631c1c18
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
AAraKKe
left a comment
There was a problem hiding this comment.
Thanks! Some questions and a simple request.
My Feedback Legend
Here's a quick guide to the prefixes I use in my comments:
praise: no action needed, just celebrate!
note: just a comment/information, no need to take any action.
question: I need clarification or I'm seeking to understand your approach.
nit: A minor, non-blocking issue (e.g., style, typo). Feel free to ignore.
suggestion: I'm proposing an improvement. This is optional but recommended.
request: A change I believe is necessary before this can be merged.
The only blocking comments are request, any other type of comment can be applied at discretion of the developer.
…idationError explicitly
Validation ReportAll 21 validations passed. Show details
|
What does this PR do?
Adds a new
spawn_identical_subagentstool to the ddev AI framework. It runs the same subagent — identical system prompt and tool set — over many different assignments in parallel, sending the shared system prompt and tools once instead of repeating them per child.SpawnIdenticalSubagentsTool(ai/tools/agents/spawn_identical_subagents.py): validates assignments (non-empty, unique names, a cap on fan-out) and the requested tool subset, fans out under anasyncio.Semaphore, and aggregates per-child results in assignment order. One child failing (or hittingmax_tokens) never affects its siblings; the call succeeds on partial results and only fails when validation fails or every child errors.spawn_subagentinto an abstractBaseSpawnTool[TInput](child config/scope construction, tool-subset validation,max_tokenshandling).SpawnSubagentToolis refactored onto it with no external behavior change. Neither spawn tool is ever offered to a child.ToolContextchanges). Flows opt in by listingspawn_identical_subagentsin an agent'stools.conftest.pyprovides fake-agent and fake-process-factory fixtures; base-class restriction logic is tested once intest_base.py; per-tool behavior (aggregation/order, partial and total failure,max_tokensnotice, concurrency cap, config inheritance) is covered in the respective files.Motivation
spawn_subagentdelegates one subtask to one child, re-inlining the fullsystem_prompton every call. Running the same worker over N input slices therefore costN×(system_prompt + prompt)of output tokens — enough to push a worker turn pastmax_tokensand truncate it midtool_use. This tool makes "same agent, many assignments" first-class, so output scales as1×system_prompt + N×(tiny assignment prompt).Review checklist (to be filled by reviewers)
qa/requiredif this PR needs QA validation, orqa/skip-qaif it does not. Exactly one of the two is required.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged