Skip to content

final_response: taxonomy run scoping, SQL tie ordering and wrapper parity (follow-up to #601) #605

Backlog

Description

@caohy1988

Follow-up from the review of #601 at 0e8e53b (merged). These are in addition to the findings already tracked from the earlier review.

  1. The taxonomy can credit a child agent's answer to its parent. rule_taxonomy.py:526-543 narrows the session to the latest raw invocation ID before calling trace.final_response, which can drop the parent rows. The parent-presence check at trace.py:442 then treats the child as a standalone run. Now that AGENT_RESPONSE counts as an answer event, this shows up even when the child produced no LLM_RESPONSE. Example: the parent makes a tool call and "The count is 42." appears only in the child's AGENT_RESPONSE. The full trace returns None, but with reference answer 42 the taxonomy moves from FIN-NO-ANSWER at the merge base to FIN-IN-ANSWER. Resolving the run from the full session before narrowing the facts would fix it.
  2. SQL ordering ties with the Python reader. When invocation IDs can't group rows, trace.py:714 uses timestamp > last_user_message. An ID-less answer at the same timestamp as the user message (span 002 after 001) is kept by the Python path and dropped by SQL, which returns NULL. The base kept it. Separately, the recency windows at trace.py:722-723 order by timestamp only, so two tied model turns can resolve to different rows than client.py:432 picks. Assigning a row position that follows the SDK's event order would fix both. Changing > to >= alone would admit answers that come before the message.
  3. A non-string summary can override a real answer in SQL. JSON_VALUE at trace.py:588 turns JSON booleans and numbers into text, and line 614 gives that text priority on AGENT_RESPONSE. Python only promotes string summaries (line 309). With an answer of "Ready" and a summary of false, Python returns "Ready" and SQL returns "false".
  4. The legacy double-quoted text wrapper isn't recognized. trace.py:168 and the SQL call pattern at line 507 only handle the single-quoted opener. For text: "Checking." | call: search, both paths now return text that includes the tool call. The merge base returned None. The SQL strip at line 626 also leaves the double-quoted prefix in place where Python removes it.
  5. The parser cache can hold large bodies. The cache at trace.py:255 is bounded by entry count only and keeps both the raw key and the extracted text. 256 distinct 64 KiB answers left about 32 MiB allocated after the traces were released. Skipping the cache for large inputs or capping retained bytes would fix this.
  6. Small cleanup: tests/test_final_response_sql.py:126 still registers a LEFT shim. Removing it would make a reintroduced LEFT( fail on newer SQLite builds too.

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