Skip to content

Support zero- and multi-parameter activities in Deep Agents' activity_as_tool - #313

Merged
brianstrauch merged 1 commit into
temporalio:mainfrom
sohom-cs:fix/deepagents-activity-as-tool-args
Oct 30, 2026
Merged

brianstrauch merged 1 commit into
temporalio:mainfrom
sohom-cs:fix/deepagents-activity-as-tool-args

Conversation

@sohom-cs

Copy link
Copy Markdown
Contributor

activity_as_tool (in _tools.py) shows the model the activity's own parameters, then collapses the model's keyword call into one positional argument: the value itself for a one-parameter activity, a dict of all the arguments otherwise, and {} for an activity with none. The worker calls the activity with one argument per input. So a two-parameter activity gets the dict as its first argument and fails with "missing 1 required positional argument", and a zero-parameter one fails with "takes 0 positional arguments but 1 was given". Every attempt fails the same way, so under the default retry policy the tool call never returns. Python activities can take several parameters; the OpenAI Agents plugin's activity_as_tool already passes args=.

This change maps the model's arguments onto the activity's parameters in order and calls workflow.execute_activity(activity, args=[...]). A parameter the model leaves out gets its default, so the worker still decodes the arguments with the activity's type hints (it uses them only when every parameter has a value). A one-parameter activity is scheduled with the same input as before, so existing histories replay unchanged.

Related: #278 reads the same inspect.signature(activity) line for callable-class activities; this change is about how the call's values are passed.

Checklist

  1. Closes: no issue (small bug fix).

  2. How was this tested:

    • New test_activity_as_tool_passes_each_parameter in tests/test_tools.py runs a workflow that calls a three-parameter activity (the last has a default) twice, once leaving the default out, and a zero-parameter activity. With the change it returns ["Paris:3:C", "Oslo:1:F", "quota:42"]. On main it fails after about 16 s, inside the 30 s execution timeout, with an ActivityError caused by TypeError: forecast_activity() missing 1 required positional argument: 'days'.
    • make lint passes. make test (the plugin): 137 passed.
  3. Any docs updates needed? No.

…_as_tool

activity_as_tool collapsed the model's keyword call into one positional
argument, so an activity with two or more parameters got a dict as its
first argument and one with none got an empty dict, and every attempt
failed with a TypeError. Pass one argument per activity parameter
instead, filling the ones the model leaves out with their defaults.
@sohom-cs
sohom-cs requested a review from a team as a code owner October 30, 2026 19:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-30T19:17:38.674279Z
We couldn’t complete this review. Comment @codex review to try again.
20235d1 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@brianstrauch brianstrauch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@brianstrauch
brianstrauch enabled auto-merge (squash) October 30, 2026 20:49
@brianstrauch
brianstrauch merged commit 96cb83e into temporalio:main Oct 30, 2026
15 checks passed
campoy added a commit that referenced this pull request Nov 1, 2026
#313 maps the model's arguments onto a function Activity's parameters.
This branch already does that with signature.bind for every form, so its
version is kept, with #313's reason for passing defaults. #313's test
stays.
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.

2 participants