feat(core): add concurrency safety guidance for subagent delegation (#17753)#21278
feat(core): add concurrency safety guidance for subagent delegation (#17753)#21278abhipatel12 merged 3 commits intomainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces crucial concurrency safety guidelines for subagent delegation within the core agent system. The aim is to mitigate race conditions by providing clear instructions to the model on when it is safe to parallelize subagent calls (e.g., for read-only tasks) and when sequential execution is mandatory (e.g., for tasks modifying shared resources). This enhancement ensures greater stability and predictability in agent operations, supported by a new evaluation test to validate compliance with these rules and a minor configuration update to streamline test execution. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Size Change: +429 B (0%) Total Size: 26 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request introduces important concurrency safety guidance for subagent delegation, preventing potential race conditions. The changes include new prompts for the model, evaluation tests to verify the behavior, and a CI improvement to disable GPG signing. The implementation is solid, but there is one violation of the repository's development conventions regarding modifications to legacy prompt files.
|
|
||
| Each sub-agent is available as a tool of the same name. You MUST always delegate tasks to the sub-agent with the relevant expertise, if one is available. | ||
|
|
||
| **Concurrency Safety and Mandate:** You should NEVER run multiple subagents in a single turn if their abilities mutate the same files or resources. This is to prevent race conditions and ensure that the workspace is in a consistent state. Only run multiple subagents in parallel when their tasks are independent (e.g., multiple concurrent research or read-only tasks) or if parallel execution is explicitly requested by the user. |
There was a problem hiding this comment.
I wonder if this is going to discourage parallelism in general. Is there any value to indicating that parallelism is encouraged, just only when it's safe (parallel reads, or parallel writes to different files or directories)?
There was a problem hiding this comment.
Yeah I def see the concern. In this case, we have the Tool Usage section that still encourages parallelism of general tool use.
this wording is primarily conservative for parallelism of subagents that may mutate things. I think that should be fine. There should be a follow up task that goes deeper into encouraging parallel calls whether subagents or tools.
For parallelism of subagents that mutate things, we'll need to test more. I attempted to be less restrictive, but even in cases that were obviously destructive, the model often still chose to run agents in parallel. even when directly modifying the same file.
gundermanc
left a comment
There was a problem hiding this comment.
Approved with a suggestion.
58ca423 to
4865388
Compare
4865388 to
110e56e
Compare
Summary
Add concurrency safety guidance for subagent delegation to prevent race conditions when running agents in parallel. This PR introduces clear instructions for the model on when it is safe to parallelize subagent calls and when it must remain sequential.
Details
evals/concurrency-safety.eval.tsto verify the model adheres to these parallelism rules.evals/test-helper.tsto setcommit.gpgsign falsein test git repositories to prevent blocking on GPG prompts during CI/tests.Related Issues
Fixes #17753
How to Validate
Run the new concurrency safety evaluation:
npm test evals/concurrency-safety.eval.tsPre-Merge Checklist