Skip to content

fix: cache already-read AGENTS.md contracts to stop re-read loops#32

Merged
m62624 merged 1 commit into
mainfrom
fix/contract-read-scan-cache
Jun 16, 2026
Merged

fix: cache already-read AGENTS.md contracts to stop re-read loops#32
m62624 merged 1 commit into
mainfrom
fix/contract-read-scan-cache

Conversation

@m62624

@m62624 m62624 commented Jun 16, 2026

Copy link
Copy Markdown
Owner
  • Decoded a stuck pi-session: a local model (qwen3.6-35b) re-routed to an already-fully-read AGENTS.md
    contract before each new source read. Because a completed planner_contract_read clears pendingRead,
    every re-read restarted the paginated dump from cursor 0 instead of recognizing it was already done —
    the model explicitly noticed it was looping yet kept repeating the same tool call until the session ran
    out.
  • planner_contract_read now serves the cached summary instead of re-reading when there's no
    in-progress pendingRead and no explicit cursor; pass cursor explicitly to force a real re-read.
  • planner_contract_scan had the same shape (status guidance tells the model to scan before every broad
    read) and now short-circuits once scanComplete is true, with a force: true escape hatch.

… scratch

Decoded a stuck pi-session: a local model (qwen3.6-35b) re-routed to an
already-fully-read AGENTS.md contract before each new source read, and
because a completed read clears pendingRead, planner_contract_read had
no way to recognize "already read" — it restarted the paginated dump
from cursor 0 every time. The model explicitly noticed it was looping
("I've been cycling too much") yet kept repeating the same tool call,
burning the rest of the session without ever calling
planner_discovery_submit.

planner_contract_read now serves the cached PlannerContractSummaryRecord
instead of re-reading when a path has no in-progress pendingRead and an
explicit cursor wasn't given; pass cursor explicitly to force a real
re-read. planner_contract_scan had the same shape (status guidance tells
the model to scan before every broad read) and now short-circuits once
scanComplete is true, with a force:true escape hatch for a real rescan.

Added contracts.test.ts coverage for both: the read case reproduces the
exact loop (drives a multi-page read to completion, then asserts a
re-read is served from cache, then asserts an explicit cursor still
forces a real re-read); the scan case asserts no re-walk after
completion and that force:true still does one.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the fix label Jun 16, 2026
@m62624 m62624 merged commit 1e64806 into main Jun 16, 2026
2 checks passed
@m62624 m62624 deleted the fix/contract-read-scan-cache branch June 16, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant