Skip to content

fix(rule_taxonomy): treat rows with an error_message as errors - #618

Merged
caohy1988 merged 1 commit into
GoogleCloudPlatform:mainfrom
leninworld:fix/602-error-rows
Nov 29, 2026
Merged

caohy1988 merged 1 commit into
GoogleCloudPlatform:mainfrom
leninworld:fix/602-error-rows

Conversation

@leninworld

Copy link
Copy Markdown
Contributor

This PR addresses part of issue #602.

Summary

Part of #602: the first item, "Error rows can read as a successful completion or tool outcome". The other items in that issue are not changed.

rule_taxonomy decided whether a row failed from status and an _ERROR event type only, while Span.has_error also counts a populated error_message. On the decision-realistic seeded corpus, the 10 failed sessions read as completed=True and got FIN-NO-ANSWER.

What changed

  • One error check, used for terminal rows, the LLM_RESPONSE progress check, the abort row and tool-end status: status == "ERROR", an _ERROR event type, or an error_message.
  • The terminal row itself now counts: an AGENT_COMPLETED or INVOCATION_COMPLETED that carries an error does not complete the run. When invocation rows exist, the last one still decides.
  • A missing error_message that arrives from a DataFrame as NaN or NaT is not an error. As elsewhere in the SDK's text handling, a blank, "null" or "nan" string is treated as missing.
  • Evidence text: TB-UNRECOVERED shows the error message of a failed TOOL_COMPLETED that also has a result, and TB-ABORT on a non-_ERROR row says the row "logged an error that stopped the run". The wording for _ERROR rows is unchanged.
  • CHANGELOG entry.

Behaviour on the seeded corpus

build_realistic_corpus(random.Random(0), ..., 100), the 10 sessions with an error_message:

completed labels
main True FIN-NO-ANSWER
this PR False TB-ABORT

Limits (not changed here)

  • The retail-returns seed corpus writes an errored AGENT_COMPLETED followed by a clean INVOCATION_COMPLETED. Those sessions still read as completed, because the last invocation row decides.
  • status is still compared case-sensitively, as Span.has_error does. The lowercase status="error" seeded rows are caught through their error_message.

Testing

  • pytest tests/test_rule_taxonomy.py: 211 passed. With the new tests and the old source, 7 fail.
  • pyink --check and isort --check-only on src and tests: clean.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — the shared error check is the right fix for the first item in #602.

I ran the taxonomy tests at this head (211 passed) and the same new tests against the previous source (7 failed). I also reproduced the seeded-corpus claim: on build_realistic_corpus(random.Random(0), ..., 100), the 10 sessions with an error_message go from completed=True / FIN-NO-ANSWER to completed=False / TB-ABORT. The last-invocation and case-sensitive status limits you called out still hold, and a missing error_message (including NaN and the "null" / "nan" forms) is not treated as an error.

A few follow-ups, none of them blocking this change:

  1. When status arrives as a pandas nullable NA (for example after reading a DataFrame with a nullable string column via itertuples()), the new shared error check can raise TypeError: boolean value of NA is ambiguous on a clean AGENT_COMPLETED or INVOCATION_COMPLETED, and also on a TOOL_ERROR that used to be recognized from the event type alone. The comparison is span.status == "ERROR" first; pd.NA == "ERROR" is pd.NA, and or then tries to use that as a boolean. A guard like isinstance(span.status, str) and span.status == "ERROR" would keep the case-sensitive check and still let the event type or message decide when status is missing. The committed tests didn't catch this because their missing-value fixtures keep a populated status.

  2. The changelog can read as if an error_message alone always produces TB-UNRECOVERED. In the code, that label still needs a completed run whose final tool call failed; a later successful retry clears it, and a deciding terminal error is TB-ABORT.

  3. Non-string error_message values such as 0 or False get stringified and treated as real errors. That's only an issue for a malformed column, not ordinary BigQuery STRING nulls.

I filed these as #619.

Thanks for the fix! If you've found the SDK useful, it'd mean a lot if you could give the repo a star.

@caohy1988
caohy1988 merged commit d5b0b92 into GoogleCloudPlatform:main Nov 29, 2026
16 checks passed
@leninworld

Copy link
Copy Markdown
Contributor Author

Thanks for this — the shared error check is the right fix for the first item in #602.

I ran the taxonomy tests at this head (211 passed) and the same new tests against the previous source (7 failed). I also reproduced the seeded-corpus claim: on build_realistic_corpus(random.Random(0), ..., 100), the 10 sessions with an error_message go from completed=True / FIN-NO-ANSWER to completed=False / TB-ABORT. The last-invocation and case-sensitive status limits you called out still hold, and a missing error_message (including NaN and the "null" / "nan" forms) is not treated as an error.

A few follow-ups, none of them blocking this change:

  1. When status arrives as a pandas nullable NA (for example after reading a DataFrame with a nullable string column via itertuples()), the new shared error check can raise TypeError: boolean value of NA is ambiguous on a clean AGENT_COMPLETED or INVOCATION_COMPLETED, and also on a TOOL_ERROR that used to be recognized from the event type alone. The comparison is span.status == "ERROR" first; pd.NA == "ERROR" is pd.NA, and or then tries to use that as a boolean. A guard like isinstance(span.status, str) and span.status == "ERROR" would keep the case-sensitive check and still let the event type or message decide when status is missing. The committed tests didn't catch this because their missing-value fixtures keep a populated status.

  2. The changelog can read as if an error_message alone always produces TB-UNRECOVERED. In the code, that label still needs a completed run whose final tool call failed; a later successful retry clears it, and a deciding terminal error is TB-ABORT.

  3. Non-string error_message values such as 0 or False get stringified and treated as real errors. That's only an issue for a malformed column, not ordinary BigQuery STRING nulls.

I filed these as #619.

Thanks for the fix! If you've found the SDK useful, it'd mean a lot if you could give the repo a star.

Thank you @caohy1988

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

Labels

None yet

2 participants