Skip to content

fix(core): freeze model-visible prefix for prompt cache - #365

Merged
github-actions[bot] merged 2 commits into
mainfrom
feat/prompt-cache-freeze
Aug 16, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
feat/prompt-cache-freeze

Conversation

@mohitranka

@mohitranka mohitranka commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stop rewriting already-sent model-visible context between consecutive requests so provider prompt caches can reuse the prefix.

This is PR 1 of 2. Follow-up: #366.

Changes

  • Always list view_image on the tool array. image_input is a call-time deny only.
  • Snapshot image attachments into the session cache at insert; drop request-time apply_missing_image_notes.
  • Apply CTX-01 tool-output offload on the HITL success path before journal + messages.push.
  • Resume: keep a journaled system message (so CTX-02 handoff survives); strip assistant text the same way as live; replay ToolValidationFailed as a tool message.

Tests

  • view_image stays listed when image_input flips.
  • Missing image is noted at insert and does not grow later.
  • Deleted original image still loads from the snapshot.
  • HITL large output is stubbed before insert.
  • Resume replays validation-failed tool messages and CTX-02 handoff system text.
  • Same registry rebuilt in different register order serializes identically.
cargo test --package forge-model --package forge-core --package forge-durable --package forge-context --package forge-tools --all-targets --locked

Out of scope

No compaction, no Gemini client, no TUI, no provider cache_control changes (that's #366).

Stop rewriting already-sent context between requests: always list
view_image, snapshot images at insert, offload HITL tool output
before it enters history, and replay resume transcripts as they
were last sent.
Drop OpenAI-compat cache_control, mark Anthropic tools/system
stably and slide only the last conversation block, and journal a
stripped prompt-wire hash so unexpected prefix mutations show up
in debug logs.
@github-actions
github-actions Bot merged commit bc5ce08 into main Aug 16, 2026
7 checks passed
mohitranka added a commit that referenced this pull request Aug 21, 2026
* fix(core): freeze model-visible prefix for prompt cache

Stop rewriting already-sent context between requests: always list
view_image, snapshot images at insert, offload HITL tool output
before it enters history, and replay resume transcripts as they
were last sent.

* feat(model): sticky Anthropic cache marks and prefix diagnostics (#366)

Drop OpenAI-compat cache_control, mark Anthropic tools/system
stably and slide only the last conversation block, and journal a
stripped prompt-wire hash so unexpected prefix mutations show up
in debug logs.
mohitranka added a commit that referenced this pull request Sep 11, 2026
* fix(core): freeze model-visible prefix for prompt cache

Stop rewriting already-sent context between requests: always list
view_image, snapshot images at insert, offload HITL tool output
before it enters history, and replay resume transcripts as they
were last sent.

* feat(model): sticky Anthropic cache marks and prefix diagnostics (#366)

Drop OpenAI-compat cache_control, mark Anthropic tools/system
stably and slide only the last conversation block, and journal a
stripped prompt-wire hash so unexpected prefix mutations show up
in debug logs.
mohitranka added a commit that referenced this pull request Sep 11, 2026
* fix(core): freeze model-visible prefix for prompt cache

Stop rewriting already-sent context between requests: always list
view_image, snapshot images at insert, offload HITL tool output
before it enters history, and replay resume transcripts as they
were last sent.

* feat(model): sticky Anthropic cache marks and prefix diagnostics (#366)

Drop OpenAI-compat cache_control, mark Anthropic tools/system
stably and slide only the last conversation block, and journal a
stripped prompt-wire hash so unexpected prefix mutations show up
in debug logs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant