Skip to content

fix(talk): retain chat-backed consult prompts in model history - #179237

Merged
obviyus merged 1 commit into
openclaw:mainfrom
khensthoth:fix/talk-consult-prompt-cache
Nov 25, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
khensthoth:fix/talk-consult-prompt-cache

Conversation

@khensthoth

@khensthoth khensthoth commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Root cause: src/gateway/talk/handlers/client.ts:475 (origin/main b402f04, unchanged since merge base 2c4413a) records the generated consult prompt of talk.client.toolCall with transcript { display: false, excludeFromContext: true }. The prompt is sent to the model in its own turn, then dropped from every later request, so each later consult/typed turn rewrites history at that prompt and the provider cache misses from there. #199538 (81ca4f4) already removed the same flag for native consults (client-agent-runtime.ts); the PR drops it on the chat-backed route and keeps display:false.

Closes #179236

What Problem This Solves

#199538 made native Talk consultations retain their hidden generated consult input in model history, so later requests keep the already-dispatched prefix. The chat-backed consult route (talk.client.toolCall in src/gateway/talk/handlers/client.ts, used by browser providers such as Google Live and by app relay sessions) still records the same hidden prompt with excludeFromContext: true. Every later consult in that session therefore rewrites history at the earlier prompt and misses the prompt cache from that point on.

User Impact

Later voice questions on browser/relay Talk keep the cached conversation prefix, the same as native Talk after #199538. The generated prompt stays hidden from chat, exactly as before.

Why This Change Was Made

This applies the contract #199538 already adopted for native consults to the remaining route: hide from chat, retain in model history.

Existing stored records are not rewritten.

History

This PR was originally a larger change (retention plus speech ordering and preview filtering) waiting on the retention decision. #199538 settled that decision for native consults, so the branch is now rebuilt on current main with only the remaining route. The earlier version is kept on khensthoth:fix/talk-consult-prompt-cache-v1-backup. Live observations from the original version (22 Oct) showed 96–98% cached input on follow-up Gemini Talk consults with this route fixed.

Evidence

Upstream CI on this head is waiting for workflow approval. Run on d7bb6636 in a clean node:24-bookworm container (Linux, Node 24.22, CI=true, prompt-cache assertion on):

  • oxfmt --check and oxlint on the changed files: clean.
  • index.test.ts, client-native-actions.test.ts, client-native-control.test.ts: 113/113 passed.
  • relay-consult-adoption.regression.test.ts: 9/9 passed.
  • server.talk-consult-history.test.ts: 20/22. The two failures (keeps host-authenticated node approval cancellation, public callback false/true) fail identically on unmodified main at 2c4413a6 in the same container (SYSTEM_RUN_DENIED: approval cannot safely bind this interpreter/runtime command), so they come from that environment, not this change. In one earlier full-file run isolates registered Talk replay across authenticated callers hit its 10 s agent.wait timeout; it passed on rerun, alone and in the full file, with the assertion on and off.

🤖 Generated with Claude Code

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 21, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR retains hidden Talk consult inputs in model history and preserves spoken clarifications without shifting previously submitted conversation prefixes.

Example: During a calendar consult, the user adds “Also tomorrow; the phrase is violet compass.”

  • Before: The next consult omits the previous generated input and can insert the clarification ahead of its answer, changing the cached prefix.
  • After: The previous generated input replays once, and the clarification follows that consult’s answer while generated input stays hidden from chat and voice background.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation has no actionable findings and supplied runtime and upgrade evidence clears the previous proof gaps; readiness remains capped by the unresolved retention-policy decision.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The inspected source-built Gateway proof exercises public Talk RPCs, the actual agent loop, and an external HTTP provider endpoint with matching changed production blobs: pending reconnect hides generated input, the prior consult replays once, and interleaved speech follows its answer. Latest-stable upgrade receipts preserve mixed history and legacy exclusions. Earlier live compiled-port observations provide supplementary evidence; inspected screenshots concern the earlier retention repair. Whole-request equality, guaranteed cache savings, and microphone behavior are not claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Repeated voice questions can rebuild previously submitted model history, increasing cache writes and disturbing where genuine spoken clarifications enter later context.
Reason: The cache-stability benefit is concrete, but the repair reverses an explicit owner-approved exclusion policy rather than merely correcting an accidental implementation detail.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this PR open: it addresses a current Talk prompt-prefix failure, but reversing the approved consult-retention contract requires an owner decision.

Priority: P2
Reviewed head: bbb9caa27a628cbea73cdb1f3429d1fae91b9c1d
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should newly tagged generated Talk consult inputs remain eligible for later model replay, replacing the exclusion contract approved in the earlier retention repair?
  • Recommendation: Approve scoped consult retention: Accept retained generated inputs for new tagged consults, keeping chat and voice background clean and leaving existing excluded records unchanged.
  • Why: The author explains the cache-prefix benefit and supplies supporting proof, but steipete’s explicit earlier decision required exclusion and no subsequent owner approval is recorded.

Before merge

  • Await maintainer action - steipete must approve or reject retaining newly tagged generated consult inputs in later model context.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

Talk producers record generated consult inputs and genuine speech through the session owners; the embedded runner projects those records into model requests, while Gateway previews supply background for voice connections.

flowchart LR
  A[Talk clients] --> B[Consult producers]
  B --> C[Session transcript owner]
  C --> D[Embedded replay boundary]
  D --> E[Model provider]
  C --> F[Gateway history previews]
  F --> A
Loading

Technical review

Best possible solution:

Approve scoped retention of newly tagged consult inputs while preserving hidden presentation, genuine speech, legacy exclusions, and current authorization gates.

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

Current-main producer and projection code establish the missing-prefix mechanism, supported by the contributor’s inspected failure-first receipts; this read-only review did not execute target code.

Is this the best way to solve the issue?

The implementation repairs both consult producers through existing transcript and replay owners, and each production hunk serves retention, ordering, or hidden presentation; its suitability depends on approving the changed retention policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7a1d72c44102.

Provenance checked

  • Generated consult exclusion and hidden presentation changes intended behavior with a stated reason (213975d: Prevent generated questions, context, and speaking instructions from replaying as later user input while preserving lossless archives.)
  • Native consult recorder ownership keeps the original intent (31c35d5: Move voice bookkeeping through existing worker and execution owners while preserving target identity, accepted-write custody, and caller authority; later session-controller refactoring retained the exclusion policy.)
  • Finalized speech during consult preparation changes intended behavior with a stated reason (3806038: Keep finalized speech durable while supplying it through the merged current prompt; this PR explains why retained consult replay instead requires separate speech input.)
  • Provider-boundary normalization keeps the original intent (cd9913f: Preserve typed runtime-context semantics and stable provider replay instead of inferring authority from delimiter text; the added speech ordering runs before the retained normalization pipeline.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +100, Tests +393, Docs +2. Total +495 across 13 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 7 112 12 +100
Tests 5 418 25 +393
Docs 1 7 5 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 537 42 +495

Review metrics

Metric Value Why it matters
Production versus regression tests Production +112/-12; tests +418/-25 Growth covers shared replay ordering, distinct producer boundaries, preparation recovery, and pending reconnect behavior without adding a schema or configuration option.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repeated Talk consults can lose reusable conversation prefixes and increase inference cost, with limited blast radius and no demonstrated core outage.
  • merge-risk: 🚨 session-state: The patch deliberately changes later model-history eligibility and speech ordering; passing checks cannot approve the change to the existing retention contract.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-21T08:41:09.182Z sha f8dd3e4 :: needs real behavior proof before merge. :: [P2] Restrict speech omission to the native consult path being repaired | [P2] Hide generated consult inputs before their first response | [P2] Update the existing direct-consult history regression | [P3] Document the changed native consult replay behavior
  • reviewed 2026-10-21T17:29:38.097Z sha 8eb64ea :: needs real behavior proof before merge. :: [P2] Restrict speech omission to the consult path being repaired | [P2] Preserve spoken clarifications absent from the consult input | [P2] Hide generated consult inputs before their first response | [P3] Update the documented consult replay contract
  • reviewed 2026-10-22T12:54:30.926Z sha 152671f :: needs real behavior proof before merge. :: none

Reviewed October 23, 2026, 6:13 AM ET / 10:13 UTC (Revision 4).

@khensthoth

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 21, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Added redacted runtime evidence and updated the PR description for 152671f3.

The report covers:

  • Real OpenAI/GPT native consults and Google/Gemini client-tool-call consults with Anthropic Claude.
  • Follow-up first-request cached-input ratios of 96.3%, 97.5%, and 97.8%, with per-call token counts in the linked JSON extracts.
  • A distinct Gemini clarification preserved across consults without repetition in the next generated prompt.
  • Spoken “silver mango” retained during an ordinary typed-chat run and present in the later backing-agent answer.
  • Deterministic old-local-helper versus installed-v2 checks for pending prompt suppression, consult speech retention, and ordinary-run ordering.

The deployment was a compiled-code port onto an existing patched 2026.10.10-beta.2 image, not a full source build of this head or latest-stable upgrade. The manual reconnect missed the pre-first-response window and is explicitly inconclusive. No exact provider-wire prefix or exact upstream-base failing run is claimed.

Pending reconnect/producer proof, pre-upgrade latest-stable compatibility, and the maintainer retention decision remain open. The report separates these gaps from the positive results. Evidence is archived on a separate fork branch; the PR head remains 152671f3.

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 22, 2026
@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Nov 9, 2026
roboclaw-bot added a commit that referenced this pull request Nov 13, 2026
Retire only the reused session's diagnostic baseline after test-state work
and cleanup settle. Keep transport cleanup with its existing owners.

Wait for the post-cancel delegation result before asserting its content so
failure replies expose the unchanged success assertion without hanging.
The named file still has four post-cancel history failures overlapping
#179237; all five original cross-fixture readiness failures are gone.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 14, 2026
Retire only the reused session's diagnostic baseline after test-state work
and cleanup settle. Keep transport cleanup with its existing owners.

Wait for the post-cancel delegation result before asserting its content so
failure replies expose the unchanged success assertion without hanging.
The named file still has four post-cancel history failures overlapping
openclaw#179237; all five original cross-fixture readiness failures are gone.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
@khensthoth

Copy link
Copy Markdown
Contributor Author

Hi @steipete, a short update in case it helps with the decision.

Since #198100 turned on the prompt-cache assertion in tests (13 Nov), the four cancellation variants in client-native-control.test.ts have failed on every hourly main run: the second Talk consult rewrites history at the first consult's excluded prompt. The root cause is written up in #198523, and f52d925 notes that the remaining failures overlap this PR.

This PR removes that exclusion, so it should turn those tests green. It still merges cleanly with main. The only open item is your call on the retention question above. Happy to adjust anything you'd like changed. Thanks for your time!

openclaw#199538 stopped excluding the generated consult input on native Talk
consultations so later requests keep the already-dispatched prefix. The
chat-backed route (client tool-call consults, used by browser providers
such as Google Live and by app relay sessions) still records the same
hidden prompt with excludeFromContext, so every later consult in that
session rewrites history at the earlier prompt and misses the prompt
cache. Apply the same contract there: hide from chat, keep in model
history. Update the openclaw#133855 regression test and the docs to match.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@khensthoth
khensthoth force-pushed the fix/talk-consult-prompt-cache branch from bbb9caa to d7bb663 Compare November 15, 2026 15:24
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed agents Agent runtime and tooling size: L labels Nov 15, 2026
@khensthoth khensthoth changed the title fix(talk): voice consults rewrite the cached prompt on every question fix(talk): retain chat-backed consult prompts in model history Nov 15, 2026
@khensthoth

Copy link
Copy Markdown
Contributor Author

Thanks @vincentkoc for #199538, which settled the retention question for native consults. I've rebuilt this PR on current main so it now only applies the same change to the remaining chat-backed route (talk.client.toolCall, used by browser providers like Google Live and app relay sessions): 4 files, +11/−11. The description is updated. Happy to adjust anything.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale after 7 days without qualifying human activity.
Without new human activity, Barnacle may close it as not planned 7 days after this message was posted. This is administrative inactivity cleanup, not a claim that the problem is fixed.
A human update restarts the inactivity clock; a new PR head also restarts it. A maintainer can add no-stale for a durable hold, or bad-barnacle to suppress Barnacle. Remove the hold when work can resume.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Nov 23, 2026
@khensthoth

Copy link
Copy Markdown
Contributor Author

@vincentkoc follow-up to #199538: this is the same contract on the remaining chat-backed route (talk.client.toolCall, browser providers and app relay), which still sets excludeFromContext: true on current main. One-line change plus tests, and it merges cleanly. CI just needs approval for the fork run. If it's easier, feel free to apply it in your own commit and close this, since I only need the fix to ship. Thanks!

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Nov 24, 2026
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Gateway proof on the exact head d7bb6636d0, run against base 2c4413a6ab (the merge base; client.ts:475 is the same on current main).

Setup: Gateway built from source (pnpm build) in a secretless node:24.22.1 container with isolated state. The only model was a local OpenAI-Responses stand-in that saves every request body. One operator connection sent the RPCs Control UI's browser Talk provider sends: chat.send TYPED_1, then talk.client.toolCall openclaw_agent_consult 3 times (each awaited with agent.wait), then chat.send TYPED_2. Each request was compared byte-for-byte with the one before it.

browser route: does each request extend the previous one?
                 base (2 runs)                                    PR head (2 runs)
consult 1        extends                                          extends
consult 2        DIVERGES at byte 168845, CONSULT_Q1 dropped      EXTENDS (176775/180023)
consult 3        DIVERGES at byte 176463, CONSULT_Q2 dropped      EXTENDS (180021/183269)
typed TYPED_2    DIVERGES at byte 179262, CONSULT_Q3 dropped      EXTENDS (183267/191161)

base Gateway log: [prompt-cache] message 3 (user) differs from the previous request; history must be
  append-only; changed fields: content, envelope.other["excludeFromContext"], ...
PR head: no prompt-cache warning for this session.
chat.history (all runs): user TYPED_1, assistant ANSWER-1, user TYPED_2, assistant ANSWER-5
  -> consult prompts stay hidden, typed turns unchanged

Controls, run in the same containers:

  • client-native-control.test.ts (native consults, prompt-cache assertion on): 14/14 on base and on the head.
  • PR regression server.talk-consult-history.test.ts -t "read-only Talk operator consult scaffolding": fails on base with the PR's test ("expected ... to not have property excludeFromContext"); passes on the head.

Gateway-relay route (talk.client.toolCall with relaySessionId, as Control UI's relay transport sends it, with caller speech just before each consult): the head keeps every consult prompt (base drops each one). Requests still split near the start of the conversation, though. That split comes from a separate cause that is the same on base: unanswered speech is folded into the consult turn, then replayed later as its own record. This PR doesn't touch that, and it isn't needed here.

Review note: the local review found no problems with the change and asked who owns the retention decision. #199538 already made that decision for these same generated records ("hide from chat, keep in model history"). This PR applies it to the last route that still drops them. Stored rows are not rewritten.

@obviyus
obviyus merged commit 4c45bb4 into openclaw:main Nov 25, 2026
143 of 146 checks passed
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Merged in 4c45bb4. Thanks @khensthoth for the fix and the live measurements. Chat-backed Talk consultations (browser providers and app relay) now keep their hidden consult prompt in model history, the same rule native Talk follows since #199538, so later voice questions and typed turns extend the cached prefix instead of rewriting history at the earlier consult. The prompts stay hidden in chat, and raw archives and existing records are unchanged.

tideclaw-bot pushed a commit that referenced this pull request Nov 26, 2026
Root cause: src/gateway/talk/handlers/client.ts:475 (origin/main b402f04, unchanged since merge base 2c4413a) records the generated consult prompt of talk.client.toolCall with transcript { display: false, excludeFromContext: true }. The prompt is sent to the model in its own turn, then dropped from every later request, so each later consult/typed turn rewrites history at that prompt and the provider cache misses from there. #199538 (81ca4f4) already removed the same flag for native consults (client-agent-runtime.ts); the PR drops it on the chat-backed route and keeps display:false.

Closes #179236

## What Problem This Solves

#199538 made native Talk consultations retain their hidden generated consult input in model history, so later requests keep the already-dispatched prefix. The chat-backed consult route (`talk.client.toolCall` in `src/gateway/talk/handlers/client.ts`, used by browser providers such as Google Live and by app relay sessions) still records the same hidden prompt with `excludeFromContext: true`. Every later consult in that session therefore rewrites history at the earlier prompt and misses the prompt cache from that point on.

## User Impact

Later voice questions on browser/relay Talk keep the cached conversation prefix, the same as native Talk after #199538. The generated prompt stays hidden from chat, exactly as before.

## Why This Change Was Made

This applies the contract #199538 already adopted for native consults to the remaining route: hide from chat, retain in model history.

- `client.ts`: drop `excludeFromContext` from the chat-backed consult transcript options.
- `index.test.ts`: expect the new transcript options.
- `server.talk-consult-history.test.ts` (the #133855 regression test): the generated input stays out of chat history and Markdown, carries no exclusion flag, and appears exactly once in reopened model context, mirroring the assertion #199538 added for the direct-call case.
- Docs: one sentence now covers both native and chat-backed consults.

Existing stored records are not rewritten.

## History

This PR was originally a larger change (retention plus speech ordering and preview filtering) waiting on the retention decision. #199538 settled that decision for native consults, so the branch is now rebuilt on current `main` with only the remaining route. The earlier version is kept on `khensthoth:fix/talk-consult-prompt-cache-v1-backup`. Live observations from the original version (22 Oct) showed 96–98% cached input on follow-up Gemini Talk consults with this route fixed.

## Evidence

Upstream CI on this head is waiting for workflow approval. Run on `d7bb6636` in a clean `node:24-bookworm` container (Linux, Node 24.22, `CI=true`, prompt-cache assertion on):

- `oxfmt --check` and `oxlint` on the changed files: clean.
- `index.test.ts`, `client-native-actions.test.ts`, `client-native-control.test.ts`: 113/113 passed.
- `relay-consult-adoption.regression.test.ts`: 9/9 passed.
- `server.talk-consult-history.test.ts`: 20/22. The two failures (`keeps host-authenticated node approval cancellation`, public callback false/true) fail identically on unmodified `main` at `2c4413a6` in the same container (`SYSTEM_RUN_DENIED: approval cannot safely bind this interpreter/runtime command`), so they come from that environment, not this change. In one earlier full-file run `isolates registered Talk replay across authenticated callers` hit its 10 s `agent.wait` timeout; it passed on rerun, alone and in the full file, with the assertion on and off.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Keith <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 4c45bb4)
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…law#179237)

Root cause: src/gateway/talk/handlers/client.ts:475 (origin/main 01b8aea, unchanged since merge base 5409be4) records the generated consult prompt of talk.client.toolCall with transcript { display: false, excludeFromContext: true }. The prompt is sent to the model in its own turn, then dropped from every later request, so each later consult/typed turn rewrites history at that prompt and the provider cache misses from there. openclaw#199538 (2768b27) already removed the same flag for native consults (client-agent-runtime.ts); the PR drops it on the chat-backed route and keeps display:false.

Closes openclaw#179236

## What Problem This Solves

openclaw#199538 made native Talk consultations retain their hidden generated consult input in model history, so later requests keep the already-dispatched prefix. The chat-backed consult route (`talk.client.toolCall` in `src/gateway/talk/handlers/client.ts`, used by browser providers such as Google Live and by app relay sessions) still records the same hidden prompt with `excludeFromContext: true`. Every later consult in that session therefore rewrites history at the earlier prompt and misses the prompt cache from that point on.

## User Impact

Later voice questions on browser/relay Talk keep the cached conversation prefix, the same as native Talk after openclaw#199538. The generated prompt stays hidden from chat, exactly as before.

## Why This Change Was Made

This applies the contract openclaw#199538 already adopted for native consults to the remaining route: hide from chat, retain in model history.

- `client.ts`: drop `excludeFromContext` from the chat-backed consult transcript options.
- `index.test.ts`: expect the new transcript options.
- `server.talk-consult-history.test.ts` (the openclaw#133855 regression test): the generated input stays out of chat history and Markdown, carries no exclusion flag, and appears exactly once in reopened model context, mirroring the assertion openclaw#199538 added for the direct-call case.
- Docs: one sentence now covers both native and chat-backed consults.

Existing stored records are not rewritten.

## History

This PR was originally a larger change (retention plus speech ordering and preview filtering) waiting on the retention decision. openclaw#199538 settled that decision for native consults, so the branch is now rebuilt on current `main` with only the remaining route. The earlier version is kept on `khensthoth:fix/talk-consult-prompt-cache-v1-backup`. Live observations from the original version (22 Oct) showed 96–98% cached input on follow-up Gemini Talk consults with this route fixed.

## Evidence

Upstream CI on this head is waiting for workflow approval. Run on `d7bb6636` in a clean `node:24-bookworm` container (Linux, Node 24.22, `CI=true`, prompt-cache assertion on):

- `oxfmt --check` and `oxlint` on the changed files: clean.
- `index.test.ts`, `client-native-actions.test.ts`, `client-native-control.test.ts`: 113/113 passed.
- `relay-consult-adoption.regression.test.ts`: 9/9 passed.
- `server.talk-consult-history.test.ts`: 20/22. The two failures (`keeps host-authenticated node approval cancellation`, public callback false/true) fail identically on unmodified `main` at `5409be48` in the same container (`SYSTEM_RUN_DENIED: approval cannot safely bind this interpreter/runtime command`), so they come from that environment, not this change. In one earlier full-file run `isolates registered Talk replay across authenticated callers` hit its 10 s `agent.wait` timeout; it passed on rerun, alone and in the full file, with the assertion on and off.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Keith <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
@khensthoth

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus for the thorough proof and the merge, and @vincentkoc for #199538. Much appreciated!

tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
Root cause: src/gateway/talk/handlers/client.ts:475 (origin/main b402f04, unchanged since merge base 2c4413a) records the generated consult prompt of talk.client.toolCall with transcript { display: false, excludeFromContext: true }. The prompt is sent to the model in its own turn, then dropped from every later request, so each later consult/typed turn rewrites history at that prompt and the provider cache misses from there. #199538 (81ca4f4) already removed the same flag for native consults (client-agent-runtime.ts); the PR drops it on the chat-backed route and keeps display:false.

Closes #179236

## What Problem This Solves

#199538 made native Talk consultations retain their hidden generated consult input in model history, so later requests keep the already-dispatched prefix. The chat-backed consult route (`talk.client.toolCall` in `src/gateway/talk/handlers/client.ts`, used by browser providers such as Google Live and by app relay sessions) still records the same hidden prompt with `excludeFromContext: true`. Every later consult in that session therefore rewrites history at the earlier prompt and misses the prompt cache from that point on.

## User Impact

Later voice questions on browser/relay Talk keep the cached conversation prefix, the same as native Talk after #199538. The generated prompt stays hidden from chat, exactly as before.

## Why This Change Was Made

This applies the contract #199538 already adopted for native consults to the remaining route: hide from chat, retain in model history.

- `client.ts`: drop `excludeFromContext` from the chat-backed consult transcript options.
- `index.test.ts`: expect the new transcript options.
- `server.talk-consult-history.test.ts` (the #133855 regression test): the generated input stays out of chat history and Markdown, carries no exclusion flag, and appears exactly once in reopened model context, mirroring the assertion #199538 added for the direct-call case.
- Docs: one sentence now covers both native and chat-backed consults.

Existing stored records are not rewritten.

## History

This PR was originally a larger change (retention plus speech ordering and preview filtering) waiting on the retention decision. #199538 settled that decision for native consults, so the branch is now rebuilt on current `main` with only the remaining route. The earlier version is kept on `khensthoth:fix/talk-consult-prompt-cache-v1-backup`. Live observations from the original version (22 Oct) showed 96–98% cached input on follow-up Gemini Talk consults with this route fixed.

## Evidence

Upstream CI on this head is waiting for workflow approval. Run on `d7bb6636` in a clean `node:24-bookworm` container (Linux, Node 24.22, `CI=true`, prompt-cache assertion on):

- `oxfmt --check` and `oxlint` on the changed files: clean.
- `index.test.ts`, `client-native-actions.test.ts`, `client-native-control.test.ts`: 113/113 passed.
- `relay-consult-adoption.regression.test.ts`: 9/9 passed.
- `server.talk-consult-history.test.ts`: 20/22. The two failures (`keeps host-authenticated node approval cancellation`, public callback false/true) fail identically on unmodified `main` at `2c4413a6` in the same container (`SYSTEM_RUN_DENIED: approval cannot safely bind this interpreter/runtime command`), so they come from that environment, not this change. In one earlier full-file run `isolates registered Talk replay across authenticated callers` hit its 10 s `agent.wait` timeout; it passed on rerun, alone and in the full file, with the assertion on and off.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Keith <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 4c45bb4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributors PR from a clawtributor docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Talk realtime consults rewrite session history, so every voice consult re-writes the whole prompt cache

3 participants