Skip to content

[typescript/openai-agents] add inputProperty to nexusOperationAsTool for Operations with a scalar input - #217

Draft
campoy wants to merge 1 commit into
mainfrom
fix/openai-agents-typescript-nexus-tool-string-input-misbound
Draft

campoy wants to merge 1 commit into
mainfrom
fix/openai-agents-typescript-nexus-tool-string-input-misbound

Conversation

@campoy

@campoy campoy commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

What was changed

nexusOperationAsTool gets an optional inputProperty field on its tool definition. It names one property of parameters. When it is set, the Operation gets that property's value as its input instead of the whole arguments object:

const confirmTool = nexusOperationAsTool(
  bookingService.operations.confirm, // nexus.operation<string, string>()
  {
    name: 'confirm',
    description: 'Confirm a booking by its reference',
    parameters: {
      type: 'object',
      properties: { ref: { type: 'string' } },
      required: ['ref'],
      additionalProperties: false,
    },
    inputProperty: 'ref',
  },
  { service: bookingService, endpoint: 'booking-endpoint' }
);
  • Without the field, the Operation gets the same input as before.
  • A name that is not in parameters.properties fails the Workflow with a non-retryable AgentsWorkflowError, as convertAgent does for other tool mistakes.
  • README: the Nexus operation tools section shows the field.

API change: additive. The new field is optional and existing tools behave the same.

Old runs and rollback: a tool call schedules the same Nexus Operation as before; only its input changes when the field is set, and Temporal does not compare inputs on replay. No patched gate is needed, and the previous release is a safe rollback (see testing).

Why?

See #212. An Operation whose input is a string, nexus.operation<string, string>(), got {"ref":"BK-7"} as its input, returned confirmed [object Object], and the run completed with no error. An Operation definition carries no input type at run time, so the plugin needs to be told which value to send.

Checklist

  1. Closes [Bug] openai-agents (TypeScript): nexusOperationAsTool gives a string-input Operation the arguments object #212

  2. How was this tested:

    • New test nexusOperationAsTool inputProperty gives a scalar-input Operation one property of the arguments in src/__tests__/test-openai-agents.ts, with its Workflow in workflows/openai-agents.ts: a real Worker, a Nexus endpoint for a handler on the same Worker, and a fake model that calls confirm with {"ref":"BK-7"}. With nexus-tools.ts from main it fails on t.deepEqual(received, ['BK-7']) (the handler got { ref: 'BK-7' }). With this change it passes.
    • New case inputProperty not in parameters throws AgentsWorkflowError in src/__tests__/nexus-tools.test.ts. It fails with nexus-tools.ts from main and passes with this change.
    • Locally, in Docker (Node v24.22.0, pnpm 10.27.0, Linux arm64): make lint passes (the 8 warnings main has, none in files this PR touches), make test passes (209 tests; main has 207), make build packs, and check_npm_package.py, _shared/smoke.mjs and scripts/ci/check_conventions.py pass. Prettier with the SDK's settings is clean on the changed files.
    • [Bug] openai-agents (TypeScript): nexusOperationAsTool gives a string-input Operation the arguments object #212's reproduction: on 1.24.0 and main (c664a34) it exits 1 with and without --input-property; with this change, --input-property exits 0 (confirm got: "BK-7", run result: "confirmed BK-7") and the run without it is unchanged.
    • Replay check with a local dev server (Temporal CLI 1.9.1): finished runs recorded on a Worker with no Workflow cache, and runs held at the model call after the tool, on main and on this branch, with and without the field. All 9 histories replay on both builds. main's open run completed on this branch, and this branch's open runs completed on main with the Operation output they recorded. The SDK does not compare a Nexus Operation's name on replay (a history with confirm renamed replays cleanly), so the control renames the first model Activity instead; it fails with [TMPRL1100] on both builds.

    CI covers the other Node versions and platforms.

  3. Any docs updates needed?
    The README paragraph, included here.

Related: #211 reports the same problem for activityAsTool; its PR adds the same field with the same name and check. That PR and #213's PR add tests next to the ones here, so whichever merges second needs a small rebase. The PRs don't depend on each other.

Open question:

  • Is one property name the shape you want for both helpers? A mapper function, such as toInput: ({ ref }) => ref, would allow any input shape but runs a callback in Workflow code. This PR keeps the smaller field, with the same name as the activityAsTool PR.

Draft while this question is open.

…r input

nexusOperationAsTool sends the model's arguments to the Operation as one
object. An Operation whose input is a string, such as
nexus.operation<string, string>(), got that object as its input 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 Operation 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 Operation gets the same input as before.
@campoy
campoy force-pushed the fix/openai-agents-typescript-nexus-tool-string-input-misbound branch from df104a7 to 81628f4 Compare November 2, 2026 16:12
@campoy campoy changed the title Add inputProperty to nexusOperationAsTool for Operations with a scalar input [openai-agents-typescript] add inputProperty to nexusOperationAsTool for Operations with a scalar input Nov 16, 2026
@campoy campoy changed the title [openai-agents-typescript] add inputProperty to nexusOperationAsTool for Operations with a scalar input [typescript/openai-agents] add inputProperty to nexusOperationAsTool for Operations with a scalar input Nov 16, 2026

This branch has not been deployed

No deployments
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.

[Bug] openai-agents (TypeScript): nexusOperationAsTool gives a string-input Operation the arguments object

1 participant