Repository navigation
Fix activity_as_tool for an Activity with *args in Deep Agents and Google ADK - #486
Conversation
…Google ADK Deep Agents refused to build a tool for an Activity with *args, and Google ADK left *args out of the declaration and passed the empty tuple as one more argument. Both now offer *args to the model as a list, as openai_agents does, and spread it into the Activity's arguments. Fixes temporalio#390
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25a2074f1f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ADK leaves *args out of a function's declaration, so the Google ADK tool keeps that declaration and only stops passing the empty tuple as one more argument. That changes the arguments new tool calls record, so it is behind the patch google_adk.activity-as-tool-var-args, which only a tool for an Activity with *args checks. Deep Agents' schema defaults *args to None, as LangChain's own schema for the function does.
brianstrauch
left a comment
There was a problem hiding this comment.
Deep Agents fails for conventional *args signatures and loses array validation for unannotated variadic parameters. Both issues reproduce with the locked dependencies.
The tool's signature replaced *args with a list parameter. For *args named args, LangChain then showed Pydantic's v__args field and every call failed; an unannotated *args lost its array type. The signature now keeps *args, so LangChain builds the schema it builds for the function, and only the call binds the list.
Replay is promised only within a major, and the next Google ADK Python release is 1.0. The google_adk.activity-as-tool-var-args patch (#486) only kept runs from before that fix passing an empty *args as one extra argument, so it goes: activity_as_tool always spreads *args now.
…before 1.0 (#585) ## What was changed Google ADK Python ships 1.0 next, so its current major is 1, and replay is promised only within a major (the rule #565 adds to AGENTS.md). The `google_adk.activity-as-tool-var-args` patch from #486 only keeps runs from before that fix passing an Activity's empty `*args` as one extra argument, so let's remove it before 1.0. `activity_as_tool` now always spreads an Activity's `*args`. The tests stop checking the old path and the patch marker. This PR doesn't need #565: no committed history reaches this gate. ## What will you notice? (Breaking) Not much. A run that started before #486 now passes `*args` the new way at its next such tool call, so its Activity gets no extra empty-tuple argument. Its history still replays: replay doesn't compare Activity arguments. A run on a `main` build since #486 that called such a tool recorded the marker, so it doesn't replay on this build. Its next Workflow Task fails with `[TMPRL1100] Non-deprecated patch marker encountered`, and the run stops making progress. No release wrote that marker. ### What should you do? Never ran a `main` build of Google ADK Python since #486? Then nothing. If you did, find the open runs that recorded the marker first. The Python SDK adds every patch it records to the `TemporalChangeVersion` search attribute, so this lists them: ``` temporal workflow list --query "TemporalChangeVersion = 'google_adk.activity-as-tool-var-args' AND ExecutionStatus = 'Running'" ``` No results? You're done. Otherwise, pick one: 1. **Let them finish, before you deploy.** Keep your current Workers until those runs close, or pin them to the old Worker Deployment Version with Worker Versioning. Then send new runs to this build. 2. **Reset them, after you deploy.** In each run's history, find the first `MarkerRecorded` event for `google_adk.activity-as-tool-var-args` and the `WorkflowTaskCompleted` event just before it. Reset to that event: ``` temporal workflow reset --workflow-id <id> --event-id <that WorkflowTaskCompleted event ID> --reason "drop google_adk var-args marker" ``` The new run keeps everything before that point and runs the rest again on this build. So the `*args` tool Activity that recorded the marker runs again, and so does every Activity after it, model calls included. Signals that arrived after that point are reapplied by default. Only reset when those Activities are safe to run twice. Reset only once this build is deployed: an older Worker would record the marker again. ## Why? We decided that replay is promised only within a major, and that a gate that only protects an older major's runs is removed before the next major ships. Google ADK Python's next release is 1.0, so this gate goes before it. ## Checklist 1. No issue. 2. How was this tested: - `make format`, `make lint` and `make test` for `python/google_adk` on Python 3.12: 324 passed, 6 skipped. - Replay, across builds. On Workers with no Workflow cache, I recorded a tool call to an Activity with `*args` and one to an Activity without, on `main` and on this PR. On `main` I also recorded the `*args` call with `workflow.patched()` returning `False` for this gate, which is what a run from before #486 does. Then I replayed every one on both builds, along with a history with a renamed Activity. - On this PR, only the `*args` run from `main`, which has the marker, fails, with `[TMPRL1100] Non-deprecated patch marker encountered`, and so does the renamed Activity. The old-path run replays. - Rollback to `main`: everything recorded on this PR replays. - The reset steps above, on a local dev server with a small stand-in Workflow (not `activity_as_tool`). A Worker that calls `workflow.patched()` for this gate before its second Activity, like `main`, recorded the marker. Then a Worker without that call, like this PR, failed with TMPRL1100. The `TemporalChangeVersion` query found the run. `temporal workflow reset` to the `WorkflowTaskCompleted` before the marker finished it on the new Worker with no marker, and ran exactly one Activity again: the one after the marker. After that, the query found nothing. I didn't try the Worker Versioning option. 3. Any docs updates needed? No. The README doesn't mention the patch.
Fixes #390
activity_as_toolin Deep Agents refused an Activity with*args, and in Google ADK it passed the empty*argstuple to the Activity as one more argument.*args, so LangChain builds the same schema as for the function itself: an array named after the parameter, defaultNone, typed from its annotation. The call binds the list and spreads it into the Activity's arguments. Building such a tool failed before, so no recorded history changes.*argsout, so the model can't fill it. The tool now spreads the empty tuple instead of passing it, so the Activity's*argsis empty, not([],). That changes the arguments a new tool call records, so it is behind the patchgoogle_adk.activity-as-tool-var-args: a Workflow started before it keeps the old arguments on replay. Only a tool for an Activity with*argschecks the patch. Offering*argsto the model is left to ADK.*args, so the Worker decodes its arguments without them, as inopenai_agentstoday.Tested:
test_activity_as_tool_passes_empty_var_positional(function and callable-class Activity, patch on and off) checks the declaration against ADK's declaration of the plain function, and the arguments the Activity is scheduled with.test_activity_as_tool_without_var_positional_checks_no_patch: a tool for an Activity without*argsdoesn't check the patch.test_activity_as_tool_var_positional_replaysruns a Workflow on the dev server with and without the patch and replays both histories.test_activity_as_tool_spreads_var_positionalchecks the schema against LangChain's for the function with*more: str(function and callable class),*args: str, and an unannotated*more; the spread arguments; and that a string for the list is rejected before any Activity is scheduled.make lintpasses in both plugins;make test: Google ADK 266 passed; Deep Agents 262 passed.