Repository navigation
Conversation
…gs and runner defaults An agentAsTool run started a new TemporalOpenAIRunner with only the sandbox, so a nested agent with no model of its own went to the Worker's default model without the run's settings, and its model Activities lost the runner's defaultModelParams (timeout, summary, retry, task queue, local Activity). As upstream agent.asTool() does, the nested run now takes the run's runConfig.model for agents that set no model, runConfig.modelSettings without toolChoice and parallelToolCalls, and the runner's defaultModelParams. This is behind a patched() marker, asked only when there is something to take, so nested runs recorded before this change replay without them.
…rs and test old histories Rename the patch to openai-agents.agent-tool-run-config and add a replay test with a history recorded before this change, whose nested model call is an Activity under a runner that sets useLocalActivity.
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
An
agentAsToolrun now takes what upstreamagent.asTool()passes to a nested run, instead of only the sandbox:runConfig.model, for nested agents that set no model of their own. A nested agent with its own model keeps it, as natively;runConfig.modelSettings, withouttoolChoiceandparallelToolCalls, which pick the outer agent's tools (upstreamgetSafeInheritedAgentToolModelSettingsleaves out the same two);defaultModelParams, so nested model Activities get the same timeout, summary, retry policy, task queue and local-Activity setting as the rest of the run. The Client header'smodelParamsstill win over them, as for the parent.How: the runner already handed its sandbox to each
agentAsTooltool through a symbol-keyed hook. That hook now carries the run's model, settings and runner defaults too.convertAgentgets an optionalmodelNameDefault, used only by agents whose model is the framework's empty placeholder, next to the existingmodelNameOverride. No public name or signature changes. The README's "Nested agent tools" section says what the nested run takes.Replay and rollback: taking the run's settings is behind
patched('openai-agents.agent-tool-run-config'), asked only when the calling run has a model, settings or runner defaults to pass. Runs with nothing to pass, like the README example, record no marker.useLocalActivityreplays its nested model call as a local Activity instead of the recorded Activity and fails with[TMPRL1100] ... No command scheduled for event ... ActivityTaskScheduled. An inheritedmodelSettings.retrycould likewise add model calls to a run that caught a failed nested call (by reading the code; not run).[TMPRL1100] ... Non-deprecated patch marker encountered). To roll back, keep this version and decline the patch with the Worker'spatchActivationCallback(experimental in SDK 1.24), or use Worker Versioning. Runs without the marker can roll back to the earlier version.Why?
See #243.
agentAsToolstarted the nested run withnew TemporalOpenAIRunner()and a run config that held only the sandbox. In a run that sets a model or model settings, a nested agent with no model of its own went to the Worker provider's default model without the run's settings, and the run completed with that answer. The nested runner also never saw the calling runner'sdefaultModelParams, so a Workflow started without the plugin's Client (by a Schedule or the CLI) had no way to set its nested agents' model Activity options: a runner retry limit of 2 attempts became unlimited for a nested call.Checklist
Closes [Bug] openai-agents (TypeScript): agentAsTool runs drop the run's model, model settings and runner defaults #243
How was this tested:
agentAsTool runs take the run model, model settings and runner defaultsintest-openai-agents.ts: a lead with twoagentAsTooltools, one agent with no model and one with its own, underrunConfig: { model: 'run-model', modelSettings: { temperature: 0.33, toolChoice: 'auto' } }and a runner with a 17-second timeout and a summary. It checks the model name and settings each call gets and the timeout and summary of all four model Activities. Onmainit fails at the first check (- '',+ 'run-model': the nested agent with no model got the Worker's default); it passes with the change.convertAgentcase formodelNameDefault: an agent with no model and a handoff target with no model take it, an agent with its own model keeps it, andmodelNameOverridestill wins.agentAsTool runs recorded before they took the runner defaults still replay, withsrc/__tests__/histories/agent-tool-local-activity-before-fix.json, recorded onmainfrom a Workflow whose runner setsuseLocalActivity, so its nested model call is an Activity. It passes onmainand with the change, and fails with the change minus its gate ([TMPRL1100] ... No command scheduled for event HistoryEvent(id: 6, ActivityTaskScheduled)).make lint(the 8 warnings already onmain, none in changed files),make test(210 tests,main's 207 and the three new ones),make build, the npm package check, the smoke install,check_conventions.pyand Prettier with the SDK settings pass. The Node 22, macOS and Windows cells did not run locally.mainatc664a34, and 0 with the change: the nested call goes torun-modelwithtemperature: 0.33and a 17-second timeout, as the native control does.main(two of them finished on the change) and the 9 from runs started on it;main, the 10 histories without the marker replay, and the 6 with it fail with[TMPRL1100] ... Non-deprecated patch marker encountered, as expected for a gate;mainfinish on the change; one with a run model takes it from its next nested call on and records the marker then;patchActivationCallback, a marked run waiting on the change finishes on its new path, and a new run takes the old path with no marker;main, and finishes once the change is back; an unmarked one finishes onmain;main's local-Activity history with[TMPRL1100] ... No command scheduled for event HistoryEvent(id: 6, ActivityTaskScheduled);[TMPRL1100]on both builds.main. All results above are from the combined change.Any docs updates needed?
The README's "Nested agent tools" section is updated here.
Not covered:
toolExecution,toolNotFoundBehavior,toolNameCollisionPolicy,tracingandtracingDisabledto nested runs. This change covers the model, settings and Activity options only.modelProvideris not part of the plugin's run config, so there is nothing to pass.agentAsToolruns are not streamed.modelSettings.retryinheritance and its replay effect were checked by reading the code, not run.Related: the plugin's top-level
runConfig.modelreplaces every agent's model, while upstream uses it only for agents that set none. This change does not touch that; nested runs follow upstream, so a nested agent with its own model keeps it.Overlap: #236 (agent hooks) also adds a fifth parameter to
convertAgentand editsrunner.ts, #238 editsconvertAgentand #240 editsrunner.ts, so whichever merges later may need a small rebase.Open questions:
tracingDisabled,tracing, tool execution settings)?Draft while the gate and these questions are open.