Skip to content

feat(agentanalytics): add pre-built agent evaluation views (v_eval_session, v_eval_turn) - #2175

Merged
wolo-lab merged 7 commits into
google:mainfrom
haiyuan-eng-google:feat/bqaa-2014-v1-eval-views
Nov 19, 2026
Merged

wolo-lab merged 7 commits into
google:mainfrom
haiyuan-eng-google:feat/bqaa-2014-v1-eval-views

Conversation

@haiyuan-eng-google

@haiyuan-eng-google haiyuan-eng-google commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue

Summary

Adds opt-in pre-built BigQuery evaluation views (<ViewPrefix>_eval_session and <ViewPrefix>_eval_turn, defaulting to v_eval_session and v_eval_turn) to plugin/agentanalytics, reconstructing multi-turn session and single-turn AgentData evaluation trajectories, agent_configs maps, token usage rollups, error flags, and consecutive identical tool-call loop detection directly from the BigQuery agent_events table.

Public API & Configuration

  • Config.CreateEvalViews bool (opt-in, default false): when enabled on an active plugin with a non-nil bqClient, creates/replaces <ViewPrefix>_eval_session and <ViewPrefix>_eval_turn asynchronously during startup (independently of DisableCreateViews, so standalone evaluation-view startup with CreateEvalViews: true, DisableCreateViews: true creates only the 2 evaluation views) and includes them in SyncViews(ctx) (with per-group validation isolation so valid per-event or evaluation views still sync and return joined errors if the other group fails validation). Its doc lists the content keys that a custom ContentFormatter must keep for the views.
  • (Config).EvalViewDefinitions() ([]ViewDefinition, error): deterministically renders the two CREATE OR REPLACE VIEW statements without requiring live clients, validating project/dataset/table/prefix identifiers, view-name length (<= 1024 bytes), and case-insensitive collisions with the events table.
  • (*BigQueryAgentAnalyticsPlugin).SyncEvalViews(ctx context.Context) error: synchronously creates or replaces only the two evaluation views (even when CreateEvalViews is false), validating configuration and view definitions before preempting any in-flight startup pass and coordinating with Close() and SyncViews(ctx) via the view gate.

Denylist & Event-Filter Validation

  • PayloadColumnDenylist projection: projects typed NULL / empty-array stand-ins in raw_events when optional payload columns content_parts, attributes, or latency_ms are listed in PayloadColumnDenylist. Rejects CreateEvalViews, EvalViewDefinitions, and SyncEvalViews when content is denied (required for AgentData trace reconstruction); unsupported column names remain rejected by PayloadColumnDenylist validation.
  • EventDenylist / EventAllowlist validation: rejects CreateEvalViews and SyncEvalViews when any of the 15 required trajectory/HITL/completion event types would be dropped by runtime emitters — accounting for "EVENT" in EventDenylist suppressing the 9 session-level events plus resumed-tool TOOL_COMPLETED, and "EVENT" in EventAllowlist covering the 8 pure session/HITL/pause events unconditionally while covering AGENT_RESPONSE only when FinalResponseToolNames is empty (since final-response tools emit AGENT_RESPONSE through logEvent).

Semantic Hardenings Beyond adk-python v2.13.0

While preserving the v_eval_session (21 columns) and v_eval_turn (22 columns) output schemas and AgentData JSON contract from adk-python v2.13.0, the Go view SQL includes three semantic hardenings:

  1. Composite (app_name, user_id, session_id) session scoping & NULL-safe joins: partitions and groups turn rollups, turn indices (turn_index), HITL pause/resume windows (LAG(is_paused) / LEAD(has_function_response)), session rollups, and agent_configs maps by (session_id, user_id, app_name) (from attributes.adk.app_name, with invocation-level backfill when a fallback row omits user_id or adk.app_name), using IS NOT DISTINCT FROM join predicates so NULL user_id or "attributes"-denied NULL app_name rows preserve trace.agents. When "attributes" is in PayloadColumnDenylist, session scoping falls back to (user_id, session_id).
  2. Storage Write retry deduplication on non-empty event_id: deduplicates retried rows sharing a non-empty event_id in deduped_events before windowing, token/tool/error aggregation, and trace construction, preserving all rows with NULL or empty event_id and preferring non-[FORMATTER_FAILED], non-[UPLOAD FAILED], GCS_REFERENCE, and non-truncated copies.
  3. Structured content_parts-first USER_MESSAGE_RECEIVED & AGENT_RESPONSE text reconstruction (excluding [FORMATTER_FAILED] scalar sentinels): whenever content_parts is non-empty, reconstructs USER_MESSAGE_RECEIVED message_text and AGENT_RESPONSE response_text from ordered non-attributed text/plain parts (excluding '', '[BINARY DATA]', '[MEDIA OFFLOADED]', and '[UPLOAD FAILED]', joined with \n by part_index), avoiding false delimiter rejection or splitting when literal response text contains ' | call: ', ' | resp: ', ' | other', or "' | text: '". User text comes only from INLINE parts, as in adk-python: a text part offloaded to Cloud Storage (GCS_REFERENCE) holds only a 200-rune preview, and a message with such a part has no user text at all (stricter than adk-python, which keeps the message's other inline parts), so its turn is not eval_ready. Response text also reads GCS_REFERENCE text parts, which only another writer sharing the table produces: this plugin writes AGENT_RESPONSE parts inline, cut at MaxContentLen with is_truncated set. When content_parts is empty (FinalResponseToolNames, LogMultiModalContent: false, custom ContentFormatter, or content_parts in PayloadColumnDenylist), the views fall back to content.text_summary / content.response and to non-sentinel scalar output, excluding root scalar "[FORMATTER_FAILED]" on both USER_MESSAGE_RECEIVED and AGENT_STARTING, so failed user-message formatters evaluate eval_ready = false and failed AGENT_STARTING formatters fall through to static_instruction.

Behavior change

  • Additive opt-in API (Config.CreateEvalViews, Config.EvalViewDefinitions, (*BigQueryAgentAnalyticsPlugin).SyncEvalViews).
  • Backtick-quoted BigQuery table/view identifier validation (isValidTableName) now accepts non-ASCII space separators (Zs), combining marks (M*), and non-decimal Unicode numbers (Nl/No, such as tbl² or tblⅫ), which also allows standard per-event view creation to proceed for such table names when CreateEvalViews is false.
  • SyncViews changes for every caller, including with CreateEvalViews=false: when Close lands after every view DDL has succeeded, it now returns the agentanalytics: plugin is closed error where it returned nil before, and a view-definition validation error now comes back wrapped by errors.Join even when it is the only error (the message is unchanged, and errors.Is and errors.As still match it).

Testing Plan

  • go build, go vet, gofmt, go mod tidy -diff, golangci-lint v2.15.0, and .github/scripts/apidiff.sh (no incompatible changes) on a clean git archive checkout in a go work workspace like CI's.
  • The full plugin/agentanalytics test suite, once without -race and once with -race -shuffle=on.
  • Not verified: the view DDL has not been run against BigQuery, and none of the checks above parses it as GoogleSQL (nothing in CI does either). TestEvalViews_SemanticExecution runs the generated SQL through a SQLite translation of it (the test needs python3 and SQLite 3.25 or later, and skips otherwise) over rows written through the plugin's own callbacks, and the length and SHA-256 pins catch any change to the generated SQL text.
  • Tests that fail if any semantic hardening or lifecycle isolation is reverted (plugin/agentanalytics/views_test.go):
    • TestEvalViews_SemanticExecution/cross_user_and_cross_app_session_isolation_and_pause_windows and null_app_name_and_null_user_id_join_preserves_agent_configs fail if (session_id, user_id, app_name) scoping or IS NOT DISTINCT FROM joins are reverted.
    • TestEvalViews_SemanticExecution/deduplicates_retried_event_id_and_preserves_empty_event_id_and_prefers_clean_copy fails if deduped_events retry deduplication or clean-copy tie-breaking is removed.
    • TestEvalViews_SemanticExecution/agent_response_reconstructs_from_content_parts_and_preserves_fallbacks fails if content_parts-first AGENT_RESPONSE text reconstruction is removed.
    • TestEvalViews_SemanticExecution/user_message_needs_whole_inline_text_and_skips_media_offloaded fails if the user text selector reads offloaded GCS_REFERENCE previews again, if a message keeps its inline parts when another text part was offloaded, or if an offloaded media placeholder holds back the inline text beside it. Its end-to-end case goes through the plugin callbacks with a fake offloader and the default MaxInlineTextSize: a prompt longer than 32 KiB whose question sits past the 200-rune preview is not eval_ready in either view, on its own or as the second part of a two-part message, while the same prompt stored inline is ready with its whole text.
    • TestViewAndEvalViewDefinitions_TableNameUnicodeAndControlChars/accept_Unicode_No_superscript_two and accept_Unicode_Nl_Roman_numeral_twelve fail if isValidTableName accepts only decimal digits (unicode.IsDigit) instead of any Unicode number.
    • TestCreateEvalViews_StartupAndSyncLifecycle/SyncViews_isolates_per-event_and_eval_failures_so_valid_view_groups_still_sync_and_return_joined_errors fails if SyncViews per-group error isolation is removed.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

Thanks for the PR, @haiyuan-eng-google.

One thing before review. Our contribution guide asks for an issue behind each change, and I could not find one linked here.

  • If an issue already exists, add Closes: #<number> or Related: #<number> to the description.
  • If not, open one — the link prefills the bug template with your PR title — then reference it the same way.

If this is a small doc or typo fix, ignore me. A maintainer can open the issue for you if you would rather.

caohy1988

This comment was marked as outdated.

@haiyuan-eng-google
haiyuan-eng-google force-pushed the feat/bqaa-2014-v1-eval-views branch from 3265e87 to a01179f Compare November 7, 2026 02:31
…ssion, v_eval_turn)

Add Config.CreateEvalViews, Config.EvalViewDefinitions(), and
BigQueryAgentAnalyticsPlugin.SyncEvalViews(ctx) to create and synchronize
the pre-built v_eval_session and v_eval_turn BigQuery evaluation views:

- Reconstruct multi-turn session and single-turn AgentData trajectories,
  agent_configs maps, token usage rollups, error flags, and consecutive
  identical tool-call loop detection from the events table.
- Scope session and turn rollups, window partitions, and agent_configs
  maps by ADK's composite session identity (app_name from attributes
  $.adk.app_name, user_id, session_id) with invocation-level backfill and
  NULL-safe IS NOT DISTINCT FROM joins.
- Deduplicate retried Storage Write API rows sharing a non-empty event_id
  before trace reconstruction and metric aggregation while preserving rows
  with empty or NULL event_id and preferring complete, non-failed copies.
- Reconstruct AGENT_RESPONSE response_text from ordered plain-text
  content_parts before falling back to formatted content.response when
  content_parts is empty or omitted.
- Project typed NULL fallbacks in raw_events when content_parts,
  attributes, or latency_ms are listed in PayloadColumnDenylist, and
  reject CreateEvalViews / SyncEvalViews when content or required trace
  events are excluded.
- Honor Config.ViewPrefix, identifier validation, table-collision checks,
  and Close() / SyncViews() view-gate preemption.
@haiyuan-eng-google
haiyuan-eng-google force-pushed the feat/bqaa-2014-v1-eval-views branch from a01179f to 58c0070 Compare November 7, 2026 03:17

@wolo-lab wolo-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One thing must change before merge: the eval-view validator accepts a filter configuration under which the views can never mark a final-response-tool turn complete, and nothing tells the user.

Must change before merge: the "EVENT" alias does not cover the AGENT_RESPONSE row that a final-response tool writes

validateEvalViewConfig treats the legacy "EVENT" allowlist alias as covering AGENT_RESPONSE (views.go lines 370 to 380 and 405 to 419). That holds for the AGENT_RESPONSE row of a final model event, which goes through logSessionEvent. It does not hold when FinalResponseToolNames is set: the AGENT_RESPONSE row for the tool is written by afterTool through logEvent, and shouldLogEvent has no alias handling, so the row is dropped. The umbrella allowlist that the new test accepts at views_test.go lines 4072 to 4085, plus FinalResponseToolNames, therefore passes construction and SyncEvalViews, and every turn whose only AGENT_RESPONSE comes from the tool has no such row. By the view SQL that turn gets is_complete = false and eval_ready = false, the session view's eval_ready goes false with it, and the final response is missing from trace. No error, no log. The doc at config.go lines 491 to 493 promises a configuration error for exactly this.

The runtime asymmetry itself predates this PR and is pinned by the existing events_test.go cases around lines 920 to 945. What this PR adds is the validator's claim that the alias is enough, and adk-python requires every event by name. Whichever side you fix, the property to keep is: for each of the 15 required event types, the config-time accept or reject decision matches what every emitter of that type does at runtime under the same allowlist, denylist and FinalResponseToolNames, with CreateEvalViews=false behavior unchanged. A test that writes rows under the umbrella allowlist with a final-response tool would pin it. Two of the inline notes below (the alias-set comment and the denylist error message) are side effects of the same mismatch.

Reproduction. Drop into package agentanalytics and run go test -run TestRepro_Umbrella -v ./plugin/agentanalytics/
func TestRepro_UmbrellaAllowlistDropsFinalResponseAgentResponse(t *testing.T) {
	umbrella := []string{"EVENT", EventAgentStarting, EventInvocationCompleted, EventLLMRequest, EventToolCompleted, EventToolStarting, EventUserMessageReceived}
	run := func(t *testing.T, allowlist []string) (types []string) {
		p, requests, mCtx := setupTestPluginWithConfig(t, func(c *Config) {
			c.DisableCreateViews = true
			c.CreateEvalViews = true
			c.FinalResponseToolNames = []string{"final_answer"}
			c.EventAllowlist = allowlist
		})
		mCtx.functionCallID = "fc-final-1"
		finalTool := &fakeTool{name: "final_answer", description: "final"}
		var errs callbackErrors
		errs.add(p.OnUserMessageCallback()(mCtx, &genai.Content{Role: "user", Parts: []*genai.Part{{Text: "hi"}}}))
		errs.add(p.BeforeRunCallback()(mCtx))
		errs.add(p.BeforeAgentCallback()(mCtx))
		errs.add(p.BeforeToolCallback()(mCtx, finalTool, map[string]any{"answer": "42"}))
		errs.add(p.AfterToolCallback()(mCtx, finalTool, map[string]any{"answer": "42"}, map[string]any{"ok": true}, nil))
		errs.add(p.AfterAgentCallback()(mCtx))
		errs.check(t)
		p.AfterRunCallback()(mCtx)
		for _, r := range collectRows(t, requests, untilEventType(EventInvocationCompleted)) {
			types = append(types, r["event_type"].(string))
		}
		return types
	}
	// Construction succeeds (the validator accepts the umbrella), but no AGENT_RESPONSE row is written:
	//   [USER_MESSAGE_RECEIVED AGENT_STARTING TOOL_STARTING TOOL_COMPLETED INVOCATION_COMPLETED]
	if got := run(t, umbrella); slices.Contains(got, EventAgentResponse) {
		t.Fatalf("unexpected AGENT_RESPONSE under umbrella allowlist: %v", got)
	}
	// Control, changing only the allowlist: the row comes back.
	if got := run(t, append(slices.Clone(umbrella), EventAgentResponse)); !slices.Contains(got, EventAgentResponse) {
		t.Fatalf("control failed: %v", got)
	}
}

A third arm that also sends a final model event with visible text gets exactly one AGENT_RESPONSE row, the text one. The tool-driven row is still absent.

Smaller things

  • When only the eval views run at startup (DisableCreateViews=true), a failed pass still logs "call SyncViews to retry", and SyncViews would also create the 25 per-event views the user opted out of. That line is not in this diff, so no inline note.
  • Pre-existing, no action needed here: the logSessionSpanEvent doc comment says final-response-tool AGENT_RESPONSE rows go through it, and Config.EventAllowlist says "EVENT" matches AGENT_RESPONSE. Both describe the path the blocking item shows is not taken. Worth fixing alongside, since they are the likely reason the validator was written this way.

The remaining notes are inline. Only the alias item above gates the merge.

Comment thread plugin/agentanalytics/views.go Resolved
Comment thread plugin/agentanalytics/views.go Resolved
Comment thread plugin/agentanalytics/views_test.go Resolved
Comment thread plugin/agentanalytics/views_test.go Resolved
Comment thread plugin/agentanalytics/views.go Resolved
Comment thread plugin/agentanalytics/views.go Resolved
Comment thread plugin/agentanalytics/views.go Resolved
Ensure validateEvalViewConfig matches runtime EVENT filter semantics:
- Include TOOL_COMPLETED in evalViewLegacyDeniedEvents (resumed tool calls emit through logSessionSpanEvent).
- Split legacy allowlist matching into evalViewLegacyAlwaysAllowedEvents and allow EVENT to satisfy AGENT_RESPONSE only when FinalResponseToolNames is empty.
- Isolate per-event and eval startup view errors so eval TableName collisions or errors skip eval views without blocking per-event views.
- Hint SyncEvalViews when an eval-only startup view pass fails DDL, and clarify Config and SyncEvalViews godoc comments.
- Add regression tests for EVENT alias parity, startup isolation, SyncEvalViews preemption/validation ordering, and USER_MESSAGE_RECEIVED function_response JSONPath coverage.
caohy1988

This comment was marked as outdated.

caohy1988

This comment was marked as outdated.

caohy1988

This comment was marked as outdated.

caohy1988

This comment was marked as outdated.

… user text and instruction fallbacks

When ContentFormatter returns an error for USER_MESSAGE_RECEIVED or
AGENT_STARTING, addContent writes the scalar "[FORMATTER_FAILED]" to
content with no content_parts. Wrap scalar JSON_VALUE(content, '$')
fallbacks in NULLIF(..., '[FORMATTER_FAILED]') so a failed user-message
formatter does not satisfy has_user_message (keeping eval_ready=false in
v_eval_session and v_eval_turn) and a failed agent-starting formatter
falls back to attributes.static_instruction, while preserving structured
user messages whose text_summary or content_parts literally contain
"[FORMATTER_FAILED]".

@caohy1988 caohy1988 left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Earlier review of a previous revision; the latest notes are in #2175 (review).

@haiyuan-eng-google

haiyuan-eng-google commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @wolo-lab — this PR is ready for re-review at 869c3d01 (all 8/8 inline threads addressed and resolved, 15/15 CI checks green, merges cleanly onto main):

Summary of Fixes Since Review 5811304493

  • Blocking — "EVENT" allowlist / FinalResponseToolNames parity (plugin/agentanalytics/views.go:367-443): Split legacy "EVENT" matching into evalViewLegacyDeniedEvents (the 9 session events plus resumed-tool TOOL_COMPLETED) and evalViewLegacyAlwaysAllowedEvents (the 8 pure session/HITL/pause events), treating "EVENT" in EventAllowlist as covering AGENT_RESPONSE only when len(c.FinalResponseToolNames) == 0. Pinned by both config/sync validation and runtime row-emission tests in TestCreateEvalViews_ConfigValidation (views_test.go:4004).
  • Startup collision isolation & eval-only retry hint (bigquery_agent_analytics_plugin.go:547-578, views.go:1669-1715): Decoupled per-event defsErr from eval evalErr during startup so a TableName collision on eval views still creates the 25 per-event views when DisableCreateViews is false, and updated eval-only startup failure warnings to recommend call SyncEvalViews to retry.
  • Docs, SyncViews isolation & test assertions (Threads 1–8):
    • Clarified Config.EventAllowlist/EventDenylist (config.go:311-322) and SyncEvalViews/SyncViews docs (views.go:1719-1769, 1771-1857), plus isValidTableName Unicode acceptance (views.go:1574-1584) in the PR description.
    • Added per-group validation isolation in SyncViews (views.go:1771-1857, views_test.go:4613-4748), executedNames() assertions (views_test.go:4424-4477), in-flight startup preemption checks (views_test.go:4789), and USER_MESSAGE_RECEIVED $.function_response + bare '$' JSONPath coverage (views_test.go:4963-5234).
  • Additional polish included at 869c3d01:
    • Accepted GCS_REFERENCE text/plain parts for USER_MESSAGE_RECEIVED (views.go:601-602, views_test.go:6800) to match AGENT_RESPONSE.
    • Wrapped root scalar JSON_VALUE(content, '$') in NULLIF(..., '[FORMATTER_FAILED]') for USER_MESSAGE_RECEIVED and AGENT_STARTING (views.go:612, 619, 1065) so failed user-prompt formatters evaluate eval_ready = false.

Whenever you have a chance, could you please take a quick look at 869c3d01? Thank you!

@wojtas000 wojtas000 self-assigned this Nov 16, 2026

@wojtas000 wojtas000 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One thing has to change before this merges: a user prompt that was offloaded to GCS counts as ready for evaluation, even though the view only has a 200-character preview of it.

Must change before merge:

  1. Offloaded user prompts are marked eval-ready. The user-message text selector accepts GCS_REFERENCE parts (views.go lines 600 to 602). When a prompt is larger than MaxInlineTextSize (32 KiB by default) and GCS offload is on, that part's text is only the first 200 runes plus ... [OFFLOADED] (gcs_offloader.go lines 840 to 841), and is_truncated stays false. The turn then gets eval_ready = true and has_truncated_content = false, so a consumer that selects eval_ready AND NOT has_truncated_content hands the evaluator a prompt cut off after 200 runes. I reproduced it through the plugin callbacks with a fake offloader and a prompt whose question sits at the end. Both views returned the 215-character preview with eval_ready=true and has_truncated_content=false, and the question was gone. adk-python accepts only INLINE parts here (eval_view_ctes_v1.sql at v2.14.1) and gives the reason: offloaded input "leaves the judge without a prompt" (v2.13.0). The property to keep is that a turn is eval-ready only when its trace holds the whole user message. I tried restricting this selector to INLINE: my reproduction passes, and the only tests that fail are the ones asserting the preview behavior (views_test.go lines 6865 to 6878) and the SQL hash pins. I'd hold the merge on it, because it produces wrong evaluation input with no signal that anything is missing, in a configuration the package documents.
  2. The table-name change has no test that pins it. isValidTableName now accepts non-decimal numbers (views.go line 1579), but no accept case uses one, so switching IsNumber back to IsDigit keeps the suite green. Let's add accept cases for tbl² and tblⅫ, the two examples in the description.

Two questions, both optional:

  • The testing plan lists go vet, golangci-lint and apidiff as verifying GoogleSQL compilation, but none of them parse the SQL, and the semantic tests run a SQLite translation of it. Has the DDL been run against BigQuery? If it has, could you say so in the description? Nothing in CI checks it.
  • adk-python has changed this SQL since v2.13.0. v2.14 falls back to the LLM_REQUEST system prompt for agents with an instruction provider, and main (not yet released) adds TOOL_ERROR, leaves the HITL tools out of the tool counts, and stops truncated turns from counting as eval-ready. Matching v2.13.0 is what the description promises, so a follow-up issue to track the newer changes is enough.

The inline notes are optional.

Comment thread plugin/agentanalytics/views.go Resolved
Comment thread plugin/agentanalytics/views.go Resolved
Comment thread plugin/agentanalytics/config.go Resolved
Comment thread plugin/agentanalytics/views.go Resolved
When Cloud Storage offloading is configured, a user text part longer than
MaxInlineTextSize is uploaded, and its content_parts entry keeps only the
first 200 runes followed by "... [OFFLOADED]", without setting is_truncated.
The eval views read that preview as the user message, so the turn came out
eval_ready with has_truncated_content false while the question past the
preview was gone.

The user message text selector now reads only INLINE parts, as adk-python
does, and a message that has any text part stored by GCS reference yields
no user text at all, so a prompt whose other parts stayed inline is not
rebuilt from those parts alone. Offloaded media placeholders are still
skipped without holding back the inline text beside them.

Also:
- Document on CreateEvalViews the content keys that a custom
  ContentFormatter must keep, and that with a ContentFormatter the views
  read AGENT_RESPONSE text from $.response alone.
- Drop the UTF-8 validity check in isValidTableName: ranging over the
  string decodes invalid bytes to U+FFFD, which the loop already rejects.
- Pin the non-decimal Unicode numbers that isValidTableName accepts with
  tbl² and tblⅫ test cases.
- Copy content parts with maps.Copy in a test helper, as the modernize
  linter now enabled on main asks.
@haiyuan-eng-google

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review, @wojtas000. I merged main into the branch (it merged cleanly) and pushed one commit on top that addresses both must-change items and the inline notes.

1. Offloaded user prompts no longer count as eval-ready. The user message text selector now reads only INLINE parts, as adk-python does. Restricting the selector on its own still let a two-part prompt through with only its inline part when the other part was offloaded, so a message with any offloaded text part now has no user text at all. Offloaded media placeholders are still skipped without holding back the text beside them. Following your reproduction, the end-to-end case in TestEvalViews_SemanticExecution/user_message_needs_whole_inline_text_and_skips_media_offloaded now goes through the plugin callbacks with a fake offloader and the default MaxInlineTextSize: a prompt over 32 KiB whose question sits at the end is stored as a 215-rune preview without the question, and both views return eval_ready = false, for the prompt on its own and as the second part of a two-part message, while the same prompt stored inline is ready with its whole text. The tests that asserted the preview behavior and the SQL pins are updated, and the CreateEvalViews doc now states the rule.

2. isValidTableName numbers. Added accept cases for tbl² and tblⅫ. Both fail if unicode.IsNumber goes back to unicode.IsDigit.

Your questions:

  • GoogleSQL compilation: you're right. None of go vet, golangci-lint or apidiff parses the SQL, and the DDL has not been run against BigQuery. The semantic tests run a SQLite translation of it. I corrected the testing section of the description to say so.
  • Newer adk-python changes: agreed. Opened feat(agentanalytics): align evaluation views with newer adk-python rules and expose app_name #2385 to track them: the v2.14 LLM_REQUEST system prompt fallback for agents with an instruction provider, and, from main, TOOL_ERROR, leaving the HITL tools out of the tool counts, and truncated turns not counting as eval-ready, along with exposing the app_name column from your inline question.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The new views are in good shape overall. Identifier validation, the denylist-aware projections, the event-filter checks and the composite session scoping all hold up, and the description is unusually upfront about what changed. There's one thing I think needs fixing before this lands, plus a few smaller gaps.

A pipeline that's still waiting on a tool result is already marked eval_ready. The completeness check (views.go:978) only asks for any AGENT_RESPONSE plus any INVOCATION_COMPLETED in the invocation. The pause predicate at views.go:964 needs zero response rows. In a sequential agent, the first sub-agent can answer with text and the next one can then pause on a long-running tool. The runner ends that call normally and INVOCATION_COMPLETED is written, so both views return eval_ready=true with only the first sub-agent's answer, even though the work is still waiting on the external result. I reproduced this with a real runner (two sequential agents, the second calling a long-running tool with no result) and the existing SQLite translation. Resuming afterwards does flip it correctly. Matching outstanding pause/HITL requests to their resumed completions by call identity, instead of treating any response as completion, would fix it. Python has the same expression, but here it's new code, and anyone selecting "ready" trajectories would be scoring unfinished work.

Smaller things:

  • Resumed invocations under-report latency. A matching function response reuses the original invocation ID (runner/run_node.go:431), but each run gets its own INVOCATION_COMPLETED with its own duration. Taking the max (views.go:960) drops the shorter runs: two runs of 54 ms and 23 ms show up as 54 ms in both views, and that flows into total_latency_ms. Summing distinct completed runs after dedup would fix it.
  • Replies that are literally [BINARY DATA], [MEDIA OFFLOADED] or [UPLOAD FAILED] disappear (views.go:704), and the turn never becomes ready, because the non-empty parts array blocks the fallback to content.response. It's an edge case, but part provenance would distinguish a real placeholder from text.
  • Offloaded text on shared tables. The no-user-text rule for offloaded user parts (views.go:593-604) only fires when part_attributes is NULL or '{}'. That's true for today's Go and Python writers, but any writer that adds attributes to text parts would let partial user text through. On the response side, GCS_REFERENCE previews are aggregated as the full reply (views.go:693-707). Go never offloads AGENT_RESPONSE, but Python does, so on a shared table a 200-character "... [OFFLOADED]" preview would be scored as the complete answer. Mirroring the user-text rule there, or at least documenting it, seems worth doing.
  • SyncViews. The deferred group validation error built at views.go:1787-1810 is only joined at the very end of syncViewsWithDefs. A canceled context, a closed plugin or a gate failure return without it. Separately, the post-sync closed check (views.go:1868-1871) now turns a fully successful sync into a "plugin closed" error. That second change is disclosed, but I don't think it's needed. I'd keep the old rule, where closed only overrides a failure.
  • The startup log still says "skipping view creation" when only one group is skipped, and the retry hint suggests SyncEvalViews even when it's the per-event views that need SyncViews.

@wojtas000
wojtas000 dismissed their stale review November 18, 2026 08:48

Every item in this review is fixed on the current head.

@wojtas000 wojtas000 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving. The single-message offload case and the IsNumber widening both have tests that fail without the fix.

Two optional notes, neither blocks:

  • A turn resumed after a pause can still come out eval-ready with its offloaded prompt missing, when the resume message carries text next to the function response. The resume reuses the paused invocation ID, so has_user_message sees the resume's text. It needs offloading on and a prompt over the inline limit, so a follow-up issue is fine. Optionally, narrow the new CreateEvalViews doc sentence, which says this can't happen.
  • Optionally, the ContentFormatter doc could say that for USER_MESSAGE_RECEIVED and LLM_RESPONSE the formatter gets the typed value, which has no text_summary or usage keys.

@wolo-lab
wolo-lab merged commit e15287f into google:main Nov 19, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants