google-gemini / google-gemini/gemini-cli
Subagent recovery after MAX_TURNS is reported as GOAL success, hiding interruption
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 45
Description
### What happened?
**Summary**: `codebase_investigator` subagent reports `status: "success"` and `Termination Reason: "GOAL"` even though its own result says it hit the maximum turn limit before doing any analysis.
While using Gemini CLI to investigate two local repositories (`t3code` and `superset`), the agent invoked the `codebase_investigator` subagent and it failed immediately without doing any analysis.
I ran the Gemini CLI on these two local repositories with an objective asking it to understand their architectures and AI agent integrations. The saved session log shows:
- The main agent called `codebase_investigator` with a valid, concrete objective.
- The tool result was reported with `status: "success"` and `Termination Reason: "GOAL"`.
- The embedded result text simultaneously says the investigation was interrupted because the "maximum number of turns was exceeded" before any specific task was identified or initiated.
- `RelevantLocations` was empty and no actual codebase analysis was performed.
This looks incorrect because:
1. The subagent appears to have exhausted its turn budget before performing any actual analysis.
2. The termination metadata is internally inconsistent: the parent tool call is surfaced as `status: "success"` with `Termination Reason: "GOAL"`, but the embedded payload describes a limit-induced early termination with no findings.
Relevant evidence from the session log:
```text
session file: session-2026-03-09T18-34-10479ef5.json
line 50: "name": "codebase_investigator"
line 53: objective: "Understand the architecture of t3code and superset..."
line 61: "Termination Reason: GOAL"
line 61: "The investigation was interrupted by a system-mandated termination (maximum turns exceeded)..."
line 61: "\"RelevantLocations\": []"
line 66: "status": "success"
line 79: "The `codebase_investigator` was unable to complete its analysis due to a turn limit..."
```
Full snippet from the saved session:
```json
{
"id": "codebase_investigator_1773081420202_0",
"name": "codebase_investigator",
"args": {
"objective": "Understand the architecture of t3code and superset, focusing on AI agent integrations.\nSpecifically:\n1. In t3code, how is 'Codex' integrated? Where is the core logic for agent interaction?\n2. In superset, what are the different agent/harness integrations (e.g., Mastra, MCP, Claude, etc.) and how are they implemented?\n3. What are the common patterns or interfaces used in superset that could be adapted for t3code to support multiple harnesses?\n\nIdentify key files, symbols, and architectural patterns in both repositories."
},
"result": [
{
"functionResponse": {
"response": {
"output": "Subagent 'codebase_investigator' finished.\nTermination Reason: GOAL\nResult:\n{\n \"SummaryOfFindings\": \"The investigation was interrupted by a system-mandated termination (maximum turns exceeded) before any specific task could be identified or initiated. As a result, no codebase analysis was performed, and no relevant locations or insights could be gathered.\",\n \"ExplorationTrace\": [\n \"Received system notification that the maximum number of turns was exceeded.\",\n \"Followed emergency termination protocol as instructed.\"\n ],\n \"RelevantLocations\": []\n}"
}
}
}
],
"status": "success"
}
```
### What did you expect to happen?
I expected one of these outcomes:
- `codebase_investigator` should actually explore the repositories and return findings.
- If it truly hits a turn limit, it should do so after some visible work, and the tool invocation should be surfaced as a failure or explicit limit condition, not as `status: "success"` with `Termination Reason: "GOAL"`.
At minimum, the CLI should not report a contradictory success state for a subagent that says it exceeded its turn budget before beginning analysis. If the subagent hits a system-imposed turn limit before doing useful work, the tool result should be reported as a failure or explicit limit condition (e.g. `status: "error"` with a clear error code), not as a successful `GOAL` completion.
### Client information
Client Information
Run `gemini` to enter the interactive CLI, then run the `/about` command.
```console
> /about
Gemini CLI package version: 0.32.1
Platform: Windows
OS: Microsoft Windows NT 10.0.26200.0
Node.js: v20.20.0
PowerShell: 5.1.26100.7920
```
### Login information
Google Account, Pro tier from students promotion
### Anything else we need to know?
- After the failed `codebase_investigator` call, the main agent continued with manual file exploration and eventually produced an implementation plan. So the overall conversation did not fully crash, but the specialized investigator tool clearly failed.
- My current inference is that this may be either:
- turn-budget state leaking into a fresh subagent invocation, or
- an incorrect mapping of a subagent limit/error state into a successful `GOAL` termination in the parent session.
- If useful, I can provide the full saved session JSON or a redacted version of it.
Contributor guide
Assessment
This issue has not been assessed yet.