Skip to content

precheck_file misses most past failures: attempts without a location, the 30-day window, partial attempts #32

Closed

Description

@bigfree

precheck_file is the tool that should stop an agent from repeating a dead end, so I measured how often it actually shows the earlier failures for the file an agent is about to edit.

On one of my projects (two months old, 248 issues, ~3k events) I took every issue that has at least one failed or partial attempt and a location: 51 cases. For each one I asked: "an agent is about to edit this file; does projectmem show it what already failed there?"

Source Shows the earlier failures Tokens per question
precheck_file(<file>) 33.3% ~55
the whole summary.md 35.3% ~6,800

Most of precheck's 33% (15 of 17 hits) comes from the open-issue check printing the issue title, not from the failed-attempts check. Running only the failed-attempts check over the 51 cases, it would have shown the case's own failures for one of them.

A minimal reproduction:

log_issue("token refresh race", location="src/auth.py")      # 40 days ago
record_attempt("wrapped refresh in a lock", outcome="failed")  # 40 days ago, no location
record_attempt("retry halves the failures", outcome="partial") # 3 days ago, no location
record_fix("serialized refresh per user")
precheck_file("src/auth.py")
src/auth.py: no warnings. Safe to modify.

Where the misses come from (the other 50 cases):

Cause Cases
The attempts carry no location, so precheck never links them to the file. location is optional on record_attempt, and agents usually leave it out because the issue already has one. 30
The failures are older than RECENT_DAYS (30). A dead end two months ago is still a dead end while the file exists. 12
Only partial attempts in the window. Precheck counts failed only, although summary.md already treats partial attempts as lessons (L-027b). 8

What I'd suggest:

  1. An attempt (or fix) without its own location inherits its issue's file in _live_event_paths.
  2. Failed and partial attempts are lessons; partial ones get their own mark. The block severity still counts failed attempts only.
  3. Lessons are not subject to RECENT_DAYS. Churn, reverts and decisions keep the window, and the staleness check still flags memories whose file changed a lot.

The same reproduction then gives:

projectmem precheck: src/auth.py
  [WARN] What already failed here (2 attempts, 1 only partly worked):
    - ~ retry halves the failures (3d ago)
    - x wrapped refresh in a lock (1mo ago)

On the same 51 cases recall goes from 33.3% to 72.5%, at about 109 tokens per question, so about 1.6% of what the full summary costs. Nothing in events.jsonl changes. The existing tests pass, and I added tests for each of the three points.

Two smaller things on the same branch, happy to drop either:

  • precheck_files(file_paths) checks several files in one call and one analysis pass, for changes that touch more than one file.
  • When more than three lessons exist, the overflow line names the issues that hold the hidden ones (... and 2 more, from #0012 (get_issue(issue_id))) instead of pointing to pjm search --failed-only, which leaves partial attempts out.

Open questions:

  • Is dropping the window for lessons acceptable, or would you prefer a longer one (say 180 days) or a config.toml setting?
  • precheck_files as a separate tool, or a list parameter on precheck_file?
  • Should record_attempt also nudge agents to pass location when it differs from the issue's, or is inheritance enough?

The change is on bigfree:fix/precheck-lessons (two commits on top of main, diff). I can open a PR if this direction works for you.

Activity

  1. riponcm commented on Nov 20, 2026

    @riponcm
    Owner

    Shipped in 0.3.6, thank you. Attempts now inherit their issue's file, partial attempts count, and failed or partial lessons no longer expire. Churn and decisions keep the 30-day window.

    To your questions:

    • No window for lessons: a dead end stays a dead end.
    • precheck_files is a separate tool, as you built it.
    • Inheriting the issue's file is enough for now, so record_attempt doesn't nudge agents to pass location.

    I also checked it on a project created with 0.3.5: an old attempt logged without a location now shows up in precheck. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions