Skip to content

Follow-up for #594 at 1c16472e: error rows, cross-invocation pairing, and a dropped changelog entry #602

Backlog

Description

@caohy1988

Follow-up from the re-review of #594 at 1c16472 (the merge of main into the branch). The rule_taxonomy code and tests are unchanged from 6334217, the merge with the trace changes on main is clean, and the 203 tests in tests/test_rule_taxonomy.py pass at this head. The items still open from #600 (answers that do report the reference, failed-tool text read as printed output, AGENT_RESPONSE answers) reproduce the same way and are not repeated here. These are new. The first three are the important ones.

Error rows can read as a successful completion or tool outcome

Error detection looks only at status, not at a populated error_message, which trace.py (~L345) treats as enough on its own. It also checks for errors only after the last AGENT_COMPLETED and skips the terminal row itself (rule_taxonomy.py ~L646, ~L670, ~L1062). On the SDK's own seeded corpus (seed_events.py ~L406 writes failed terminal rows), all 10 terminal timeouts come out as completed=True with FIN-NO-ANSWER on the preceding tool span, where TB-ABORT on the timeout span is expected. A tool end that carries only error_message is recorded as OK and never produces TB-UNRECOVERED. Using the same error check as the SDK on terminal rows, tool ends and progress checks would fix this.

Name-fallback pairing can attach a result to an earlier invocation

When span ids don't pair, _pair_tool_calls (~L1035) searches session-wide starts by tool name. If the first invocation left a call open, a successful end in the second invocation pairs with that stale start and keeps the earlier invocation id (~L1068), so the current call looks unfinished and becomes the primary TB-UNRECOVERED. This happens with shared or distinct trace ids, and with a NULL or fresh end span id. Excluding starts whose known invocation or trace id conflicts would keep the fallback for writers without usable ids.

A reused span can drop a distinct tool error

Once every start on a span has paired, a later end row on that span is dropped (~L1024), even a TOOL_ERROR from a different tool with its own event id and timestamp. A successful preview followed by an export error on the same span gives steps [('preview', 'OK')] and no labels, where TB-UNRECOVERED on the export is expected. Dedupe only the terminal events already seen, and keep a distinct end as a start-less call.

Smaller items

  • The merge dropped the changelog entry. CHANGELOG.md at this head matches main, so the Unreleased entry for label_failed_session_rules from 6334217 is gone and the PR diff no longer touches the changelog.
  • Rows without invocation_id drop out of the run. Once an invocation id repeats, _last_invocation (~L678) scopes run facts to rows with that id. A model row with invocation_id=None that carries the answer is ignored, and the session gets FIN-NO-ANSWER at 0.85. The tracing logger defaults that field to None. Either place id-less rows by position or document the requirement, and add a mixed-id test.
  • A recovered call cap hides a later error. The limit check (~L546) searches the whole invocation. After a cap, a resumed attempt with a successful lookup and then a permission error is labeled TW-CALL-CAP on the lookup.
  • Clipped arguments create false evidence. Exact-repeat detection (~L592) and the "source never read" check (~L906) both trust truncated start rows. Seven distinct queries clipped to the same prefix count as six repeats and fire TW-THRASH, and clipping the line that opens the file triggers IE-PASTED-PREVIEW at 0.85.
  • Malformed latency_ms or content_parts raise AttributeError. Span.from_bigquery_row calls .get on a decoded latency_ms and on each part without checking that it's a mapping (trace.py ~L277, ~L291), so a row with content_parts=["x"] or latency_ms="[1,2]" aborts the whole call instead of raising the documented ValueError. This is older trace code that the new module inherits.
  • Quadratic scans. Name fallback rescans already-paired starts (2,080 candidate visits for 64 calls, 8,256 for 128), and near-duplicate purpose comparison grows about 4x per doubling (0.73s at 2,000 calls). Neither matters for normal sessions, but both are cheap to bound by consuming matched starts in order and indexing purposes.
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