aft icon indicating copy to clipboard operation
aft copied to clipboard

Repeat breaker omits aft_search.pattern, conflating different searches and issuing false stop instructions

Open chpock opened this issue 1 month ago • 1 comments

What happened?

The repeat breaker treats different aft_search calls as the same request because its semantic key omits pattern, even though pattern determines what the tool searches for. This can produce false loop warnings and, on escalation, an instruction to end an otherwise productive turn.

Confirmed by source inspection in v0.63.5 and still present on main at 7ca30b526163a62bc0756e49238ab689eb46969f. No local AFT patch or new live replay was performed for this report.

Minimal input pair and expected behavior

These are two actual search predicates from a Pi session; the common local file path has been sanitized:

{"pattern":"filePreviewState.observe","path":"/repo/src/index.ts"}
{"pattern":"function filePresentationTool|filePresentationTool =","path":"/repo/src/index.ts"}

They are different searches and should have different repeat identities. However, semantic_key("aft_search", input) reduces both inputs to:

{"path":"/repo/src/index.ts"}

This is deterministic loss of a behavior-defining argument before hashing, not a coincidental hash collision. It also affects calls with the same natural-language query and options but different pattern values.

The key comparison above is established by source inspection; a fresh unit-test or end-to-end reproduction was not run.

Source mechanism

  1. repeat_breaker.rs:237–288 selects these fields for aft_search:

    "aft_search" => select_fields(input, &["query", "path", "topK", "offset", "includeTests"]),
    

    pattern is missing. In contrast, the adjacent grep key includes it.

  2. tool_gate.rs:36–61 canonicalizes the adapter's search call to aft_search. run_tool_call.rs:650–709,726–739 constructs the repeat observation from the caller's arguments before translating the request, so this key is on the actual tool execution path.

  3. repeat_breaker.rs:138–200 counts equal keys even when outputs differ. Changing results only change the wording to “output is drifting”; they do not prevent intervention.

  4. response_finalize.rs:22–72 escalates at six observations for a non-worker session to “The turn must end now with no further tool call.” This is a model-facing instruction, not a forced tool cancellation.

Observed impact and limits

In the Pi journal on 2026-11-03:

  • 18:25:56 UTC: the first search above.

  • 18:28:20 UTC: the second search above, with a different pattern but the same file path.

  • 18:28:21 UTC: its result contains the following reminder in both the model-facing text and details.text:

    This is the 6th call with the same arguments in 145s. The call is being repeated
    with the same arguments while its output is drifting (for example, because it
    includes a timestamp). The turn must end now with no further tool call.
    
  • 18:28:37 UTC: the agent ends its turn with a local final answer saying its changes are still unverified and tests are the next step. It does not send the expected checkpoint to its coordinating peer, so the two independent sessions remain idle.

The stop instruction is a plausible trigger for the premature finish, not proof of the model's internal reason for stopping. The session was an independent Pi peer named “Worker,” not a managed child; its name alone does not imply worker_session=true.

Separate unresolved detail: the reminder reports six occurrences, while the journal shows only two visible searches with the matching key in that 145-second interval. Omitting pattern proves those different searches collide, but does not by itself explain the count of six. No transport-retry or hidden-call mechanism is asserted here. The key defect can be assessed independently of that counter discrepancy.

Suggested correction and regression coverage

Include pattern in the aft_search repeat identity. Suggested behavioral coverage:

  • Different patterns with the same path/options do not accumulate as repetitions of one request, both with no query and with an identical query.
  • Repeating an actually identical search still produces the existing warning/escalation after the required count and time span.
  • Changing only nonsemantic metadata such as description does not defeat repetition detection.

Diagnostics

  • Installed Pi adapter: @cortexkit/aft-pi 0.63.5.
  • Host: Pi 1.4.0, Linux x64, Node 26.12.1.
  • Source versions checked: v0.63.5 and the pinned main commit linked above.
  • The exact running daemon binary's byte identity against those source revisions was not independently verified in this investigation.
  • Evidence: persisted Pi tool-call/result records plus source inspection; no model replay, debugger attachment, process restart, or code modification.

Related issue checked

#347 concerns counting both preview and apply for mutating tools and is marked fixed in v0.58.0. This report concerns omitted aft_search.pattern on read-only calls, not that preview/apply mechanism. I found no existing issue for the missing-pattern identity after checking open and closed issue titles/bodies and targeted comment searches.

chpock avatar Nov 03 '26 18:11 chpock

Confirmed: aft_search still omits pattern from its repeat identity, so different patterns on the same path can be grouped together. The permission-retry overcount in #1368 is an additional, independent problem. This identity bug remains open.

aft-alfonso[bot] avatar Nov 11 '26 19:11 aft-alfonso[bot]