← Back to Pull requests

fix(runtime): preserve context history for prompt caching #6177

Closed
unknown closed this pull request without merging on Oct 20, 2026 09:59 UTC
View on GitHub
unknown unknown commented on Oct 19, 2026 16:25 UTC
Author

Time and Inbox context used to be replaced at the end of each model request. Updating the clock therefore changed an existing request prefix, reducing cache reuse even when the conversation had only grown.

Persist named runtime context as internal events and append a new value only when it changes. Historical values remain unchanged, retries reuse the same snapshot, and replay preserves event order. Split the matter clock from its Inbox so observation-only revision changes do not resend the Inbox. Context removed by compaction is refreshed afterward; internal context remains hidden from the chat transcript.

Validation on current main:

  • 700 targeted tests passed: runtime history, context, retries, replay, compaction and recovery (662), core event decoding (29), Host composition/steering (7), and MatterController (2).

  • Core, runtime and runtime-host builds; UI and desktop type checks passed. Staged lint, formatting, license headers and diff checks passed.

  • Prior isolated real-model validation used GPT-6.1 Sol at medium effort with the modified runtime and actual MatterStore/Controller. A running Inbox amendment and a steering message both reached the next model request. Four calls retained the full previous input prefix; cache hits were 0%, 88.9%, 96.7%, and 96.6%. One earlier repeat still had a cache miss despite an unchanged prefix, so this does not guarantee provider cache availability or resolve every timeout.
  • Real-model tools were read-only synthetic fixtures outside the repository, not a production business-workflow test. An earlier broader Host test process did not exit naturally and is not counted as passing; the relevant targeted Host tests completed successfully.

    Review follow-up:

  • Adapt Host environment, Agent Graph/Swarm, and cold WorkHub recovery fixtures to persisted runtime context history. Production behavior and original assertions remain unchanged.

  • The five review-reported regressions pass; runtime-host type checking and changed-file formatting checks pass. Final Host dist suite: 2,830 passed, 13 skipped, 1 failed. The remaining failure is prompt suggestions ask Kimi K3 for its lowest effort instead of its default thinking (missing thinking: {type: adaptive}); it passed in an earlier isolated run but failed in the full suite, so the full suite is not reported as passing. Missing executor/filesystem-worker build artifacts were corrected before this final run. Separately, assistant suites passed 83 memory-network and 24 initiative tests; Matters passed 79/80, with the queued-wake timeout passing on isolated rerun. These additional failures were not hidden or relaxed. No paid-model tests or production deployment were performed for this follow-up.
  • Generative-tool attribution: OpenAI Codex made substantive implementation, test, and documentation contributions to this PR. The follow-up commit includes Generated-by: OpenAI Codex; preserve this trailer in the final squash commit.

    Diff: 369 lines (+276 / -93) across 4 files Reviewer: M4n5ter Review duration: 1053m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 369 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.354
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6177"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.8% (MEDIUM) · Higher = larger blast radius
    42.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.9% · Safe to merge
    16.9%
    Repository