Skip to content

Follow-up for #594: finalization and other rule_taxonomy edge cases #600

Backlog

Description

@caohy1988

Follow-up from the re-review of #594 at 6334217. The previously requested pairing, abort-anchor, completion-scoping, Decimal matching, start-less ends, truncation, and checks validation fixes look good, and the 203 tests in tests/test_rule_taxonomy.py pass at that head. These remaining items can wait for a later PR. The first four are the important ones.

Finalization: FIN-SEEN-NOT-REPORTED on answers that do report the value

If a compute tool has already printed the reference, _rule_finalization returns FIN-SEEN-NOT-REPORTED without checking that the final response already contains it. It relies on FIN-IN-ANSWER having fired first, but _answer_contains_reference is narrower: for numbers it only accepts a bare number or prose whose last number is the reference, and for strings only an equal, line-equal, or tail match.

A session whose compute step prints mean = 812.45 and whose final response is any of:

  • The mean is 812.45 mm at 3 stations
  • 812.45 mm (2024 data)
  • Mean: 812.45, from 12 files

is labeled FIN-SEEN-NOT-REPORTED at 0.75, with evidence that quotes the final response that already contains 812.45. The same happens for a string reference: tool output city: Boston and answer Boston is the city, population 650000 with reference Boston. The committed case at tests/test_rule_taxonomy.py (around the "812.45 mm at 3 stations" row) only checks FIN-IN-ANSWER in isolation, without a compute output that also contains the reference.

A natural fix is to suppress FIN-SEEN-NOT-REPORTED when the final response itself contains a distinctive rendering of the reference (the same test used on tool output, including the short-count guard), or to widen FIN-IN-ANSWER to cover any distinctive occurrence that is not a count.

Answers delivered on AGENT_RESPONSE are ignored

The rules take the answer text from Trace.final_response, which reads LLM_RESPONSE and AGENT_COMPLETED. A completed run whose text was delivered on AGENT_RESPONSE (for example after a final-response callback, or through a configured final-answer tool) has final_response is None and is labeled FIN-NO-ANSWER at 0.85. In the other direction, if an LLM_RESPONSE still contains 812.45 and a later AGENT_RESPONSE replaced it with 790.1, the rule still reports FIN-IN-ANSWER at 0.9 for reference 812.45. Worth resolving the last visible agent response for the selected invocation, including delivered-response fields, and keeping the existing fallback for writers that lack that event.

Failed-tool diagnostics are treated as printed output

When a TOOL_ERROR has no result, the diagnostic is copied into ToolStep.result and then searched as if it were output printed by the computation. A failed request with HTTP 404: file not found, a successful retry returning no rows, a final answer of unknown, and reference 404 is labeled FIN-SEEN-NOT-REPORTED at 0.75 on the failed request. Failure diagnostics should stay distinct from observed result data.

Short counts in prose that the current guard misses

The adjacent-preposition guard correctly rejects 812.6, computed over 3 files as a match for reference 3. These nearby phrasings still produce FIN-IN-ANSWER at 0.9 for reference 3, even though 3 is a sample count and the agent's value is 812.6:

  • 812.6 (sample size n=3)
  • 812.6, computed over the 3 files
  • 812.6 from the 3 files
  • 812.6 (n=3)
  • the total is 812.6 computed over **3** files

Allowing an optional article between the preposition and the count, and treating a parenthetical n= as a count, would close the gap.

Other residuals worth checking in the same pass

  • Tool-name fallback can pair across invocations when a span does not match, and a reused span can drop a later distinct end once earlier starts on that span have paired.
  • Completion and abort still have edge cases: an old INVOCATION_* terminal after a later INVOCATION_STARTING on the same id, a silent parent after a child completes, a model LLM_RESPONSE whose failure is only in error_message with status OK, and a completed tool result that matches tool_error_pattern but is never admitted as an abort error.
  • Rows with a NULL invocation_id can fall out of the last-invocation run once any invocation id is present.
  • One spanless anchor currently raises and discards every other label, rather than failing only that rule closed.
  • Absent or redacted tool arguments collapse to an empty signature, so several redacted calls can look like exact repeats (TW-THRASH), and a withheld tool name can look like preview-only work.
  • Near-duplicate waste currently compares purpose text without requiring the same tool or overlapping path/code arguments, so generic purposes such as "preview the data file" on different files can inflate thrash.
  • Profile regexes have no runtime bound on long tool output, and a bytes pattern is accepted at construction then raises TypeError at first use.

No change requested on this issue before #594 merges; these are follow-ups.

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions