32 Commits

Author SHA1 Message Date
Bo Yang c560c8474f feat(samples): Add GitHub OAuth sample to demonstrate token requests
Add a new sample 'auth_oauth' demonstrating how to request a GitHub OAuth token in a workflow and use it to list repositories. Also rename the 'auth_config' sample to 'auth_api_key' for consistency.

Change-Id: I014b2f46f74b3017be89efc092380087179cf533
2026-04-20 17:59:17 -07:00
Xuan Yang 0b3d7c49e1 fix(events): Support camelCase in RequestInput
Add alias_generator and populate_by_name to RequestInput model_config to match frontend naming conventions and other event models.

Change-Id: I5eb4a55185d0113d86407c119050bb9885a7962b
2026-04-20 14:33:19 -07:00
Bo Yang 81a226ee61 refactor: rename is_parallel to use_sub_branch throughout workflow execution logic
Change-Id: I34eb070973dec2752338c454e4c4bd110466c925
2026-04-16 15:52:31 -07:00
Bo Yang cc3ba8a4cb refactor(workflow): Make JoinNode stateless by moving join logic to orchestrator
Moved the stateful aggregation logic from JoinNode to the Workflow orchestrator to simplify node implementation and prevent state leaks in loops. Removed in_nodes from Context as it is no longer needed.

Change-Id: If0677f65c735ee3bce985478f7990b4a3335b7df
2026-04-16 14:10:25 -07:00
Shangjie Chen dd64293559 chore(workflow): Remove non-functional shared_sub_agent sample
The shared_sub_agent sample was broken and not working, so it has been removed.

Change-Id: I4b71a04a069ed16c3257a43b469179c19ab1249b
2026-04-16 13:04:46 -07:00
Shangjie Chen 4c0a74bcf6 refactor(workflow): remove empty _workflow.py and rename _workflow_class.py to _workflow.py
Change-Id: I513ceb15e19b92a904746b736dcd976085d1c5d6
2026-04-14 21:23:49 -07:00
Bo Yang c1bdd9bc3b refactor: format dyanmic fan out fan in sample better.
Change-Id: Ifbab67f85122a1400f67df189b0bad24a3eb848b
2026-04-10 11:33:08 -07:00
Bo Yang ed8add2e9b test(cli): Make JSON test files deterministic and sequential
Sort keys when saving rebuilt JSON test files and re-assign sequential event IDs to avoid gaps from filtered events. Also applied these changes to all existing test files in the contributing folder.

Change-Id: Ib126228f016db1d28030eee4f7d9d8cbc604e038
2026-04-10 11:08:42 -07:00
Bo Yang c97d39982f feat(workflow): Refine branch propagation for parallelism
Only add branch segments when parallelism occurs. Handle joins by using the common prefix of incoming branches.

Change-Id: If75f57e2dd69f2ddf71ade818e9c19d2a6e32c53
2026-04-10 11:08:02 -07:00
Shangjie Chen 7041c412f3 feat(samples): add dynamic fan-out/fan-in workflow sample
Demonstrates dynamic node orchestration with ctx.run_node() and asyncio.gather. Uses sub_branch for event isolation to prevent context pollution.

Change-Id: I00b98fe135b5f2a4d671580054d3aa4ad2901d50
2026-04-09 23:15:49 -07:00
Shangjie Chen 4f726053f4 refactor(samples): Clean up and fix style issues in workflow and agent samples
- Removed obsolete TODOs and mode='single_turn' from dynamic nodes sample.
- Fixed line lengths exceeding 80 characters in several samples.
- Removed unused imports and arguments.

Change-Id: Ie03871a258d02eadae9f2ae73f6d2982b755eae5
2026-04-09 22:22:34 -07:00
Bo Yang 7c7a0d7a4b tests: restore replay file now the node path issue is fixed.
Change-Id: Ia2dbf7efebe34239e53c28ac452794602db5bf49
2026-04-09 10:07:03 -07:00
Bo Yang 4476854455 feat(events): make run_id calculated and remove from JSON dump
Change-Id: Ida7d49b36bf6f590796f5c22ca26e5dc121352a5
2026-04-09 09:44:59 -07:00
Xuan Yang 61a8b5b9b8 fix(tests): Align retry sample test with 1-based attempt count
Change-Id: If7442f8c79f36880efdd5084b5baba9585d9a776
2026-04-08 15:44:59 -07:00
Xuan Yang c7f3c625e2 test(cli): Prevent random pollution in replay tests via JSON config
Running all tests caused the global random state to diverge, failing samples that rely on specific random sequences (like retry and loop_self). Moving mock values to JSON files allows deterministic replay without hardcoding sample paths in the runner.

Change-Id: I8e8b14cc54baa47da96aecdbaacb391868d528bb
2026-04-08 15:32:51 -07:00
Shangjie Chen 6f5d47cc27 refactor(workflow): Standardize retry mechanics with attempt_count
This commit refactors the workflow engine's retry mechanics to use a 1-based `attempt_count` instead of the ambiguous `retry_count`. This eliminates off-by-one complexities and aligns the implementation with documented behavior.

Key Changes:
- Replaced `retry_count` with `attempt_count` across `_node_runner_class.py`, `_node_runner.py`, `_workflow.py`, and `_retry_utils.py`.
- Updated `Context` in `agents/context.py` to use `attempt_count` as primary, removing `retry_count` entirely.
- Updated `NodeState` in `_node_state.py` to store `attempt_count` (1-based) instead of `retry_count`.
- Fixed the off-by-one bug in `max_attempts` check: now simply `attempt_count >= max_attempts`.
- Updated the `retry` sample and its README to use `attempt_count` and `max_attempts`.
- Updated unit tests in `test_node_runner_class_failure.py` and `test_workflow_failures.py` to use `attempt_count` and `attempt_counts` in assertions.

Change-Id: I0809c345cae2b62a00170e45e5c3cb6b648823f1
2026-04-08 15:09:21 -07:00
Bo Yang c88caac9af all sample tests pass.
Change-Id: I3708748489a49726fb9822e3eec404b1b88033ad
2026-04-05 11:18:58 -07:00
Bo Yang 003ae2ba68 test(samples): new recordings for v1 llm agent
Change-Id: I2ea965774e3c8147cf5fc4ace88c6e7af491b835
2026-04-05 00:41:42 -07:00
Bo Yang 1936d464e1 fix(workflow): Disable sleep in message sample during pytest
Change-Id: I561cd00fcbc132bb3198f6ffb02b7938f5eeda25
2026-04-05 00:03:03 -07:00
Bo Yang 4035cbdf27 feat(test): Support custom pytest args and ensure reproducible test results
Allow users to customize test execution by passing arbitrary arguments to the underlying pytest runner. Ensure test results are reproducible by removing non-deterministic fields and enforcing sequential execution IDs during test rebuilding.

Change-Id: Ib08dc6a39c6ddf5dff6735865892b02c7d12bf01
2026-04-04 19:25:45 -07:00
Bo Yang 4d14acd6a2 refactor: remove automatic test rebuilding from web server session save endpoint
Change-Id: I22cee1e45a1b10ccd73fc76d79fcd928073d0f6f
2026-04-04 17:35:52 -07:00
Wei (Jack) Sun bf3c1195b4 chore(workflow): Merge new_workflow_samples tests into workflow_samples
Moved tests directories from contributing/new_workflow_samples to contributing/workflow_samples.
Removed contributing/new_workflow_samples directory.
Preserved agent.py files in workflow_samples to maintain feature flag support.

Change-Id: Ic59973c513997dbfd7a3aa278968efa4cc374ef8
2026-04-04 15:55:31 -07:00
Bo Yang dd3fc8b0f4 feat: update nested workflow agent to pass year state to downstream agents and format aggregation output
Change-Id: I6924a0db6d9e71439b0da1e65d1759bfa476a402
2026-03-31 20:11:03 -07:00
Bo Yang dd88f9320d docs: update description of inline image from square to circle in agent workflow sample
Change-Id: I002617036f843460d7c1891da60dd16bd0db11a9
2026-03-31 20:10:54 -07:00
Bo Yang 2d5957eb3c docs(samples): add markdown table to streaming message sample
Change-Id: I77e6b5399bb2ca43f0dd0e7a957085c486920f5b
2026-03-28 16:27:10 -07:00
Bo Yang 1d59974cf4 docs(samples): Add streaming message example
Update message workflow sample to demonstrate streaming token chunks using Event(message=..., partial=True).

Change-Id: Iaa44a293dda1aec1a689b26997b83e4e17ae31ef
2026-03-28 16:25:22 -07:00
Shangjie Chen dc2adf9869 feat(workflow): Use SingleAgentReactNode for leaf single_turn agents in new Workflow
In the new _workflow_class.py Workflow, leaf single_turn LlmAgents now
run through SingleAgentReactNode instead of _SingleLlmAgent. This
enables proper event deduplication via _output_delegated — only the
LlmCallNode content event appears in the stream, not a duplicate
wrapper output event.

The old _workflow.py Workflow retains the original _SingleLlmAgent
path. Runtime detection uses event_queue presence on InvocationContext
to distinguish the two paths.

Also updates the use_as_output sample to use an LLM agent as the
delegated child node, and rewrites wrapper tests per adk-style
guidelines covering both old and new workflow paths.

Change-Id: I96aea3f12fe432d0449268eb75580c900fd047d7
2026-03-27 18:36:56 -07:00
Shangjie Chen d56e11ed68 feat(workflow): Add output_for field to Event for output delegation tracking
Add node_info.output_for to Event -- a list of node paths whose output
an event represents. For normal nodes it contains just the node own
path. When use_as_output=True delegation is used, it includes the full
ancestor chain (child path + all delegating parent paths).

Also adds a contributing sample demonstrating use_as_output with a
downstream edge in the new Workflow architecture.

Change-Id: I7e11276f894a3a2b396759dd146c221b487d4a7c
2026-03-27 10:11:19 -07:00
Shangjie Chen d93cdf35db feat(workflow): add FunctionNode auth_config
Add auth_config field to FunctionNode that pauses for user
authentication before running. The auth gate lives inside
FunctionNode.run(), keeping _node_runner generic.

Utility functions in _workflow_hitl_utils:
- create_auth_request_event: builds adk_request_credential FC event
  with user-facing message
- process_auth_resume: stores credentials with plain value fallback
- has_auth_credential: checks if credentials exist in state

Unwrap {"result":...} for auth responses in _process_resumptions,
consistent with request_input handling.

Includes sample agent and tests for auth flow and credential reuse.

Change-Id: Ib81bf9cf63b8282efd7898def17f6e47a95b2d05
2026-03-20 13:01:22 -07:00
Shangjie Chen fc90f364f9 fix(docs): add ctx param to retry sample README snippet
Change-Id: I4ad9994d95618ea1577951a856ce105db8411400
2026-03-19 13:57:42 -07:00
Shangjie Chen 4561d04ab3 feat(workflow): emit error events on node failure
When a node raises an exception, emit an Event with error_code and
error_message before propagating the error. This makes failures
visible in the event stream (web UI, CLI) without requiring nodes
to manually yield error messages.

Applies to all node types via _node_runner, covering both unhandled
exceptions and timeouts.

Update retry sample to remove manual error message yield.

Change-Id: I4598cd288f1201416086149f3af44f8c8c10c1a4
2026-03-19 13:34:42 -07:00
Wei (Jack) Sun 1c64a41b53 feat: ADK 2.0 alpha
Introduces two major capabilities:
- Workflow runtime: graph-based execution engine for composing
  deterministic execution flows for agentic apps, with support for
  routing, fan-out/fan-in, loops, retry, state management, dynamic
  nodes, human-in-the-loop, and nested workflows
- Task API: structured agent-to-agent delegation with multi-turn
  task mode, single-turn controlled output, mixed delegation
  patterns, human-in-the-loop, and task agents as workflow nodes

Co-Authored-By: Bo Yang <ybo@google.com>
Co-Authored-By: George Weale <gweale@google.com>
Co-Authored-By: Sean Zhou <seanzhougoogle@google.com>
Co-Authored-By: Shangjie Chen <deanchen@google.com>
Co-Authored-By: Swapnil Agarwal <swapnilag@google.com>
Co-Authored-By: Wei Sun <weisun@google.com>
Co-Authored-By: Xuan Yang <xygoogle@google.com>
Co-Authored-By: Yifan Wang <wanyif@google.com>
Change-Id: I35932c50cfe29ff68559e3781713dbb5eb7b3382
2026-03-17 23:24:58 -07:00