Skip to content

fix(tool): default toOpenAIResponses to non-strict - #408

Merged
glebedel merged 3 commits into
mainfrom
s2d2/audit-responses-non-strict
Nov 11, 2026
Merged

glebedel merged 3 commits into
mainfrom
s2d2/audit-responses-non-strict

Conversation

@glebedel

@glebedel glebedel commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

toOpenAIResponses() defaulted to strict: true. OpenAI's strict mode requires every property in required and every nested object closed, and the SDK only closes the root, so OpenAI rejected every StackOne tool with an optional or open nested field. That includes the OpenAI Responses example, which failed on main with a 400.

  • src/tool.ts: BaseTool.toOpenAIResponses() and Tools.toOpenAIResponses() now default to strict: false. { strict: true } still closes the root, for schemas that already meet the rest. JSDoc on both describes the default.
  • README.md: the schema table describes the new default.
  • src/tool.test.ts: both modes pinned on BaseTool and Tools. Two of these tests fail against main's src/tool.ts.
  • tests/examples/openai-responses-integration.test.ts: checks no tool goes out strict.

Behaviour change for callers who used the default and relied on OpenAI enforcing the schema: pass { strict: true } to keep it. Their schemas must already be strict-compatible, as before.

Dogfood: the OpenAI Responses example against the real OpenAI API

examples/openai-responses-integration.ts, unchanged (it calls tools.toOpenAIResponses() with no options), run on Node 24.22.1 against a local StackOne MCP stand-in built from mocks/mcp-server.ts, with the real OpenAI API.

main:

BadRequestError: 400 Invalid schema for function 'bamboohr_list_employees': In context=('properties', 'query'), 'additionalProperties' is required to be supplied and to be false.
exit=1

This PR:

Tool calls found: 2
  Tool: bamboohr_list_employees
  Arguments: {"query":{"limit":5}}
  Tool: workday_list_workers
  Arguments: {"query":{"limit":5}}
exit=0

Test plan

  • pnpm vitest run src/tool.test.ts src/toolsets.test.ts tests/examples: 380 passed, no type errors
  • The default-mode tests fail against main's src/tool.ts (2 failed) and pass here
  • pnpm run lint (oxfmt, oxlint type-aware with type-check, knip): pass. pnpm build and publint: pass

Gates

Gate Result Head
Repo skills None in repo (Nix-managed, gitignored). Read .claude/rules/*. release-please not applied: no release in scope 1889726
/forge:forge Ran (meter, rewrite loop). JSDoc trimmed to 3 lines. Meter vs main: +24 -22, 6 comment lines (JSDoc on two public methods and one test line), longest block 3, type escapes 0, copies 0. Density flag is the diff being mostly doc lines 1889726
Security scan (security-reviewer agent + Aikido) No findings at threshold 70. Sub-threshold: strict was never a local validation step, so arguments reach execute() the same way in both modes, as with toOpenAI() and toAnthropic(). Aikido: 30 open critical/high on main, all in pnpm-lock.yaml or .github/actions/setup-nix/action.yaml, none in a changed file 54a7b9b
Codex security pass No findings 54a7b9b
/security-review Pass: no secrets, injection, auth or new requests. Platform-specific items not applicable to a client library 1889726
/code-review 7 findings. Fixed: Tools.toOpenAIResponses() JSDoc, a test for the bulk default, the example test now checks the strict flag. Not changed: making strict mode rewrite nested schemas (a separate, larger change), toAISDK() closing the root and strict replacing a served root additionalProperties (both existing, documented behaviour) 54a7b9b, fixes in 1889726
CI Green (25 pass, 5 skipped by design, 1 neutral) 1889726
Review threads 0 unresolved 1889726

The commits after 54a7b9b add tests and JSDoc only, with no runtime change.

Post-merge validation

Library: ships with the next release-please release. After publishing, run examples/openai-responses-integration.ts with the published package. The signal is the model's tool calls printed with exit 0. The regression signal is the 400 above.

Requested by guillaume@stackone.com in Slack (repo audit thread).

🤖 Generated with Claude Code

s2d2-s1 and others added 3 commits November 11, 2026 09:46
OpenAI's strict mode requires every property in `required` and every nested
object closed. The SDK only closes the root, so with strict as the default every
StackOne tool with an optional or open nested field was rejected with a 400
("'additionalProperties' is required to be supplied and to be false"), including
the OpenAI Responses example.

- toOpenAIResponses() and Tools.toOpenAIResponses() now default to strict: false
- { strict: true } still closes the root, for schemas that already meet the rest
- JSDoc and README describe the new default; tests pin both modes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
- Tools.toOpenAIResponses() JSDoc states the default and points at the strict notes
- Unit test checks the bulk default is non-strict, not only the explicit option
- The Responses example test checks no tool goes out strict

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
@glebedel
glebedel requested a review from a team as a code owner November 11, 2026 09:54
@glebedel glebedel self-assigned this Nov 11, 2026
@pkg-pr-new

pkg-pr-new Bot commented Nov 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@408

commit: 1889726

@glebedel
glebedel merged commit 091d23d into main Nov 11, 2026
32 checks passed
@glebedel
glebedel deleted the s2d2/audit-responses-non-strict branch November 11, 2026 10:11
glebedel added a commit that referenced this pull request Nov 12, 2026
… to non-strict

#408 made toOpenAIResponses non-strict by default, so passing it and
explaining that strict mode rejects optional fields is redundant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
glebedel added a commit that referenced this pull request Nov 13, 2026
* fix(examples): make the framework examples run end to end

Running every example against a local StackOne MCP stand-in, with real
OpenAI and Claude models, showed four examples that fail or print the
wrong thing on main:

- openai-responses-integration: OpenAI rejects the strict schema (400
  "additionalProperties is required" for nested query objects), so the
  example and README now pass { strict: false }, as the toOpenAIResponses
  doc already advises for StackOne actions.
- ai-sdk-integration: AI SDK 5+ tool calls carry `input`, not `args`, so
  the example printed "Arguments: undefined".
- anthropic-integration: claude-haiku-4-5-20241022 is not a model id;
  the Claude Haiku 4.5 id is claude-haiku-4-5-20251001.
- claude-agent-sdk-integration: a headless query cannot answer a
  permission prompt, so the StackOne MCP tools are now listed in
  allowedTools and actually run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>

* fix(examples): scope the auto-approved Claude Agent SDK example to list actions

allowedTools runs every tool on the StackOne server without a prompt, so
the example and README now fetch only the list actions the prompt needs
rather than every action, writes included. The README Anthropic snippet
also gets the Claude Haiku 4.5 id the example already uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>

* docs(examples): drop strict:false now that toOpenAIResponses defaults to non-strict

#408 made toOpenAIResponses non-strict by default, so passing it and
explaining that strict mode rejects optional fields is redundant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>

---------

Co-authored-by: S2D2 <s2d2@stackone.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
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