Skip to content

gemini-cli resume: session/load succeeds but context is not restored #96

Description

@omridevk

Summary

geminiCli declares capabilities.resume: true, so on resume conciv sends only the latest user message — correct behaviour, since the harness is meant to hold the conversation. gemini-cli accepts the session load and keeps the same session ID, but never feeds the prior turns to the model.

Net effect: every gemini turn after the first loses all context in real conciv usage. packages/core/test/gemini-tanstack.it.test.ts has been catching this; it is skipped in CI (!process.env.CI) so it only shows up locally with the real CLI installed.

Evidence

Check Result
gemini initializeagentCapabilities {"loadSession":true, ...} — so session/load is attempted, not skipped
Session ID across both turns identical (c2510aba-…) — the load succeeded, no silent fallback to newSession
gemini's own session file on disk contains PLUM42 — gemini did persist the history
Model reply on turn 2 "I do not have a token in my current context. This is the first message in our conversation."
Same helper, claude harness (claude-tanstack.it.test.ts) passes in 9.8s

So the conciv side is behaving correctly end to end:

  1. acpChatConfig passes modelOptions: {sessionId} (packages/harness/src/_shared/acp.ts)
  2. @tanstack/ai-acp calls connection.loadSession({sessionId, cwd, mcpServers}) when the agent advertises loadSession: true (src/session/acp-client.ts)
  3. gemini returns success and the ID is reused
  4. gemini does not restore the transcript into model context

Note that acp-client.ts swallows a failed load with a bare catch {} and falls back to a fresh session — but that is not what happens here; the matching session IDs prove the load succeeded.

Also worth noting: conciv spawns a new gemini --acp process per turn, so session/load must rehydrate from disk. The history is on disk, and turn two still started a new chat file.

Reproduce

Requires the real gemini CLI installed and authenticated:

cd packages/core && npx vitest run test/gemini-tanstack.it.test.ts
AssertionError: expected 'I do not have a record of a token in …' to contain 'PLUM42'

Unrelated gotcha found while diagnosing

If ~/.gemini/settings.json has security.auth.selectedType: "oauth-personal", every call fails with "This client is no longer supported for Gemini Code Assist for individuals" — Google discontinued that tier. Switching to "gemini-api-key" (with GEMINI_API_KEY set) gets past auth. This is separate from the resume bug above.

Options

  1. Set resume: false for gemini so conciv replays the transcript preamble each turn. Fixes user-facing context loss; costs tokens per turn, and assertTurnAndResume would need a transcript-based variant for this harness.
  2. File upstream with gemini-cli and wait.
  3. Investigate whether session/load needs additional params, or whether restoration works under a different auth mode or CLI flag.

Test is marked it.todo until this is resolved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-triagedInvestigated by the nightly issue trackeragent:already-resolvedNightly agent found this already fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions