Skip to content

Propose runtime hooks for native agent tools - #277

Closed
campoy wants to merge 2 commits into
mainfrom
design/openai-agents-runtime-hooks
Closed

campoy wants to merge 2 commits into
mainfrom
design/openai-agents-runtime-hooks

Conversation

@campoy

@campoy campoy commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What was changed

This draft is intended to replace #270. It starts with the reviewed design and an executed proof; production plugin code and dependencies are unchanged. Keep #270 open until the replacement is implemented and ready.

The proposed implementation keeps #270's clone-free runner and native agent.asTool() objects. Two supported upstream runtime hooks, at effective run-configuration consumption and actual model resolution, replace its three prototype interceptions and tool-source registry. A bundle check rejects SDK copies without the contract.

The design under typescript/openai-agents/design/runtime-policy/ contains the developer-experience and maintenance comparisons and a self-contained runnable proof. Generated histories and logs are written under an ignored results directory; the dependency and plugin prototype edits are encoded once in prepare.py. Successful application code keeps the same native declarations and Temporal setup. Some unsupported nested configurations fail later, as tool output after the parent model Activity.

Why?

#270's review/rework loop repeatedly found another path around Activity dispatch as validation moved between SDK hooks. The remaining duplicate-SDK cases ran models inside the Workflow and repeated them during replay. The prototype blocks those paths while retaining the original native tool objects and their approvals, guardrails and handlers.

Related issues this replacement is intended to fix:

This draft does not close these issues yet.

Checklist

  1. Related issues: [Bug] openai-agents (TypeScript): agentAsTool runs drop the run's model, model settings and runner defaults #243, [Bug] openai-agents (TypeScript): agent.on(...) lifecycle hooks never run through TemporalOpenAIRunner #235 and [Bug] openai-agents (TypeScript): TemporalOpenAIRunner ignores the agent a custom Handoff's callback returns #237. Intended successor to Breaking: run TypeScript OpenAI Agents as written: agent.asTool() works, runConfig.model no longer overrides an agent's own model, agentAsTool is deprecated #270; do not close Breaking: run TypeScript OpenAI Agents as written: agent.asTool() works, runConfig.model no longer overrides an agent's own model, agentAsTool is deprecated #270 yet.
  2. Validation: 14 Worker cases on each build, each replayed; the unchanged Breaking: run TypeScript OpenAI Agents as written: agent.asTool() works, runConfig.model no longer overrides an agent's own model, agentAsTool is deprecated #270 head reproduces both duplicate-SDK inline calls and their replay repetition. The prototype records zero inline calls and rejects an unmodified second SDK copy at bundle time. All 21 selected existing tests pass, covering native defaults, options, approvals, hooks, handoffs, streaming, cancellation and sandbox behavior. Valid histories replay across both builds in both directions, a Workflow held after its native tool finishes completes across upgrade and rollback Worker replacement with no Workflow cache; a still-pending nested run was not checked, and the deliberate Activity-name control fails with [TMPRL1100]. The trimmed nine-file proof package was rerun end to end. Generated histories, logs and duplicate patch files are excluded from this PR. Proposal links, repository conventions and whitespace checks pass.
  3. Before merge: agree on, implement and release the upstream SDK contract; replace the integration's interception with it; verify both module formats, registration lifetime, cross-copy session acceptance and the supported CI matrix. The accepted Breaking: run TypeScript OpenAI Agents as written: agent.asTool() works, runConfig.model no longer overrides an agent's own model, agentAsTool is deprecated #270 upgrade and replay warnings still apply. No upstream issue or PR has been posted for the hook request yet.

@campoy campoy closed this Oct 29, 2026
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.

1 participant