Skip to content

fix(openai-responses): prevent repeated GPT-5.6 cache writes - #130067

Closed
BukeLy wants to merge 7 commits into
openclaw:mainfrom
BukeLy:fix/bedrock-gpt56-explicit-prompt-cache
Closed

BukeLy wants to merge 7 commits into
openclaw:mainfrom
BukeLy:fix/bedrock-gpt56-explicit-prompt-cache

Conversation

@BukeLy

@BukeLy BukeLy commented Aug 26, 2026 •

Copy link
Copy Markdown

Closes #130061

Related: #108216. #111782 owns automatic Mantle discovery and endpoint routing; this change owns caching after a Responses route is selected. The manual Mantle configuration in the provider docs is usable independently of automatic discovery.

What Problem This Solves

OpenClaw discards its stable/dynamic system-prompt boundary when constructing GPT-5.6 Responses requests. Changing turn context and tool results can therefore cause repeated cache writes instead of reusing stable instructions. Responses succeed while cache-write cost accumulates.

The repair preserves the stable prefix on native OpenAI and verified compatible Responses endpoints, keeps current dynamic context visible during continuation, and preserves measured compaction usage after saved-history reload.

Why This Change Was Made

The shared Responses request owners now translate the existing prompt boundary into one content-level prompt_cache_breakpoint and send prompt_cache_options.mode: "explicit".

  • Native OpenAI GPT-5.6 model IDs enable the contract automatically. Display names do not establish capability.
  • Verified compatible providers declare the optional supportsExplicitPromptCaching runtime capability while normalizing their models. Unknown endpoints remain implicit.
  • cacheRetention: "none" sends explicit mode with no breakpoint or cache key, preventing cache writes while preserving current instructions.
  • The existing shared lifetime owner remains authoritative: native long retention composes ttl: "30m" with explicit mode. Compatible providers retain their declared key/lifetime limits.
  • Continuation compares the stable prefix and sends the current dynamic developer context with the new input. Current reasoning replay, raw tool-call restoration, pending async calls, recovery, and bounded session cleanup remain composed into that owner.
  • Measured compaction usage records the admitted breakpoint representation so saved-history reconstruction compares the same request bytes.
  • Explicit input blocks use the canonical boundary stripper, preserving instruction text while removing internal relocation delimiters.

The Mantle plugin declares support for its prefixed GPT-5.6 Responses models and preserves an explicitly disabled prompt-cache key. Both managed transport and simple completion use the same conversion and capability contract.

This adds one optional provider-owned runtime capability and no user configuration option or Plugin SDK subpath. The provider SDK docs define the endpoint-verification and payload-test requirements for declarations. The declaration is additive and defaults off for unverified compatible endpoints.

The Responses SDK compatibility type also declares the existing supportsPromptCacheKey switch, matching the runtime's native-default/compatible-opt-in behavior and allowing verified models to preserve an explicit key opt-out.

User Impact

GPT-5.6 Sol, Terra, and Luna agents can reuse stable instructions across changing turns without repeatedly writing dynamic context. Continued requests retain current instructions, and compaction accounting can still use measured provider usage after transcript reload.

Evidence

API contracts

  • OpenAI prompt caching: explicit mode uses only selected breakpoints; no breakpoints means no cache writes; developer input blocks carry breakpoints; GPT-5.6+ uses a 30-minute TTL.
  • Amazon Bedrock prompt caching: the three prefixed GPT-5.6 models support explicit Responses caching with a 1,024-token minimum and 30-minute TTL.
  • Installed [email protected] declares both request cache options and content-level breakpoints.

Fresh native OpenAI transport proof

On 2026-10-10, the candidate's real createOpenAIResponsesTransportStreamFn made three credentialed gpt-5.6-luna SSE requests with a synthetic stable prefix, changing developer markers, and stateful continuation enabled through the existing payload hook. Captures inspected the final serialized bytes passed to fetch.

turn 1: HTTP 200  output=FIRST   cacheRead=0     cacheWrite=4918
turn 2: HTTP 200  output=SECOND  cacheRead=4918  cacheWrite=0
turn 3: HTTP 200  output=THIRD   cacheRead=4918  cacheWrite=0

Exactly three physical requests completed successfully. Turns two and three sent previous_response_id and only the current dynamic developer message plus the new user turn. The stable instruction prefix was absent from those wire deltas. No credential or private prompt content was recorded.

The real Mantle QQ Bot tool-loop trace supplies compatible-endpoint cache proof: the four follow-up tool rounds each reused 25,375 cached tokens with zero new writes.

Regression proof

Before the owner fixes, the strengthened three-turn test returned stop, stop, error, and both native/shared explicit-cache compaction cases lost their measured boundary after JSON transcript reload. After the fixes, all six selected continuation and saved-history scenarios passed.

The broader Responses/cache/replay selection covers native key and TTL behavior, compatible declarations, opt-out, instructions, SSE/WebSocket continuation, reasoning replay, tool IDs, recovery, lifecycle cleanup, and compaction usage. Mantle tests cover prefixed IDs and preservation of explicit key opt-out.

Stable saved-data compatibility

The retained fixture comes from eleven immutable v2026.9.9 source owners, with their SHA-256 hashes recorded. The candidate saves and reopens all four synthetic messages through the supported SQLite session reader, restores the old 520-token compaction usage boundary, and sends the next request through real SDK serialization into mocked HTTP/SSE. Model/provider/API/base URL, cache-key opt-out, retention selection and saved conversation remain unchanged. The new request contains the retained compaction and conversation plus the current explicit stable-prefix breakpoint.

This validates source-produced saved-data compatibility; it does not claim a complete published-binary database upgrade.

Validation

Local owner selections passed using the standard pnpm test ... --maxWorkers=1 entrypoint:

  • Responses, cache, replay, continuation, compaction, WebSocket, sibling cache policy and stable-data upgrade: 307 tests in 15 files.
  • Mantle registration, discovery and Anthropic sibling runtime: 67 tests in 3 files.
  • Gateway reader/entry/render and live-probe prerequisites: 49 tests in 4 files.
  • Embedded agent stream selection: 13 tests in 1 file.

The final Responses selection took 8.98 seconds (10.59 seconds through the repository wrapper), reusing the shared compiled generation. The parameter owner took 0.785 seconds standalone (13 tests). The Mantle selection took 9.30 seconds, Gateway 7.84 seconds, and embedded caller 13.22 seconds.

The complete Dashboard browser file passed 8/8 tests in 22.70 seconds, including the production UI build and Chromium setup. True pointer clicks cover both original Pin failures, Details open/close, widget documents, dashboard commands, permissions and Workboard linkage.

Core and UI production, package tests/shared declarations, plugin production and plugin test typechecks passed. Scoped source and UI stylesheet lint, formatting, assertion safety, line caps and deprecated API checks passed.

Docs passed Markdown, template, MDX, glossary, internal link, configuration-fence and changelog gates: 14,955 links with zero broken links, and 1,316 validated configuration fences. Config/schema baselines remain unchanged. Local ratchets, plugin boundaries, source lint, dependency pins/patches, schema version, database/media/sidecar guards, authentication/webhook guards and zero runtime import cycles passed.

At head 37ba43fca63379ddc526d0e7d78cfb7852910c5b, pnpm build passed in 4m46.1s, verifying 151 public SDK subpaths, 96 external plugins, 54 native modules and the Control UI build. The public SDK declaration graph is 4,761,404 bytes against a 5,315,536-byte limit. The production, full-tree and scripts unused-export scans all passed with zero entries.

The strict normalized Control UI performance lane passed in native CI. Final candidate: ca81f06b37e06f7d6d3080add2f2bea1630ed700; exact-head native CI is verified after publication.

Independent structured review of the complete candidate: scoped-clean, no actionable P0–P2 findings or suspected credentials.

The branch carries the small CI prerequisite from #168292, original commit 8133cc33327afa7c7882cd625d0a6e324ee5e2e0, with Dallin Romney's original author identity preserved. It removes two test-only Gateway exports, exercises the actual rendered lifecycle script in the existing refresh fixture, and removes the stale doctor-memory-search.test.ts max-lines entry. Rendered script bytes, HTML and CSP behavior remain unchanged. The older pr-cross-checkout.test.ts missing-tool fixture failure is fixed by upstream commit 4bbdedbb9b94fa0d13c4db0fae292c29a9021be6, included in this branch's base.

The integration prerequisite also reserves the existing above-preview widget toolbar's 36-pixel height plus the 12-pixel spacing token in normal flow. This clears the Details header in narrow conversation columns and keeps both controls clickable. The E2E fixture uses the canonical language context. General Details layout and widget document execution remain owned by their existing implementations.

Production growth implements the shared explicit-cache wire contract, stable/dynamic continuation comparison, and measured-prefix reconstruction. Tests cover those observable contracts; provider documentation explains the additive capability and manual configuration.

@clawsweeper

clawsweeper Bot commented Aug 26, 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 docs Improvements or additions to documentation extensions: amazon-bedrock-mantle size: M labels Aug 26, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR adds explicit GPT-5.6 Responses caching, Mantle capability metadata, replay accounting, and widget toolbar spacing.

Example: Five Mantle GPT-5.6 Terra requests in a tool loop.

  • Before: Follow-up requests wrote another 169, 101, 101, and 101 cache tokens.
  • After: Each follow-up reused 25,375 cached tokens with zero additional writes.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful live cache evidence supports the central change, but a verified continuation defect and unresolved product direction prevent readiness.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Performance · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: GPT-5.6 agent workflows can repeatedly incur cache-write charges while responses continue to succeed.
Reason: The demonstrated savings merit retaining the work, while the automatic policy change and provider contract require owner direction.

Merge readiness

⛔ Blocked before merge - 6 items remain

This PR contains useful caching work absent from current main, but the previously reported stale-instruction defect remains unresolved.

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

Decision needed

  • Question: Should native GPT-5.6 Responses default to system-prefix-only explicit caching, and should providers receive the proposed runtime capability?
  • Recommendation: Preserve native history caching: Retain native implicit caching, consider a stable-prefix breakpoint, and reserve explicit-only policy for verified workloads where total cost improves.
  • Why: Write suppression is demonstrated, but conversation history becomes uncached and no qualifying owner approval settles that tradeoff or the additive provider contract.

Before merge

  • Add real behavior proof - Native credentialed production-transport SSE output exercises caching and continuation, and BukeLy's Mantle Gateway trace exercises tool-loop reuse; the added widget spacing lacks before/after visual evidence, and saved-data evidence uses a v2026.9.9 source fixture rather than the required latest-stable upgrade with settings and conversation intact; redact credentials and private endpoints from additional captures. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Avoid re-appending a superseded pinned prompt suffix (P2) - The production prompt-series owner pins the initial complete system prompt and appends replacement sections when instructions change. With Temporal Context Day 1 initially, turn two appends a Day 2 replacement; an unchanged third turn still supplies Day 1 in the pinned suffix. This unconditional prepend then sends Day 1 after the stored Day 2 update, making obsolete developer instructions newer than their replacement. Compose suffix delivery with the existing prompt-series owner so unchanged pinned content is not appended again, and cover this three-turn sequence through projection and continuation. This previously reported finding remains present on the same reviewed head.
  • Complete next step - Resolve GitHub's reported conflicts against main and validate the affected resolutions.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.
  • Explain or restore the original intent of Complete prompt-series pinning - a79e29e: Preserve the initial complete prompt and append refreshed instruction sections in history.

Findings

  • [P2] Avoid re-appending a superseded pinned prompt suffix — packages/ai/src/transports/openai-responses-continuation.ts:576

Provenance

  • Complete prompt-series pinning changes intended behavior without addressing why it exists (a79e29e: Preserve the initial complete prompt and append refreshed instruction sections in history.)

Tests

  • Missing end-to-end proof: Supply before/after widget screenshots and a latest-stable upgrade run, and extend continuation coverage through the real pinned-prompt projection rather than manually replacing systemPrompt between turns.
Agent review details

How this fits together

The shared Responses builders convert model capabilities, system instructions, and conversation history into provider requests; continuation reuses stored responses, and replay metadata supports later context accounting.

flowchart TD
  A[Model capabilities] --> C[Responses request builders]
  B[Prompt series and history] --> C
  C --> D[Continuation owner]
  D --> E[OpenAI or Mantle endpoint]
  E --> F[Response and replay accounting]
  F --> B
Loading

Technical review

Best possible solution:

Compose cache boundaries with the existing prompt-series owner, preserve reusable history, and separate the unrelated widget layout repair.

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

Source tracing establishes both the current implicit-cache path and the introduced stale-suffix continuation path; contributor traces demonstrate cache-write suppression, and no target code was executed during this review.

Is this the best way to solve the issue?

Shared Responses ownership is appropriate, but unconditional suffix delivery conflicts with prompt pinning and the proposed native default trades history-cache reuse for write suppression.

Full review comments:

  • [P2] Avoid re-appending a superseded pinned prompt suffix — packages/ai/src/transports/openai-responses-continuation.ts:576
    The production prompt-series owner pins the initial complete system prompt and appends replacement sections when instructions change. With Temporal Context Day 1 initially, turn two appends a Day 2 replacement; an unchanged third turn still supplies Day 1 in the pinned suffix. This unconditional prepend then sends Day 1 after the stored Day 2 update, making obsolete developer instructions newer than their replacement. Compose suffix delivery with the existing prompt-series owner so unchanged pinned content is not appended again, and cover this three-turn sequence through projection and continuation. This previously reported finding remains present on the same reviewed head.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native cache settings changes intended behavior with a stated reason (8e3f572: Honor native retention and cache-key settings through shared endpoint and lifetime policy.)
  • Responses instructions and continuation changes intended behavior with a stated reason (e1a2f77: Keep changing instructions outside input-prefix comparison so routine prompt changes do not defeat continuation.)
  • Migration preservation queries keeps the original intent (974443a: Compare sealed recovery captures without changing persisted data; the diff retains query semantics while annotating raw SQL boundaries.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 8e3f572 adds packages/ai/src/providers/openai-responses.ts:15 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8e3f572ffa25; files: packages/ai/src/providers/openai-responses.ts)
  • Markus Hartung: Raw commit e1a2f77 adds packages/ai/src/transports/openai-responses-params-internal.ts:238 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e1a2f775733e; files: packages/ai/src/transports/openai-responses-params-internal.ts)

PR surface

Source +253, Tests +633, Docs +67. Total +953 across 29 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 15 310 57 +253
Tests 10 650 17 +633
Docs 4 71 4 +67
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 29 1031 78 +953

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #130061
Summary: The paired issue describes the explicit-cache payload gap this PR implements; automatic Mantle routing remains separate.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The affected workflows continue running, but caching costs and refreshed instructions can be wrong within the selected Responses routes.
  • merge-risk: 🚨 compatibility: The PR changes native caching defaults and adds a provider-facing runtime capability.
  • merge-risk: 🚨 session-state: Continuation can append an original pinned suffix after a newer instruction replacement.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 (20 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-31T08:57:49.273Z sha 19ac33573ea8e1768c6daf55b7536de513dee7f3 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T09:01:06.233Z sha c0169a92abd50f5a64a9f3b02726d0df36636bb9 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-04T21:40:40.263Z sha c0169a92abd50f5a64a9f3b02726d0df36636bb9 :: blocked before merge. :: none
  • reviewed 2026-10-03T11:36:47.758Z sha c0169a92abd50f5a64a9f3b02726d0df36636bb9 :: blocked before merge. :: [P3] [P3] Queue the third response in the explicit-cache regression
  • reviewed 2026-10-10T07:47:51.833Z sha 37ba43fca63379ddc526d0e7d78cfb7852910c5b :: blocked before merge. :: [P2] [P2] Update the existing Responses retention assertion | [P3] [P3] Strip relocation markers from explicit-cache content
  • reviewed 2026-10-10T08:30:54.753Z sha ca81f06 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T09:08:07.562Z sha 60209ca :: needs real behavior proof before merge. :: [P2] Avoid re-appending a superseded pinned prompt suffix
  • reviewed 2026-10-10T10:04:09.183Z sha 59d7385 :: needs real behavior proof before merge. :: [P2] Avoid re-appending a superseded pinned prompt suffix

Reviewed October 18, 2026, 3:15 AM ET / 07:15 UTC (Revision 21).

@BukeLy
BukeLy force-pushed the fix/bedrock-gpt56-explicit-prompt-cache branch from 9e6d1e6 to c25ef95 Compare August 26, 2026 10:39
@BukeLy
BukeLy marked this pull request as ready for review August 26, 2026 10:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c25ef95c15

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@BukeLy

BukeLy commented Aug 26, 2026

Copy link
Copy Markdown
Author

Updated head c25ef95c15251345fa65fed47f12bdc0a02bb4fd is now cache-only:

This removes both P1 findings from the prior review (which inspected superseded head 9e6d1e6f25). The current PR is mergeable and maintainer edits are enabled.

Current exact-head CI has one upstream blocker: packages/memory-host-sdk/src/host/session-files.test.ts exceeds max-lines. The same file fails recent main run 32959379240; exact local reproduction of this PR's check-lint-core-1 command passes on the branch baseline. The second red check-lint is an aggregate cancellation from that same failure.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 26, 2026
@BukeLy
BukeLy force-pushed the fix/bedrock-gpt56-explicit-prompt-cache branch from c25ef95 to 04c11f0 Compare August 26, 2026 14:20
@BukeLy

BukeLy commented Aug 26, 2026

Copy link
Copy Markdown
Author

Addressed all three current-head ClawSweeper findings in 04c11f0aa8:

  • Composed Mantle cache decoration with the shared OpenAI Responses payload policy, including replayed-item status and disabled-reasoning cleanup.
  • Registered the same wrapper for wrapSimpleCompletionStreamFn, using sourceApi so projected internal transport aliases keep the Responses wire contract.
  • Normalized GPT-5.6 Responses models with supportsLongCacheRetention: false, so cacheRetention: "long" does not emit prompt_cache_retention: "24h".

Regression proof:

  • Pre-fix: the three focused assertions failed independently.
  • Post-fix: pnpm test:extension amazon-bedrock-mantle — 61/61 passed.
  • pnpm test src/agents/embedded-agent-runner-extraparams.test.ts — 144/144 passed.
  • Exact-file pnpm check:changed passed all typecheck, lint, SDK, boundary, and cycle guards; Knip scans reported 0 unused exports.
  • pnpm build, pnpm check:docs, and uncommitted autoreview all passed; autoreview reported patch is correct at 0.98 confidence.

Automatic discovery and endpoint routing remain out of scope here and owned by #111782.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 26, 2026
@BukeLy

BukeLy commented Aug 26, 2026

Copy link
Copy Markdown
Author

Live QQ Bot message_tool proof for exact-head behavior, using the same prompt before and after enabling the Mantle explicit-cache wrapper on OpenClaw 2026.7.1-2.

The test called message(action="send", dryRun=true) four times sequentially, waiting for each tool result. No QQ message was delivered. Both runs completed with toolSummary.calls=4, tool message, and failures=0.

Before, automatic cache mode:

call 1: input=2 cacheRead=0     cacheWrite=26257
call 2: input=2 cacheRead=26257 cacheWrite=169
call 3: input=2 cacheRead=26426 cacheWrite=101
call 4: input=2 cacheRead=26527 cacheWrite=101
call 5: input=2 cacheRead=26628 cacheWrite=101

After, explicit mode with one stable system-prompt breakpoint:

call 1: input=891  cacheRead=0     cacheWrite=25375
call 2: input=1062 cacheRead=25375 cacheWrite=0
call 3: input=1163 cacheRead=25375 cacheWrite=0
call 4: input=1264 cacheRead=25375 cacheWrite=0
call 5: input=1365 cacheRead=25375 cacheWrite=0

The live route was amazon-bedrock-mantle/openai.gpt-5.6-terra at POST /openai/v1/responses; all five responses were HTTP 200 SSE. After the run, the Gateway remained reachable and QQ Bot default was running and connected.

This directly covers the multi-round message_tool loop that motivated the change: the first request writes the stable prefix, and every follow-up tool round reads that same prefix without another cache write.

@BukeLy
BukeLy force-pushed the fix/bedrock-gpt56-explicit-prompt-cache branch from 04c11f0 to 7efd87f Compare August 26, 2026 15:15
@BukeLy

BukeLy commented Aug 26, 2026

Copy link
Copy Markdown
Author

Updated head 7efd87febd resolves the remaining SDK-contract finding:

  • Removed all three new Plugin SDK exports; the PR now has zero src/plugin-sdk diff.
  • Reused the existing createOpenAIResponsesContextManagementWrapper seam from provider-stream-family.
  • Kept the cache-boundary split provider-local, so no new public compatibility contract is created.
  • Preserved sourceApi projection for simple-completion transport aliases.

Verification after this refactor:

  • pnpm test:extension amazon-bedrock-mantle — 61/61 passed.
  • pnpm test src/agents/embedded-agent-runner-extraparams.test.ts — 144/144 passed.
  • Extension typecheck, focused lint, deprecated-API guard, wrapper-shadowing guard, import-cycle guard, SDK surface check, and full pnpm build passed.
  • The live QQ message_tool A/B proof remains applicable because request behavior did not change: fix(openai-responses): prevent repeated GPT-5.6 cache writes #130067 (comment)

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Aug 26, 2026
@BukeLy
BukeLy force-pushed the fix/bedrock-gpt56-explicit-prompt-cache branch 2 times, most recently from 19ac335 to c0169a9 Compare September 1, 2026 08:32
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. and removed P1 High-priority user-facing bug, regression, or broken workflow. labels Sep 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 3, 2026
@BukeLy
BukeLy force-pushed the fix/bedrock-gpt56-explicit-prompt-cache branch from c0169a9 to 37ba43f Compare October 10, 2026 07:38
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime and removed agents Agent runtime and tooling labels Oct 10, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@BukeLy
BukeLy force-pushed the fix/bedrock-gpt56-explicit-prompt-cache branch from 37ba43f to ca81f06 Compare October 10, 2026 08:22
Attach existing raw SQL allowances to the actual SQL nodes, document the immutable backup PRAGMA, and reuse quoted schema-derived identifiers. Query text, value encoding and migration behavior remain unchanged.

Validated pnpm lint:kysely, the existing plugin rowid/view/trigger preservation test, formatting and git diff --check.
@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.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @BukeLy for the detailed cache-cost investigation and endpoint traces. Closing this broad patch in favor of the prefix-preservation repairs in #140849, #167698, and #181301.

On current main (7293e892728aef27996d8a15626e006e2d537dcc), I compared the exact SDK-serialized requests for consecutive turns on GPT-5.6 Sol, Terra, and Luna through both managed and simple Responses builders. Every pair kept identical cache keys, instructions, tool definitions/order, and earlier input bytes; only appended conversation input changed. Both default and explicit cache-key cases passed. The existing tool-loop, cold-replay, prompt-pinning, and required agent-tool prefix-stability tests also passed.

This is request-boundary evidence, not a live billing measurement. A system-only explicit-mode default disables implicit history checkpoints, so eliminating new writes alone does not establish lower total cost. Leaving #130061 open for measured breakpoint-placement and total-cost work; your endpoint evidence remains useful there. No contributor code was executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui commands Command implementations docs Improvements or additions to documentation extensions: amazon-bedrock-mantle gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: GPT-5.6 Responses lacks explicit cache breakpoints

3 participants