Repository navigation
fix(platform): start every Gemini CLI kick as a fresh conversation - #4025
Merged
Merged
Conversation
The pinned Gemini CLI's `--resume` replays every tool result of the recorded session twice (its toolCalls[].result and the user record it also writes for the same response — google-gemini/gemini-cli#29365, fix PRs open), so the first request of a resumed conversation that ever ran a tool is refused by the model: Google answers "number of function response parts…", an OpenAI-wire upstream "role 'tool' must be a response to a preceding message with 'tool_calls'". Every later kick of a task, every automatic retry, a mid-run comment's restart and an answered ask all handed the exec the handle, so a Gemini task that used a tool could never continue, and its retries died on the same wall. Harness YAML gains `capabilities.resume`, held coherent with the argv resume slot by the schema; gemini declares false and drops its slot. The task kick, the automation retry, the answered-ask resume and the comment restart read it and take their existing fresh path; the exec builder refuses a handle on such a harness. Qwen Code resumes cleanly and keeps its slot. Docs and the manual suite carry the exception; the contract debt ledger carries the re-enable condition.
The gemini stream parser never set `apiErrorStatus`, so a Gemini CLI
turn the provider refused reached the run with no status: the kick's
"400/404 → start fresh" rule, the broker's 401 rotation and the 429
cooldown never applied to it, and the run's reason was the gateway's
JSON body verbatim. The CLI's `result.error.message` for a refusal is
`[API Error: {"error":{"code":N,…}}]`; for a 429 the SDK's retries
leave only the CLI's own rate-limit sentence (errorParsing.ts
getRateLimitMessage). Read the code and the provider's sentence out of
the body, recognise the 429 by its sentence, and stamp the turn end.
Fixtures captured from the pinned 0.59.0 against a loopback gateway.
larryro
added a commit
that referenced
this pull request
Oct 1, 2026
The audit-chain check read the org's rows, verified the chain, then read the chain head in a second autocommit statement. An audit write commits its row and the head together, so a job of another lane (or this lane's own lockout bell) landing between the two reads left the head one row ahead of the tail just read: `chain=true, head=false` on an intact chain (Backend integration, PR #4025 attempt 1). Both reads now share one repeatable-read, read-only transaction.
Contributor
Author
|
Attempt 1's one red, Backend integration → |
The audit-chain check read the org's rows, verified the chain, then read the chain head in a second autocommit statement. An audit write commits its row and the head together, so a job of another lane (or this lane's own lockout bell) landing between the two reads left the head one row ahead of the tail just read: `chain=true, head=false` on an intact chain (Backend integration, PR #4025 attempt 1). Both reads now share one repeatable-read, read-only transaction.
larryro
force-pushed
the
fix/gemini-cli-resume-tool-turns
branch
from
October 1, 2026 03:17
f6d36ec to
386b7ad
Compare
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.
Why
A project-agent task on Gemini CLI that ran a tool could never be continued: every later kick (a comment, an automatic retry, a mid-run comment's restart, an answered ask on an automation node) handed the exec
--resume <id>, and the first model call of the resumed conversation was refused — DeepSeek-style upstreams withMessages with role 'tool' must be a response to a preceding message with 'tool_calls', Google withnumber of function response parts…. The retries then resumed into the same wall until the budget was spent, because the gemini parser never stampedapiErrorStatus, so the kick's "400 → start fresh" rule never fired.Root cause is in the CLI, not the gateway: on
--resume, Gemini CLI 0.59.0 (and main) replays every tool result twice — once rebuilt from the recordedtoolCalls[].result, once from the user record it also writes for the same response (convertSessionToClientHistory). google-gemini/gemini-cli#29365, fix PRs #29400/#29490 open, nothing released. Reproduced with the pinned CLI against Bifrost 2.2.4 and a logging mock upstream: the live turn sends onetoolmessage per call, the resumed one sends two with the sametool_call_id. Qwen Code 0.23.3 resumes cleanly under the same rig.What changes
capabilities.resume; the schema holds it coherent with the argv resume slot (resume ⇔ slot). The eight other harnesses declaretrue; gemini declaresfalse, drops its slot, and says why and when to flip it back.harnessResumesConversations) and take their existing fresh path: the task kick (resolveTaskKickResume, box swept after a settled predecessor, kept with the inspect note after a failed one), the automation retry (workflowAgentRetryResume), the answered-ask resume, and the comment restart in the task host. The exec builder refuses a handle on such a harness, so no planner can bypass the flag.apiErrorStatuson the turn end: thecodeof a relayed[API Error: {"error":{"code":N…}}]body, 429 from the rate-limit sentence the CLI appends (the SDK's retries leave no body). The run's reason becomes the provider's sentence with the status instead of the JSON dump.TASK-F59, anautomation.mdrow, a contract debt ledger entry, and theGEMINI_CLI_VERSIONnote on what a pin bump needs first.Verified
task_kick_resume,agent_retry,registry(schema coherence),exec-builder(refusal),golden-exec(gemini goldens re-frozen without--resume),gemini-stream(fixtures captured from the pinned 0.59.0: 400 body, 429 prose; 500 inline),agent_run_host.connector_caller(a comment on a Gemini run restarts without the handle and on the rebuilt brief; Codex control still resumes),load_system_config(every shipped harness but gemini resumes). The server project around the changed seams: 393 files green.@tale/shared+@tale/platformtypecheck, oxlint, oxfmt,lint:manual,lint:links, docs tests.Not verified here
TASK-F59).tests/guards/frontend-entry-discovery.guard.test.tscould not run in the worktree (noknipunder its root) — unrelated to this change.