Repository navigation
[typescript/openai-agents] add inputProperty to activityAsTool for Activities with a scalar parameter - #216
Draft
campoy wants to merge 2 commits into
Conversation
…meter activityAsTool passes the model's arguments to the Activity as one object. An Activity whose parameter is a string, such as greet(name: string), got that object as the string and returned a wrong value with no error. The new optional inputProperty field of the tool definition names one property of the arguments. When it is set, the Activity gets that property's value instead of the whole object. A name that is not in parameters fails the Workflow with an AgentsWorkflowError. Without the field, the Activity gets the same input as before.
This was referenced Oct 27, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was changed
activityAsToolgets an optionalinputPropertyfield on its tool definition. It names one property ofparameters. When it is set, the Activity gets that property's value as its argument instead of the whole arguments object:parameters.propertiesfails the Workflow with a non-retryableAgentsWorkflowError, asconvertAgentdoes for other tool mistakes. A typo would otherwise sendundefined, the same kind of silent wrong value. The check runs whenTemporalOpenAIRunner.runconverts the agent, before the first model call, and again when the tool is invoked. It does not run whenactivityAsToolis called, so a tool declared at module level cannot stop the Workflow bundle from loading.API change: additive. The new field is optional and existing tools behave the same.
Old runs and rollback: a tool call schedules the same Activity as before; only its input changes when the field is set, and Temporal does not compare Activity inputs on replay. No
patchedgate is needed, and histories replay on either version. Rolling back is not safe for runs that will still call a tool withinputProperty: the previous release ignores the field, so a tool call scheduled after the rollback sends the whole arguments object again (Hello, [object Object]!). Activities scheduled before the rollback keep their recorded input. Before rolling back, let those runs finish, or remove the field and change the Activity to take the object.Why?
See #211. An existing Activity with one string parameter, such as
greet(name: string), got{"name":"Ada"}as its string, returnedHello, [object Object]!, and the run completed with no error. The plugin knows the Activity only by name, so it needs to be told which value to send.Checklist
Closes [Bug] openai-agents (TypeScript): activityAsTool gives a one-string Activity the arguments object #211
How was this tested:
activityAsTool inputProperty gives a scalar Activity one property of the argumentsinsrc/__tests__/test-openai-agents.ts, with its Workflows inworkflows/openai-agents.ts: a real Worker and a fake model that callsgreetwith{"name":"Ada"}. Withtools.tsfrommainit fails ont.deepEqual(received, [['Ada']])(the Activity got[{ name: 'Ada' }]); with this change it passes. The same Worker runs a Workflow whose tool, declared at module level, hasinputProperty: 'nmae'; it fails with a non-retryableAgentsWorkflowErrorand the Activity never runs. That module-level tool is in the bundle every Workflow test in this file loads, so those tests also show the bundle still loads. With a check inactivityAsToolitself, the test fails at import withinputProperty 'nmae' is not a property in parameters.src/__tests__/convert-agent.test.ts:convertAgentandinvokethrowAgentsWorkflowErrorfor an unknown name and for an inherited one (toString), and a valid name passes.typescript/openai-agents:make lintpasses (the 8 warningsmainhas, none in files this PR touches),make testpasses (209 tests),make buildpacks, andscripts/ci/check_conventions.pypasses. Prettier with the SDK's settings is clean on the changed files.main'stools.ts. The Activity got the whole object (Hello, [object Object]!); resumed on this branch, it returnedHello, Ada!. Both histories replayed on both versions. The rollback paragraph above describes this.CI covers the other Node versions and platforms.
Any docs updates needed?
The README paragraph, included here.
Related: #212 reports the same problem for
nexusOperationAsTool; its PR adds the same field with the same name and check. #213's PR addsincludeContextto the same tool definition and changes the sameinvokecode. The PRs don't depend on each other, but they add tests next to each other, so whichever merges second needs a small rebase.Open questions:
toArgs: ({ name }) => [name], which would also cover Activities with two or more parameters but runs a callback in Workflow code. This PR keeps the smaller field and uses the same name fornexusOperationAsTool.ActivityAsToolOptionsnext to the timeouts? It sits next toparametersbecause it names one of its properties.Draft while these questions are open.