Skip to content

feat(rpc): tell hosts when the prompt cache expires - #59

Merged
yaacovcorcos merged 2 commits into
mainfrom
claude/idle-cache-20261113
Nov 14, 2026
Merged

yaacovcorcos merged 2 commits into
mainfrom
claude/idle-cache-20261113

Conversation

@yaacovcorcos

@yaacovcorcos yaacovcorcos commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

An assistant reply's RPC message_end frame now carries promptCache: the tier, touch time and lifetime of the prompt-cache entry its response confirmed. Scient Desktop needs this to compact an idle thread just before a one-hour cache expires, so the summary reads a warm cache instead of re-writing the whole context on the next message.

What's new

  • message_end for an assistant reply gets promptCache: { tier: "short" | "long", touchedAt, ttlMs } while the next request would still read the entry.
  • It is left out for an inferred entry, a changed conversation, a model with no declared lifetime, and a cache that never expires.
  • The agent's own idle compaction stays a terminal feature, so it never races a host that compacts.
  • Hosts that do not read the field are unaffected. Owned code: src/scient/prompt-cache.ts; one marked hook in rpc-mode.ts and wire/events.ts. Clients regenerated in a separate (generated) commit.

Desktop: ScientFactory/scient-desktop#923 (idle compaction). Plan mode on top: #60 here, ScientFactory/scient-desktop#925. Desktop sets an expiry only for long entries.

Checked

  • bun test test/scient/prompt-cache.test.ts test/rpc-prompt-result.test.ts pass, with the rest of the stack's tests (49).
  • bun run check:ts passes (no warnings in touched files). Divergence check (stack top): 34 commits, all accounted for, 7 generated commits match their generators.
  • Live: the binary from this branch ran in a Desktop dev app. With GPT-6 Luna (no declared lifetime in the catalog) it correctly sent no entry. A real one-hour entry needs an Anthropic sign-in, so the field itself is covered by unit tests only. Record: reviews/scient-agent-next-20261111/build-all-20261113/agentmodes-RECORD.md in the ScientFactory workspace.

Platforms: no platform-specific code. Tested on macOS only; Windows and Linux run the same code, covered by CI.

Release: ships in the next Scient Agent release, which is held until #53 merges.

Scient-Divergence: SA-PROMPT-CACHE

🤖 Generated with Claude Code

yaacovcorcos and others added 2 commits November 14, 2026 18:58
An assistant reply's message_end now carries promptCache: the tier,
touch time and lifetime of the prompt-cache entry its response
confirmed, while the next request would still read it. The session
already tracks this entry for the status line and the cache warmer.

Scient Desktop compacts an idle thread just before a one-hour entry
expires, so the summary reads a warm cache instead of the next message
re-writing the whole context. It needs the expiry to do that. The field
is left out for an inferred entry, a changed conversation and a cache
that never expires (logged-in Codex). The agent's own idle compaction
stays a terminal feature, so the two never race. Hosts that do not read
the field are unaffected.

Scient-Divergence: SA-PROMPT-CACHE

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scient-Generator: rpc
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yaacovcorcos
yaacovcorcos merged commit 456c3bc into main Nov 14, 2026
15 checks passed
@yaacovcorcos
yaacovcorcos deleted the claude/idle-cache-20261113 branch November 14, 2026 18:32
yaacovcorcos added a commit that referenced this pull request Nov 15, 2026
ChatGPT apps through the person's ChatGPT sign-in, with `apps --json` and the host command list in `--runtime-info` (#57). Hosts learn when the prompt cache expires (#59). Plan mode for RPC hosts (#60).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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