16 Commits

Author SHA1 Message Date
Jason Zhang 94832a5151 docs: Add developer unit guide for ReflectAndRetryToolPlugin
The new guide explains what the plugin does, a get-started
example, how the retry loop and per-tool failure tracking
work, the configuration options, advanced applications,
and its limitations.

Co-authored-by: Jason Zhang <jasoncz@google.com>
PiperOrigin-RevId: 955444373
2026-07-28 13:40:52 -07:00
Haran Rajkumar 52c3e9eb60 docs: document creating and using a custom managed agent
Add a "Create and use a custom managed agent" section to the ManagedAgent guide
showing the control-plane create/delete pattern via `ManagedAgent.api_client`,
and complete the guide's Related samples list.

Co-authored-by: Haran Rajkumar <haranrk@google.com>
PiperOrigin-RevId: 954766292
2026-07-27 12:25:10 -07:00
Jason Zhang 322f45591c feat: Add ReflectAndRetryModelPlugin for self-healing model errors
Introduces the `ReflectAndRetryModelPlugin`, which provides error recovery
for model failures (such as malformed function calls). When a configured model
error occurs, the plugin intercepts it, provides reflection guidance to
the model via a reserved tool call, and retries the operation.

Key features:
- Configurable max retries for model errors.
- Customizable list of FinishReasons to treat as errors.
- Support for both invocation-level and global-level tracking scopes.
- Interception of direct calls to the reserved retry tool to prevent misuse.

Co-authored-by: Jason Zhang <jasoncz@google.com>
PiperOrigin-RevId: 954695655
2026-07-27 10:15:36 -07:00
Haran Rajkumar 597fac3a4f docs(agents): add system-instruction sample and guide section
Add a runnable sample under
contributing/samples/managed_agent/system_instruction demonstrating the new
ManagedAgent.instruction field, and document the field in the ManagedAgent
guide.

Co-authored-by: Haran Rajkumar <haranrk@google.com>
PiperOrigin-RevId: 951709300
2026-07-21 14:46:43 -07:00
Haran Rajkumar 26ed6fe382 docs(guides): note single_turn works for non-LlmAgent agents
Extend the LlmAgent single-turn guide with a section showing that `single_turn`
composition is not limited to `LlmAgent`: a server-backed `ManagedAgent` can be
a single-turn sub-agent via `mode='single_turn'`, is auto-exposed as an inline
tool, preserves its internal events in the shared session, and is stateless per
call.

Co-authored-by: Haran Rajkumar <haranrk@google.com>
PiperOrigin-RevId: 945962977
2026-07-10 17:10:18 -07:00
Shangjie Chen 9d306f5d32 feat(workflow): Support state-based resumption for task-mode agent workflow nodes
- Decouple task-mode node execution from default output binding so standard text output does not prematurely finish the node.
- Enhance the runner to automatically resolve and reuse the invocation_id of active suspended task nodes.
- Route incoming plain text resume messages to the active task node by mapping to its isolation scope.
- Enforce strict concurrency serialization by suspending parallel branch execution when a task node is waiting for user input.
- Align schema validation helpers to cleanly handle Content wrapping and raw JSON strings.

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 945423735
2026-07-09 18:40:44 -07:00
George Weale 534e8d50cc docs: add to_mcp_server unit guide
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 944717677
2026-07-08 14:59:25 -07:00
Haran Rajkumar ab839d51d3 docs(guides): Add ManagedAgent unit guide
This guide explains how to use ManagedAgent, its configuration
options, and orchestrating it with AgentTool.

Co-authored-by: Haran Rajkumar <haranrk@google.com>
PiperOrigin-RevId: 944359273
2026-07-08 02:03:47 -07:00
Shangjie Chen 199d954815 feat: expose max_parallel_workers parameter on workflow.node decorator and Node class
Expose `max_parallel_workers` on the `@workflow.node` decorator and `Node` class when `parallel_worker=True`. This allows throttling the concurrency limit when executing parallel workers.

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 940663519
2026-06-30 14:34:30 -07:00
Bo Yang a40f19930f fix: Wrap math formulas in math blocks in retry config guide
This ensures proper rendering of the delay and jitter formulas.

Co-authored-by: Bo Yang <ybo@google.com>
PiperOrigin-RevId: 934409270
2026-06-18 09:54:25 -07:00
George Weale a7377b446a docs: remove trailing whitespace in dynamic_nodes guide
Unblocks the pre-commit --all-files check; mdformat rewrites this file
and fails on every PR until the whitespace is gone.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 934144935
2026-06-17 23:29:05 -07:00
Bo Yang e5c7d20d5d docs(workflow): Add and update workflow developer guides
Add comprehensive guides explaining:
- Workflow Graphs (nodes, edges, validation)
- Function Nodes (wrapping functions and generators)
- Join Nodes (aggregating parallel branches)
- Retry Config (resilience policies)
- Parallel Workers (concurrent list processing)
- Dynamic Nodes (runtime execution)

Update the main guides index and the adk-unit-guide skill rules.

Co-authored-by: Bo Yang <ybo@google.com>
PiperOrigin-RevId: 933979245
2026-06-17 16:15:57 -07:00
Bo Yang f84a5b5e20 docs: add unit guides for task mode
Added task mode doc, README and cross-linking samples.

Co-authored-by: Bo Yang <ybo@google.com>
PiperOrigin-RevId: 931386773
2026-06-12 16:19:07 -07:00
Bo Yang 7d74a0a0e2 docs: add unit guides for event.py, request_input.py and update adk-unit-guide skill
- Updated request_input.py unit guide to use function node example and removed field table.
- Updated adk-unit-guide skill:
  - Discourage exhaustive API reference tables in guides.
  - Prefer simple Python functions over extending BaseNode for workflow node samples.
- Removed field reference tables from the event guide.

Co-authored-by: Bo Yang <ybo@google.com>
PiperOrigin-RevId: 931347184
2026-06-12 14:55:34 -07:00
George Weale cb48d015d8 fix: restore GitHub-only changes dropped during v2 bring-over
Re-aligns two files with GitHub main so the piper-to-github cutover does not
silently revert them: the _ALLOWED_PICKLE_GLOBALS type annotation and a stray
f-string prefix in skill_toolset.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 928768999
2026-06-08 16:49:54 -07:00
Bo Yang 6a533573db feat(api_server): Abort runs on client drops to avoid leaks
Standard REST, SSE, and WebSocket endpoints now actively monitor client disconnections. When a connection drop is intercepted, the executing worker task tree is aborted mid-run to prevent background task leaks, API token burn, and resource wastage.

Includes:
1. REST `/run` connection drop monitor blocking on raw ASGI receive events with 0% CPU consumption.
2. Graceful `499 Client Closed Request` status response on REST disconnections to suppress server-side exceptions.
3. Unit and integration tests validating REST task cancellations and generator finalizations.
4. Comprehensive architectural design documents and user guide under `/docs`.
5. An invocation-focused cooperative counting agent sandbox under `/contributing/samples/core/abort`.

Change-Id: I50fcba7a8bb56cf28b0a3bb8fa66b85732062a67
2026-05-28 14:11:39 -07:00