Skip to content

fix(tool): require plain-object parameter roots per OpenAI tools contract - #262

Merged
LeXwDeX merged 3 commits into
devfrom
fix/tool-params-object-root
Aug 14, 2026
Merged

fix(tool): require plain-object parameter roots per OpenAI tools contract#262
LeXwDeX merged 3 commits into
devfrom
fix/tool-params-object-root

Conversation

@LeXwDeX

@LeXwDeX LeXwDeX commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Summary

Structural replacement for the transport-level root-anyOf patch (#260, superseded):

  • workflow tool: Parameters nests the 10-branch discriminated union under a single params property — the provider-facing schema root is now a plain object on every transport. Call shape: { params: { action, ...fields } }.
  • Tool.define: construction-time assertion that parameters serialize to a plain object root (type: object, no root combinator). Violations fail tool registration with guidance instead of degrading at provider runtime.
  • provider transform: the openai-compatible root-anyOf → type: object patch is deleted — superseded by the source-level contract.
  • native runtime gate: keys off the SDK transport package (api.npm) instead of providerID, so OpenAI-compatible relays (local proxies, DeepSeek, GLM gateways) can use the native path.

Why (live-reproduced evidence)

Root-level combinators are outside the OpenAI tools contract:

The v1.0.11 type: object patch was necessary (DeepSeek) but insufficient (GLM needs no root combinator at all). This PR removes the need for any transport-level translation.

Test plan

  • New workflow-schema-contract.test.ts: plain-object root across 4 transports, 10 branches intact in params, decode shape, root shortcut rejected
  • tool-define.test.ts: root-combinator tool dies at construction with actionable message
  • Updated provider-schema/wire-shape/snapshot/byte-evidence tests
  • bun x tsgo --noEmit clean; bun test test/tool test/dag 814 pass / 0 fail
  • GLM end-to-end verification after release

fix(provider): object-root union schemas for all openai-compatible backends
…ract

Root-level anyOf in tool parameters violated the OpenAI tools contract:
OpenAI tolerated it, DeepSeek rejected it with a schema error, and GLM
silently emitted empty tool arguments (live-reproduced: five consecutive
workflow calls decoded as got {}). Replace the transport-level patch
with a structural contract:

- workflow Parameters: nest the 10-branch discriminated union under a
  single params property; the wire root is now a plain object
- Tool.define: assert at construction time that parameters serialize to
  a plain object root; violations fail registration with guidance
- provider transform: drop the openai-compatible root-anyOf patch,
  superseded by the source-level contract
- native runtime gate: key off the SDK transport package instead of the
  providerID so OpenAI-compatible relays can use the native path
@LeXwDeX
LeXwDeX force-pushed the fix/tool-params-object-root branch from 7bff31f to 2c89feb Compare August 14, 2026 09:55
@LeXwDeX
LeXwDeX merged commit f969b01 into dev Aug 14, 2026
5 checks passed
@LeXwDeX
LeXwDeX deleted the fix/tool-params-object-root branch August 14, 2026 10:00
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