Skip to content

docs(agents): key caches by every input that changes the answer - #174837

Merged
obviyus merged 1 commit into
mainfrom
docs/cache-identity-rule
Oct 16, 2026
Merged

obviyus merged 1 commit into
mainfrom
docs/cache-identity-rule

Conversation

@obviyus

@obviyus obviyus commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: agents keep shipping caches whose key leaves out an input that changes the answer. Callers then collide, serve another agent's or account's data, return stale results, or never hit the cache. No rule in AGENTS.md covers cache keys.

User Impact

No user-visible change. Agents get one rule that tells them what a cache key must contain and how to prove sharing is safe.

Why This Change Was Made

The rule adds one line under "Runtime and code safeguards":

  • key caches, memos, in-flight joins and shared snapshots by scope and request shape;
  • give callers asking different questions separate slots;
  • keep volatile values out of keys;
  • prove sharing with a work-count test where differing callers interleave.

#174741 is the trigger. usage.status and models.authStatus shared one provider-usage slot per agent but asked for different provider sets. They evicted each other on every Models page load for 80 days, across 7 refactor passes, because no test interleaved the two callers.

Evidence

I reviewed main since 2026-04-01: every fix commit whose diff touched cache-key, cache get/set or in-flight lines (728 commits). Each one was judged by reading its message and diff. 95 fixed a cache identity bug. That is about 3 per week, steady every month (Apr 14, May 13, Jun 8, Jul 15, Aug 18, Sep 16, Oct 1–16 11).

Kind Count Example
Key omits an input, so the answer is stale or wrong 35 276ba10: markdown render cache ignored codeBlockChrome
Data leaks across agent, account or credential scope 23 6a12c6f: run→session lookup keyed by runId only; 1487b45: GitHub previews shared across credentials; 51042e8: cron deliveries routed to the wrong agent
Different callers collide or evict each other 14 c3f0b6a (#174741); f8380a8: route keys with separators collided
Key too volatile, so it never hits 14 3f9d241: prompt-cache key was the per-run session id
In-flight join dedups unrelated work 9 2aabde7: deep health probe joined a passive refresh; 4ca63cb: dispatch joined a different executionMode

23 of the 95 were data leaks across scopes, so this is a correctness and privacy issue, not only performance.

@clawsweeper

clawsweeper Bot commented Oct 16, 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.

@obviyus
obviyus marked this pull request as ready for review October 16, 2026 23:38
@clawsweeper clawsweeper Bot added clawsweeper:intake:docs Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. and removed clawsweeper:intake:docs Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Adds a root agent instruction requiring cache identity to account for scope and request shape, with interleaved work-count validation.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-supported documentation improvement with clean validation and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Only contributor instructions change, so shipped runtime evidence is unnecessary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Docs · Worth it: Yes · Fix scope: Complete
User problem: Incomplete cache identities can mix scopes, discard useful results, or repeatedly redo work.
Reason: The maintainer-authored addition captures a concrete failure pattern with a concise invariant and a meaningful validation approach.

Merge readiness

✅ Ready for maintainer review

This PR adds useful, focused cache-identity guidance missing from current main; no actionable defects were found, and exact-head checks pass.

Priority: P3
Reviewed head: 60b345b19ea6fc6b1feb24f59d1c28c3d7b011f6

Before merge

None.

Findings

None.

Agent review details

How this fits together

The root AGENTS.md guides repository contributors and coding agents; this addition turns cache-design inputs into explicit implementation and validation requirements.

flowchart TD
  A[Contributor task] --> B[Root agent instructions]
  B --> C[Cache identity design]
  C --> D[Interleaved behavior validation]
  D --> E[Reviewed implementation]
Loading

Technical review

Best possible solution:

Retain the concise cache-identity rule alongside the existing lifecycle and hot-path guidance.

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

This documentation-only PR requires no runtime reproduction; the motivating cache collision is independently supported by its merged implementation and regression coverage.

Is this the best way to solve the issue?

The addition states a reusable identity invariant at the existing policy owner without introducing implementation machinery or duplicating lifecycle rules.

AGENTS.md: found and applied where relevant.

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

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 872d5b2 adds AGENTS.md:71 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 872d5b20e3f8; files: AGENTS.md)

PR surface

Docs +1. Total +1 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 1 0 +1

Labels

Label changes:

  • add P3: This is a focused contributor-guidance improvement with no direct runtime change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a focused contributor-guidance improvement with no direct runtime change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed October 16, 2026, 7:53 PM ET / 23:53 UTC.

@obviyus
obviyus merged commit baf094d into main Oct 16, 2026
131 checks passed
@obviyus
obviyus deleted the docs/cache-identity-rule branch October 16, 2026 23:54
@obviyus

obviyus commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in baf094d. Adds the cache identity rule to root AGENTS.md: key caches, memos, in-flight joins and shared snapshots by every input that changes the answer. The evidence is in the PR body: 95 cache-key fixes since April, 23 of them leaks between agents, accounts or credentials.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…claw#174837)

## What Problem This Solves

Fixes: agents keep shipping caches whose key leaves out an input that changes the answer. Callers then collide, serve another agent's or account's data, return stale results, or never hit the cache. No rule in `AGENTS.md` covers cache keys.

## User Impact

No user-visible change. Agents get one rule that tells them what a cache key must contain and how to prove sharing is safe.

## Why This Change Was Made

The rule adds one line under "Runtime and code safeguards":
- key caches, memos, in-flight joins and shared snapshots by scope and request shape;
- give callers asking different questions separate slots;
- keep volatile values out of keys;
- prove sharing with a work-count test where differing callers interleave.

openclaw#174741 is the trigger. `usage.status` and `models.authStatus` shared one provider-usage slot per agent but asked for different provider sets. They evicted each other on every Models page load for 80 days, across 7 refactor passes, because no test interleaved the two callers.

## Evidence

I reviewed main since 2026-04-01: every `fix` commit whose diff touched cache-key, cache get/set or in-flight lines (728 commits). Each one was judged by reading its message and diff. **95 fixed a cache identity bug.** That is about 3 per week, steady every month (Apr 14, May 13, Jun 8, Jul 15, Aug 18, Sep 16, Oct 1–16 11).

| Kind | Count | Example |
|---|---|---|
| Key omits an input, so the answer is stale or wrong | 35 | ec1fe7a: markdown render cache ignored `codeBlockChrome` |
| Data leaks across agent, account or credential scope | 23 | 62706db: run→session lookup keyed by `runId` only; 61cfec6: GitHub previews shared across credentials; 07fdf40: cron deliveries routed to the wrong agent |
| Different callers collide or evict each other | 14 | c373547 (openclaw#174741); 6a9b2cb: route keys with separators collided |
| Key too volatile, so it never hits | 14 | 39dd2bb: prompt-cache key was the per-run session id |
| In-flight join dedups unrelated work | 9 | 5db8377: deep health probe joined a passive refresh; 153d5a8: dispatch joined a different `executionMode` |

23 of the 95 were data leaks across scopes, so this is a correctness and privacy issue, not only performance.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant