Skip to content

feat(plugins): add workflow-node observation windows - #13

Draft
caohy1988 wants to merge 4 commits into
rfc98/upstream-main-3f21e891from
feat/bqaa-workflow-observation-windows
Draft

caohy1988 wants to merge 4 commits into
rfc98/upstream-main-3f21e891from
feat/bqaa-workflow-observation-windows

Conversation

@caohy1988

Copy link
Copy Markdown
Owner

Please ensure you have read the contribution guide before creating a pull request.

Caution

Draft implementation; do not merge yet. RFC google#98 requires one named
production query that cannot be answered by a canonical aggregate view over
real Stage 1 data. The high-cardinality drain residual under Additional
context
must also be resolved before this PR becomes ready for review.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

Problem:

Stage 1 made workflow-node outputs and errors visible, but it cannot separate
resumed runner calls that reuse invocation_id, retain interrupt evidence, or
describe source-event windows consistently. Calling these inferred facts node
start, completion, failure, or latency would overstate what the plugin observes.

Solution:

This PR adds an additive, plugin-only observation contract:

  • WORKFLOW_NODE_FIRST_OBSERVED records the first path-bearing event seen in
    one runner call.
  • WORKFLOW_NODE_OBSERVATION_SUMMARY records first/last source-event
    provenance, signed event span, event count, direct/descendant interrupt
    evidence, node-error count, and the terminal callback that drained the
    segment.
  • A plugin-generated workflow_segment_id separates resume calls even when
    invocation_id and node paths are reused.
  • Managed typed views expose stable BigQuery columns without changing the
    physical table schema.

The producer records observations before event-row filtering. Both terminal
callbacks clear task-local state in finally. A failed synthetic observation
row cannot suppress the existing invocation or node telemetry.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • The complete affected plugin unit-test file passes locally.

Passed result:

516 passed, 6 skipped in 22.74s

Command:

pytest -q tests/unittests/plugins/test_bigquery_agent_analytics_plugin.py

The tests cover segmentation, partial and empty-path events, signed and
zero-length spans, direct and ancestor interrupt evidence, node-error counts,
normal and error drains, concurrent task isolation, disabled/shutdown paths,
failure isolation, exact Stage 1 row ordering, event filtering, and typed-view
projections.

Repository hooks pass for both changed files. A focused mypy run still
reports the plugin file's existing strict-mode errors; it reports no error on
the new observation code. Repository-wide tox was not run because the locked
optional environment cannot be installed on this Intel macOS host:
google-antigravity and cryptography==50.0.0 do not provide compatible
wheels in this environment.

Manual End-to-End (E2E) Tests:

Not run. The RFC's implementation gate intentionally requires evaluation
against real Stage 1 BigQuery data before producer rows are enabled for merge.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes. (The affected plugin suite passes; repository-wide tox remains outstanding.)
  • I have manually tested my changes end-to-end. (Blocked on the RFC implementation gate.)
  • Any dependent changes have been merged and published in downstream modules. (Stage 1 landed in 04b8b727.)

Additional context

Contract limits are deliberate:

  • These rows describe callback observations, not framework lifecycle or wall
    time. A one-event FunctionNode has a zero source-event span.
  • Partial events can anchor provenance even though their IDs may not correspond
    to persisted session or NODE_* rows.
  • A missing summary proves nothing: filtering, delivery loss, abandonment, or
    an in-progress call can produce the same shape.
  • Source timestamps can tie or regress. The summary preserves a signed span.
  • Default configuration adds up to two rows per observed node per runner call.

Known merge-blocking residual:

  • The summary-before-terminal contract can enqueue a high-cardinality burst.
    If one runner call observes more distinct node paths than the bounded writer
    queue can accept without yielding, the trailing INVOCATION_COMPLETED or
    INVOCATION_ERROR row can be dropped. Before this draft becomes ready, choose
    and test a bounded drain or terminal-row capacity policy that preserves the
    RFC's required ordering.

This PR targets rfc98/upstream-main-3f21e891, which is pinned to current
upstream main at 3f21e891. That keeps the fork's stale main and the
contract-stale PR #8 untouched.

Post-Deploy Monitoring & Validation

  • Search logs for Could not emit workflow-node and BigQuery log queue full.
  • Monitor get_drop_stats()["queue_full"], per-invocation row growth, and the
    ratio of summary rows to distinct (workflow_segment_id, node_path) pairs.
  • Healthy signal: no new queue drops and stable invocation-terminal row counts
    in an opt-in canary using the named production query.
  • Failure signal: any queue-drop increase, missing terminal-row increase, or
    material write-volume regression. Mitigate by denylisting both new event
    types and return the draft to design review.
  • Validation window: first 24 hours of the opt-in canary. Owner: BQAA plugin
    maintainer running the RFC How to deploy the agent as self-managed google/adk-python#98 gate evaluation.

New concepts

Observation windows are not lifecycle boundaries

An observation window summarizes the events a plugin actually received for a
node path during one runner call. It does not claim when the node started or
stopped executing.

This distinction matters here because ADK has no public node-lifecycle callback
that covers retries, replay, pause/resume, cancellation, and silent nodes. The
plugin can publish factual source-event provenance now without consuming exact
names such as WORKFLOW_NODE_STARTING or WORKFLOW_NODE_COMPLETED.

For example, a FunctionNode that works for one minute and emits one result has
a zero observation span. Use this contract for event-span and interrupt
analytics. Do not use it for wall-time latency, completion status, or failure
attribution.


Compound Engineering

Create a fresh plugin-local segment for each runner call and emit the first path-bearing source event without claiming a node lifecycle boundary.
Drain source-event spans, sticky interrupt evidence, and factual node-error counts from both runner terminal callbacks without inferring completion or failure.

This branch has not been deployed

No deployments
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