Skip to content

fix(bigquery): BQAA Java P1 preview-readiness fixes (tracing, lifecycle, redaction, HITL)#1355

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_948528272
Jul 16, 2026
Merged

fix(bigquery): BQAA Java P1 preview-readiness fixes (tracing, lifecycle, redaction, HITL)#1355
copybara-service[bot] merged 1 commit into
mainfrom
test_948528272

Conversation

@copybara-service

Copy link
Copy Markdown

fix(bigquery): BQAA Java P1 preview-readiness fixes (tracing, lifecycle, redaction, HITL)

Resolves the plugin-local P1 preview-readiness blockers in the Java BigQuery
Agent Analytics (BQAA) plugin: correctness, lifecycle, privacy-boundary, and
duplicate-telemetry defects fixable inside the agentanalytics package.
(Terminal agent/run failure analytics is out of scope; it needs new framework
plugin callbacks and will land separately.)

  • Branch-safe trace state: TraceManager keeps span records in per-branch
    stacks keyed by InvocationContext.branch(), so concurrent ParallelAgent
    branches can no longer pop each other's spans. Pops are kind-checked; tool
    spans carry an operation identity and push-time parent (an event's function
    calls run concurrently); parent resolution walks the branch ancestor chain.
  • No plugin-owned OpenTelemetry spans: records are ID-only (16-hex local IDs).
    Ambient OTel context is still read for trace_id/root span_id so rows stay
    joinable to Cloud Trace, but a host with an SDK exporter receives zero
    BQAA-owned spans.
  • Sensitive-key redaction at the final attributes boundary: logEvent runs the
    fully assembled attributes map through the redaction walk before
    serialization (state_delta, custom tags, labels, nested extras). Redaction
    only -- no length truncation, does not set is_truncated.
  • Per-invocation processor/task lifecycle: BatchProcessor.start() stores its
    ScheduledFuture; an idempotent close() cancels it so completed
    invocations no longer leak periodic tasks retaining closed processors.
  • Bounded append/drain/timeout: each Storage Write RPC is bounded by
    shutdownTimeout (future cancelled on timeout); the final drain in close()
    is deadline-bounded; abandoned and after-close rows are counted
    (shutdown_timeout, after_close).
  • Writer-construction and late-continuation accounting: PluginState.appendRow
    gates every append on the invocation lifecycle -- a late continuation
    completing after finalization is dropped and counted (late_after_finalize).
    StreamWriter construction failures are logged SEVERE and counted
    (writer_create_error), leaving the mapping unpopulated so the next event
    retries; writer-close ownership is bounded by admission permits.
  • HITL and long-running-tool pause/resume: a synthetic adk_request_*
    FunctionCall now emits HITL_*_REQUEST (previously mislabeled _COMPLETED);
    any long-running FunctionCall additionally emits a pairable TOOL_PAUSED row
    with pause_kind and function_call_id; resumed FunctionResponse parts route
    HITL responses to HITL_*_COMPLETED and non-HITL resumes to TOOL_COMPLETED
    carrying the pause pair keys; adds the TOOL_PAUSED view and
    pause_kind/function_call_id columns on the TOOL_COMPLETED view.

Adds regression tests for concurrent ParallelAgent overlap with out-of-order
completion, per-operation tool spans, zero BQAA spans on a recording exporter,
no retained processors after many invocations, bounded close, post-finalize
append rejection, writer-construction accounting, nested/session-state
redaction, and HITL request/pause/complete naming with pair keys.

@copybara-service copybara-service Bot force-pushed the test_948528272 branch 4 times, most recently from 11f46c6 to 60c10a0 Compare July 16, 2026 08:59
…le, redaction, HITL)

Resolves the plugin-local P1 preview-readiness blockers in the Java BigQuery
Agent Analytics (BQAA) plugin: correctness, lifecycle, privacy-boundary, and
duplicate-telemetry defects fixable inside the `agentanalytics` package.
(Terminal agent/run failure analytics is out of scope; it needs new framework
plugin callbacks and will land separately.)

- Branch-safe trace state: `TraceManager` keeps span records in per-branch
  stacks keyed by `InvocationContext.branch()`, so concurrent `ParallelAgent`
  branches can no longer pop each other's spans. Pops are kind-checked; tool
  spans carry an operation identity and push-time parent (an event's function
  calls run concurrently); parent resolution walks the branch ancestor chain.
- No plugin-owned OpenTelemetry spans: records are ID-only (16-hex local IDs).
  Ambient OTel context is still read for `trace_id`/root `span_id` so rows stay
  joinable to Cloud Trace, but a host with an SDK exporter receives zero
  BQAA-owned spans.
- Sensitive-key redaction at the final attributes boundary: `logEvent` runs the
  fully assembled attributes map through the redaction walk before
  serialization (state_delta, custom tags, labels, nested extras). Redaction
  only -- no length truncation, does not set `is_truncated`.
- Per-invocation processor/task lifecycle: `BatchProcessor.start()` stores its
  `ScheduledFuture`; an idempotent `close()` cancels it so completed
  invocations no longer leak periodic tasks retaining closed processors.
- Bounded append/drain/timeout: each Storage Write RPC is bounded by
  `shutdownTimeout` (future cancelled on timeout); the final drain in `close()`
  is deadline-bounded; abandoned and after-close rows are counted
  (`shutdown_timeout`, `after_close`).
- Writer-construction and late-continuation accounting: `PluginState.appendRow`
  gates every append on the invocation lifecycle -- a late continuation
  completing after finalization is dropped and counted (`late_after_finalize`).
  `StreamWriter` construction failures are logged SEVERE and counted
  (`writer_create_error`), leaving the mapping unpopulated so the next event
  retries; writer-close ownership is bounded by admission permits.
- HITL and long-running-tool pause/resume: a synthetic `adk_request_*`
  FunctionCall now emits `HITL_*_REQUEST` (previously mislabeled `_COMPLETED`);
  any long-running FunctionCall additionally emits a pairable `TOOL_PAUSED` row
  with `pause_kind` and `function_call_id`; resumed FunctionResponse parts route
  HITL responses to `HITL_*_COMPLETED` and non-HITL resumes to `TOOL_COMPLETED`
  carrying the pause pair keys; adds the `TOOL_PAUSED` view and
  `pause_kind`/`function_call_id` columns on the `TOOL_COMPLETED` view.

Adds regression tests for concurrent ParallelAgent overlap with out-of-order
completion, per-operation tool spans, zero BQAA spans on a recording exporter,
no retained processors after many invocations, bounded close, post-finalize
append rejection, writer-construction accounting, nested/session-state
redaction, and HITL request/pause/complete naming with pair keys.

PiperOrigin-RevId: 948836241
@copybara-service copybara-service Bot merged commit 2027a4b into main Jul 16, 2026
@copybara-service copybara-service Bot deleted the test_948528272 branch July 16, 2026 09:07
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.

1 participant