fix(bigquery): BQAA Java P1 preview-readiness fixes (tracing, lifecycle, redaction, HITL)#1355
Merged
Merged
Conversation
11f46c6 to
60c10a0
Compare
…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
60c10a0 to
2027a4b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
agentanalyticspackage.(Terminal agent/run failure analytics is out of scope; it needs new framework
plugin callbacks and will land separately.)
TraceManagerkeeps span records in per-branchstacks keyed by
InvocationContext.branch(), so concurrentParallelAgentbranches 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.
Ambient OTel context is still read for
trace_id/rootspan_idso rows stayjoinable to Cloud Trace, but a host with an SDK exporter receives zero
BQAA-owned spans.
logEventruns thefully 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.BatchProcessor.start()stores itsScheduledFuture; an idempotentclose()cancels it so completedinvocations no longer leak periodic tasks retaining closed processors.
shutdownTimeout(future cancelled on timeout); the final drain inclose()is deadline-bounded; abandoned and after-close rows are counted
(
shutdown_timeout,after_close).PluginState.appendRowgates every append on the invocation lifecycle -- a late continuation
completing after finalization is dropped and counted (
late_after_finalize).StreamWriterconstruction failures are logged SEVERE and counted(
writer_create_error), leaving the mapping unpopulated so the next eventretries; writer-close ownership is bounded by admission permits.
adk_request_*FunctionCall now emits
HITL_*_REQUEST(previously mislabeled_COMPLETED);any long-running FunctionCall additionally emits a pairable
TOOL_PAUSEDrowwith
pause_kindandfunction_call_id; resumed FunctionResponse parts routeHITL responses to
HITL_*_COMPLETEDand non-HITL resumes toTOOL_COMPLETEDcarrying the pause pair keys; adds the
TOOL_PAUSEDview andpause_kind/function_call_idcolumns on theTOOL_COMPLETEDview.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.