Skip to content

feat(B): superseded-context detector + ts_stale_context (agent-agnostic) - #111

Merged
Mibayy merged 3 commits into
mainfrom
feat/superseded-detector
Jul 28, 2026
Merged

feat(B): superseded-context detector + ts_stale_context (agent-agnostic)#111
Mibayy merged 3 commits into
mainfrom
feat/superseded-detector

Conversation

@Mibayy

@Mibayy Mibayy commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Feature B, cross-agent core. Reclaims context wasted on tool results that a later action made obsolete.

Detector (discover/superseded.py::find_superseded) — a pure function over the transcript Events any harness produces. Flags, per session: a file read then re-read, a file read then edited (the read is stale), a Bash command re-run. Names the stale + fresh event so a caller can drop the stale content or point to the fresh copy. Deterministic, no model.

Universal delivery (ts_stale_context MCP tool) — scans the recent session transcript(s), runs the detector, returns the stale refs as a table or JSON. Works on any MCP client, not just Claude Code — this is the cross-agent path. The Claude-only PreCompact hook (which can actually prune at compaction) is a follow-up bonus; everywhere else the tool is advisory, because an MCP server cannot delete context it does not own.

Design note: the durable cross-agent prevention is the pointer-returning tools (get_full_context intent, capture relevant: — already merged in #110). This B tool cleans up what slipped through.

Tests: detector (reread / read-then-edit / rerun / mcp-prefix / cross-session isolation / determinism) + tool formatting + handler smoke over real transcripts. ruff clean, tool count 69->70, protocol end-to-end green.

Mibayy and others added 3 commits July 28, 2026 19:12
Pure function over transcript Events (any harness): flags tool results made
obsolete later in the same session — a file read then re-read, a file read
then edited, a Bash command re-run. Names the stale + fresh event so a caller
can drop the stale content or point to the fresh copy.

Delivery (follow-up): a callable MCP tool (works on every agent) + a Claude
Code PreCompact hook. This module stays pure/harness-free by design.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Exposes find_superseded as an agent-agnostic MCP tool: scans the recent
session transcript(s), lists tool results made obsolete later in the same
session (reread / read-then-edit / rerun), and returns the stale refs so the
agent can drop that content or refetch the fresh copy. Works on any MCP
client — this is B's cross-agent path (the PreCompact hook is a Claude-only
bonus, still to wire). META handler, read-only, PII-safe. Tool count 69 -> 70.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The all-tools coverage guard requires every TOOL_SCHEMAS entry to appear in
ARGUMENTS_REALISTES. Add ts_stale_context ({} — all params optional).
@Mibayy
Mibayy merged commit b781cf1 into main Jul 28, 2026
3 checks passed
@Mibayy
Mibayy deleted the feat/superseded-detector branch July 28, 2026 17:32
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