Skip to content

providers/gemini + loop: next-speaker check and stall recovery for Gemini #343

Description

@erain

Goal

P2.7 of docs/coding-harness-roadmap.md: Gemini's classic stall — narrating "Next, I will…" and stopping without a tool call — plus residual reliability gaps not covered by v1.8.0's thoughtSignature work.

Scope

  • Next-speaker heuristic when a turn ends with no pending tool calls: fast paths first (last message functionResponse → continue; empty model turn → continue), optional cheap-model JSON check; on "model", auto-send "Please continue." bounded by max-turns.
  • Sanitize lone UTF-16 surrogates in outbound text (Gemini API crash).
  • Over-escape repair for tool args lands with tools/fs: edit_file repair ladder — flexible matching, instructive errors, escape repair #338; this issue wires any remaining provider-side cases.

Out of scope

Flash model fallback chains; quota-tier policies.

Implementation notes

Sources: Gemini CLI nextSpeakerChecker.ts (3-rule prompt + fast paths), geminiChat.ts. The auto-continue belongs in the loop with a provider-capability flag so it can also serve open-weight models that exhibit the same stall.

Docs update required

CHANGELOG; provider-guide note.

Verification commands

go test ./providers/gemini/ ./loop/ && go build ./... ; GEMINI_API_KEY=... go test ./providers/gemini -run Live

Acceptance criteria

Fake-provider test: a no-tool "I will now…" turn triggers exactly one "Please continue." and the loop completes; surrogate sanitization unit-tested; live smoke unaffected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions