Skip to content

Gemini 2.5 Pro: textSignature bloat + think tags + mixed text/tool causes session failures #48709

Closed as not planned

Description

@jarvis-playrockets

Summary

When using google/gemini-2.5-pro via the google-generative-ai API, three issues combine to cause rapid session context bloat, aborted runs, and silent Telegram delivery failures.

Issue 1: textSignature Session Bloat (High Severity)

Gemini assistant responses include a textSignature field containing ~15KB of base64 data per response turn. OpenClaw stores these signatures verbatim in the session JSONL history. After 10+ turns, the accumulated signatures alone consume 150KB+, causing:

  1. Context window bloat (observed: 416K tokens in one session)
  2. Gemini API timeouts on re-submission of full context
  3. Compaction failures (session too large to compact)
  4. Silent message delivery failures (run aborts before reply is sent to Telegram)

Expected: textSignature should either not be stored in session history, be stored separately, or not be re-sent to the model on subsequent turns.

Issue 2: Embedded <think> Tags in Text

Gemini 2.5 Pro embeds <think>...</think> tags directly in the text content field (not as separate thinking type blocks). If OpenClaw treats <think>-prefixed text as internal/thinking content, the reply is suppressed and never delivered to Telegram.

Expected: OpenClaw should either strip <think> tags from the delivered text, or not suppress messages that contain them.

Issue 3: Mixed Text + ToolCall in Same Response

Gemini 2.5 Pro consistently emits text + toolCall in the same response turn. OpenClaw processes the toolCall, gets the result, then emits an empty content: [] as the final stop. The original text from the first part of the response is never delivered to the user.

Expected: Text content from a mixed text+toolCall response should be delivered to the user, not silently dropped.

Reproduction

  1. Configure an agent with google/gemini-2.5-pro as primary model
  2. Send 5-10 interactive messages via Telegram group topic
  3. Check session JSONL — each assistant message contains textSignature (~15KB base64)
  4. After ~10 exchanges, session reaches 150K+ tokens
  5. Subsequent runs timeout or abort; replies never reach Telegram

Workaround

Switched affected agent to Claude Sonnet 4.6, which does not exhibit these behaviors.

Environment

  • OpenClaw 2026.3.13 (61d171a)
  • macOS Darwin 24.6.0 (arm64)
  • Gemini API key auth (google-generative-ai provider)
  • Telegram channel with group topics

Activity

  1. Ryce commented on Mar 17, 2026

    @Ryce
  2. openclaw-barnacle commented on Apr 29, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  3. added
    stale
    on Apr 29, 2026
  4. clawsweeper commented on Apr 29, 2026

    @clawsweeper
    Contributor

    Thanks for the report. I checked current main, but this shell is missing enough reproduction detail to verify a current bug.

    Close this older, partially addressed report: native Gemini reasoning is fixed in shipped code, while the remaining signature-related failures lack a current-version reproduction.

    Review details

    Best possible solution:

    Preserve replay metadata and investigate any remaining failure using a current-release trace that separates stored bytes, provider token usage, compaction, and delivered output.

    Do we have a high-confidence way to reproduce the issue?

    No high-confidence current reproduction is established: the supplied steps target 2026.3.13, and no later human comment provides current-release logs or a reduced failing transcript; no runtime tests were executed.

    Is this the best way to solve the issue?

    Blanket signature removal is not justified: the provider retains signatures as replay metadata, compaction excludes them from assistant token estimates and summaries, and the separate tagged-reasoning conflict already has a shipped repair.

    Security review:

    Security review: The report establishes reliability concerns without a security-boundary violation.

    AGENTS.md: found and applied where relevant.

    What I checked:

    Codex review notes: model internal, reasoning medium; reviewed against 3dc6e49c07fb.

  5. clawsweeper commented on Apr 29, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

    Keep open. Current main still has the central Gemini signature-bloat path: Google visible text blocks can persist textSignature, same-provider replay sends it back as thoughtSignature, and the replay sanitizer only targets thought_signature / thoughtSignature. Mixed text before tool execution has partial protection now via block flushing, but Gemini remains on tagged reasoning with strict final-tag suppression, so meaningful parts of the report are still unresolved rather than stale or implemented.

    Required change / next step:

    Needs owner decision on Google signature retention/replay and Gemini tagged-versus-native reasoning before an automated fix changes provider replay semantics.

    Review details

    Best possible solution:

    Handle this at the Google provider and replay boundary: preserve required Gemini function-call/native-thinking signatures, bound or avoid replaying stale visible-text signatures, and align Gemini reasoning delivery with native thinking so malformed or final-less tagged output cannot silently suppress user replies.

    Acceptance criteria:

    • pnpm test extensions/google/transport-stream.test.ts
    • pnpm test src/agents/pi-embedded-runner.sanitize-session-history.policy.test.ts src/agents/pi-embedded-runner.sanitize-session-history.test.ts
    • pnpm test src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.filters-final-suppresses-output-without-start-tag.test.ts src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.calls-onblockreplyflush-before-tool-execution-start-preserve.test.ts src/agents/pi-embedded-utils.test.ts
    • pnpm test src/agents/pi-embedded-runner/run/payloads.test.ts

    What I checked:

    • Current main stores Gemini text-part signatures: Google streamed text parts retain part.thoughtSignature on visible text blocks as activeBlock.textSignature, so opaque Gemini signatures can enter assistant session history on ordinary text. (extensions/google/transport-stream.ts:706, e46dccb35374)
    • Current main replays stored textSignature: When rebuilding same-provider/same-model Google history, assistant text blocks with block.textSignature are emitted as Gemini thoughtSignature, so stored visible-text signatures are replayed into subsequent requests. (extensions/google/transport-stream.ts:350, e46dccb35374)
    • Generic signature sanitizer misses textSignature: The sanitizer type and deletion logic only cover thought_signature and optional camel-case thoughtSignature; it does not remove OpenClaw's stored assistant textSignature field before Google replay. (src/agents/pi-embedded-helpers/bootstrap.ts:11, e46dccb35374)
    • Google replay policy only configures thought-signature cleanup: The Google/Gemini replay policy enables base64-only thought-signature sanitization, but it has no visible text-signature retention, size-bound, or externalization rule. (src/plugins/provider-replay-helpers.ts:155, e46dccb35374)
    • Gemini still resolves to tagged reasoning: The provider-family hook for google-gemini still calls resolveTaggedReasoningOutputMode(), and checked-in tests assert Google provider reasoning mode is tagged. (src/plugin-sdk/provider-model-shared.ts:200, e46dccb35374)
    • Strict final-tag suppression remains asserted: When enforceFinalTag is true, streaming delivery returns empty output until a <final> start tag has appeared, and the checked-in test still asserts no agent payload for final-less assistant text. (src/agents/pi-embedded-subscribe.ts:669, e46dccb35374)

    Likely related people:

    • vincentkoc: The prior ClawSweeper comment in the issue discussion reports earlier current-main blame for the Google transport replay/storage lines, Google replay policy, provider-family hook, and strict final-tag sanitizer to Vincent Koc, making him a plausible routing candidate for the provider replay policy portion. (role: likely provider replay owner; confidence: medium; commits: ad2516b1c876; files: extensions/google/transport-stream.ts, src/plugins/provider-replay-helpers.ts, src/plugin-sdk/provider-model-shared.ts)
    • steipete: Available local blame for the current inspected files resolves to Peter Steinberger on the current source snapshot, and the latest release commit still contains the observed behavior, making him a practical maintainer routing candidate for the cross-provider delivery and release-policy decision. (role: recent maintainer / adjacent owner; confidence: low; commits: 34d11d57579d, be8c24633aaa; files: extensions/google/transport-stream.ts, src/agents/pi-embedded-subscribe.ts, src/agents/pi-embedded-utils.ts)

    Remaining risk / open question:

    Codex review notes: model gpt-5.5, reasoning high; reviewed against e46dccb35374.

  6. removed
    stale
    on Apr 30, 2026
  7. added
    P1
    impact:message-loss
    impact:session-state
    clawsweeper:source-repro
    clawsweeper:no-new-fix-pr
    clawsweeper:fix-shape-clear
    clawsweeper:needs-maintainer-review
    clawsweeper:needs-product-decision
    issue-rating: 🦞 diamond lobster
    on May 17, 2026
  8. 64 remaining items

  9. added
    impact:message-loss
    issue-rating: 🦪 silver shellfish
    and removed
    clawsweeper:no-new-fix-pr
    clawsweeper:needs-maintainer-review
    clawsweeper:needs-product-decision
    clawsweeper:source-repro
    issue-rating: 🦞 diamond lobster
    on Sep 22, 2026
  10. openclaw-barnacle commented on Oct 7, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  11. added
    stale
    on Oct 7, 2026
  12. added
    clawsweeper:intake:bug
    on Oct 16, 2026
  13. removed
    stale
    on Oct 16, 2026
  14. removed
    clawsweeper:intake:bug
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2impact:message-lossimpact:session-stateissue-rating: 🦪 silver shellfish

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions