gemini-cli - ✅(Solved) Fix I feel the subagents are duplicating work when running in parallel [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25533Fetched 2026-04-17 08:55:36
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×2commented ×1cross-referenced ×1mentioned ×1

PR fix notes

PR #25572: fix(agents): isolate subagent thread context to prevent prompt broadcast

Description (problem / solution / changelog)

Summary

Isolates subagent thread context to prevent prompt broadcast during parallel execution.

Details

When the scheduler dispatches parallel subagents, it previously passed the global config.promptId to the execution context. This caused all parallel workers to share the same memory pointer and read the unpartitioned parent history, resulting in duplicated work.

This patch forks the promptId by appending the parentCallId to the scheduler context, mathematically ensuring each subagent operates within an isolated thread and only processes its specific invocation arguments without scope creep.

Related Issues

Fixes #25533

How to Validate

Booted the local executor and submitted the following stress-test:

Act as a 'Recipe Scout'. I want you to find recipes for 3 different dishes: Tacos, Sushi, and Pasta. Run these tasks in parallel using subagents.

Verified that the subagents successfully partition the tasks (one for Tacos, one for Sushi, one for Pasta) and execute without inheriting the parent's full conversation history.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

Changed files

  • packages/core/src/agents/agent-scheduler.ts (modified, +4/-2)

Code Example

> /about
About Gemini CLI│                                                                                                                                           │ 
CLI Version                                     0.37.1Git Commit                                      3b2d4f100                                                                                 │ 
Model                                           gemini-3-flash-preview                                                                    │ 
Sandbox                                         no sandbox                                                                                │ 
OS                                              linux                                                                                     │ 
Auth Method                                     Signed in with Google (ksprashanth82@gmail.com)Tier                                            Gemini Code AssistGCP Project                                     cloudshell-gca                                                                            │ 
IDE Client                                      Cloud Shell

---

---
name: recipe-scout
description: Finds a single, specific recipe matching provided meal and macro constraints.
tools:
  - google_web_search
---
You are a precision culinary researcher. You will be given a specific meal request and ingredient constraints.
- Action: Search the web to find exactly ONE high-quality recipe that perfectly aligns with these constraints. 
- Output: Return the recipe title, URL, exact ingredient list with quantities, and cooking instructions. Do not output conversational filler.
RAW_BUFFERClick to expand / collapse

What happened?

I am testing subagents and I have created a few of them. However when I send the instructions, it seems to send the same prompt to all the parallel sub agents, and each of them is executing the sme prompt in parallel. Then each of them execute the next prompt together and so on. Finally the results are consolidated. This seems wrong and not as expected.

Either that or the display of running subagents is wrong.

<img width="716" height="673" alt="Image" src="https://github.com/user-attachments/assets/45e26482-4730-4c4d-bf72-9e57278b45a1" />

What did you expect to happen?

If there are 3 tasks (multiple instances of same subagent), each of the subagent should run one task in parallel. All 3 shouldn't run all 3 tasks.

Client information

<details> <summary>Client Information</summary>

Run gemini to enter the interactive CLI, then run the /about command.

> /about
│ About Gemini CLI                                                                                                                          │ 
│                                                                                                                                           │ 
│ CLI Version                                     0.37.1                                                                                    │ 
│ Git Commit                                      3b2d4f100                                                                                 │ 
│ Model                                           gemini-3-flash-preview                                                                    │ 
│ Sandbox                                         no sandbox                                                                                │ 
│ OS                                              linux                                                                                     │ 
│ Auth Method                                     Signed in with Google ([email protected])                                           │ 
│ Tier                                            Gemini Code Assist                                                                        │ 
│ GCP Project                                     cloudshell-gca                                                                            │ 
│ IDE Client                                      Cloud Shell ```

</details>

### Login information

gmail auth

### Anything else we need to know?

Subagent definition

```markdown
---
name: recipe-scout
description: Finds a single, specific recipe matching provided meal and macro constraints.
tools:
  - google_web_search
---
You are a precision culinary researcher. You will be given a specific meal request and ingredient constraints.
- Action: Search the web to find exactly ONE high-quality recipe that perfectly aligns with these constraints. 
- Output: Return the recipe title, URL, exact ingredient list with quantities, and cooking instructions. Do not output conversational filler.

prompt - attached screenshot. CLI is not letting me select the prompt - I've filed a bug.

<img width="1021" height="114" alt="Image" src="https://github.com/user-attachments/assets/c63cd074-258c-438c-b141-3f2cc1430022" />

extent analysis

TL;DR

The issue might be due to the subagent definition or the way tasks are being sent to the subagents, causing all subagents to execute the same prompt in parallel.

Guidance

  • Review the subagent definition to ensure it is correctly configured to handle multiple tasks in parallel.
  • Verify that the tasks being sent to the subagents are correctly formatted and distinct from one another.
  • Check the CLI output to see if there are any error messages or warnings that could indicate the cause of the issue.
  • Consider testing with a different subagent definition or a different set of tasks to isolate the problem.

Example

No code snippet is provided as the issue is more related to the configuration and usage of the subagents rather than a specific code problem.

Notes

The issue might be related to the way the CLI is handling the subagent tasks, and the provided screenshots and subagent definition might not be sufficient to fully diagnose the problem. Further investigation and testing are needed to determine the root cause.

Recommendation

Apply workaround: Test with a different subagent definition or a different set of tasks to isolate the problem and see if the issue persists. This can help determine if the problem is with the specific subagent or task configuration.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - ✅(Solved) Fix I feel the subagents are duplicating work when running in parallel [1 pull requests, 1 comments, 2 participants]