Skip to content

[pull] main from temporalio:main - #192

Merged
pull[bot] merged 3 commits into
TheTechOddBug:mainfrom
temporalio:main
Aug 10, 2026
Merged

[pull] main from temporalio:main#192
pull[bot] merged 3 commits into
TheTechOddBug:mainfrom
temporalio:main

Conversation

@pull

@pull pull Bot commented Aug 10, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

tconley1428 and others added 3 commits August 10, 2026 10:22
…vity_tool (#1683)

* Support ToolContext session state in activity_tool via ToolContextSnapshot

Activities wrapped with activity_tool could not access the ADK ToolContext:
declaring a tool_context parameter put it in the LLM-facing tool schema and
then failed at runtime trying to serialize the live ToolContext as an
activity argument (#1470).

An activity can now declare a parameter named tool_context annotated with
the new ToolContextSnapshot dataclass. Exactly like a native ADK function
tool's tool_context parameter, it is excluded from the tool schema (ADK
reserves the name) and filled at invocation time — with a serializable
snapshot of the live ToolContext (session state as a plain dict, plus the
function-call id) taken workflow-side before the activity is scheduled. The
live ToolContext never crosses the activity boundary. Annotating the
parameter with an ADK context type raises an actionable error at wrap time
instead of failing at serialization time.

The snapshot is one-way by design: activities may run on different workers,
so session-state modifications must happen workflow-side using information
returned from the activity.

Closes #1470

* Harden tool_context validation, close annotation-based injection bypass

ADK detects the context parameter annotation-first across all parameters
(find_context_parameter), falling back to the name 'tool_context', so the
previous name-only validation missed cases where ADK would still inject
the live, non-serializable context:

- Reject an ADK context annotation on any parameter, not just
  'tool_context' (e.g. 'ctx: ToolContext' previously passed wrap-time
  validation, then failed payload serialization at runtime — the exact
  failure mode from #1470 — and, when combined with a
  'tool_context: ToolContextSnapshot' parameter, leaked that parameter
  into the LLM-facing tool schema as required).
- Reject ToolContextSnapshot on a parameter not named 'tool_context'
  (ADK never injects it there, so it would leak into the tool schema).
- Reject an unannotated 'tool_context' (public docs already required the
  annotation; without it the activity decoded the snapshot as a plain
  dict under Temporal but received a ToolContextSnapshot in local runs).
- Route Optional[ToolContext] to the ADK-specific error message and
  render union annotations readably.

Docs: state serializability/payload-size constraints under Temporal and
read-only snapshot semantics (nested values may alias live session state
in local runs); add missing timedelta import to the README snippet.

Tests: new wrap-time acceptance/rejection matrix (Optional form, ADK
context under any name, misplaced snapshot, unannotated), legacy
(non-JSON-schema) declaration path, context-only tool schema, mixed-type
session state round-trip, and an in-activity marker proving the snapshot
crosses a real activity boundary; drop incorrect copyright header.
Verified against google-adk 2.2.0 (locked) and 2.5.0.

* README: note local-run nested state aliasing in the read-only caveat
@pull pull Bot locked and limited conversation to collaborators Aug 10, 2026
@pull pull Bot added the ⤵️ pull label Aug 10, 2026
@pull
pull Bot merged commit 8d8f346 into TheTechOddBug:main Aug 10, 2026
4 of 14 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants