Skip to content

Follow-up to #594: session identity, anchor pairing and a few rule-matching edge cases #604

Backlog

Description

@caohy1988

Follow-up from the re-review of #594 at 28fb7ff (another merge of main into the branch). The rule_taxonomy code and tests are unchanged, the merge is clean, and the 203 tests in tests/test_rule_taxonomy.py pass at this head. Items already tracked in #602 aren't repeated here; these are new.

Two root agents sharing a thread id are treated as one session (important)

label_failed_session_rules (rule_taxonomy.py ~L512) only checks that all rows share a session_id before collecting tool results across them. trace.py (~L2198) defines a session by session_id, user_id and root_agent_name, and two root agents can legitimately reuse the same thread id. With two root agents on the same user and thread id, where only the first computed the reference value, the second gets FIN-SEEN-NOT-REPORTED anchored to the first agent's trace and call, instead of the documented ValueError for input that spans two sessions. Validating the full identity (with the same null-aware comparison the client uses) before deduplicating events would fix it, while still allowing several trace ids for one identity.

A built-in label can point to a trace/span pair that isn't in the input (important)

Pairing (~L1066) fills the span id and trace id independently. When a start row has a span id but no trace id, a name-matched end row can supply a trace id that belongs to a different span. Given (None, 'call-start') and ('trace', 'call-end'), the emitted TB-UNRECOVERED points at ('trace', 'call-start'), and joining on that pair finds no rows. Extension labels already go through a row-membership check (~L480); picking one native row as the anchor and copying both ids from it (keeping its nullable trace id) would give built-in labels the same guarantee.

Rule-matching edge cases

  • Profile-recognized tool failures don't count as the abort. Abort selection (~L570) looks at raw span fields, so a result that matches tool_error_pattern counts as a failed step but isn't considered as the terminal error. A plain TOOL_ERROR gets TB-ABORT; the equivalent profile-matched result gets no label.
  • List matching depends on order. At ~L1305 the matcher greedily consumes 1.4 as a match for integer 1, so [1, 1.4] in prose matches the reference but [1.4, 1] doesn't. A one-to-one, order-independent match would fix it when tolerances overlap.
  • Decimal list values lose precision. ~L1316 parses candidate decimals as binary floats before the exact comparison, so [9007199254740993.0] is reported as FIN-IN-ANSWER against [9007199254740992]. Keeping the original decimal tokens avoids that.
  • One undated row can change which answer is final. The ordering from span_taxonomy.py (~L419) is dropped entirely if any row lacks a timestamp, so the same rows in reverse order pick a different final answer. Keeping dated rows in chronological order and placing undated ones deterministically would make it stable.
  • TW-CALL-CAP evidence always says there was no final response. _rule_turn_waste (~L831) uses a fixed "...without a final response" string even when facts.final_response is set. Conditioning the wording on whether there is an answer would keep the evidence accurate.
  • Off-contract live-object inputs fail with bare exceptions. Rows whose content is a live mapping with mixed key types or cycles hit json.dumps(..., sort_keys=True) (~L592, ~L982) and raise a bare TypeError/ValueError; a bytes pattern in ToolProfile fails later at re.search. Stored JSON rows can't hit these, but validating up front would give callers the documented error surface.

PR: #594 (head 28fb7ff)

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