Repository navigation
Commit 4386da7
committed
fix: normalize tool function schemas to always have root type: "object"
Some tool definitions (e.g. Codex `codex_app__automation_update`) arrive
without a `parameters` field or with `parameters: null`. When serialized,
that produces a JSON Schema whose root `type` is `null` (or missing).
Strict validators — such as DeepSeek — reject such schemas with HTTP 400.
Changes in two places to cover both forwarding paths:
1. `src/responses/parser.ts` (`buildTools`): Coerce every function tool's
`parameters` to a valid object-schema root. Covers the adapter
translation path (Anthropic, Gemini, Cursor, etc.).
2. `src/adapters/openai-responses.ts` (`createResponsesPassthroughAdapter`):
Add `normalizeToolSchemas()` that fixes top-level `tools` and Responses
Lite `additional_tools[].tools` before serialization. Required because the
passthrough path (e.g. DeepSeek with `wire_api=responses`) forwards
`_rawBody` verbatim and bypasses the parsed `context.tools`.
Fixes the 400 error: "Invalid schema for function: schema must be a JSON
Schema of 'type: \"object\"', got 'type: null'."1 parent e449521 commit 4386da7
2 files changed
Lines changed: 70 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
357 | 412 | | |
358 | 413 | | |
359 | 414 | | |
| |||
938 | 993 | | |
939 | 994 | | |
940 | 995 | | |
941 | | - | |
| 996 | + | |
942 | 997 | | |
943 | 998 | | |
944 | 999 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
140 | 153 | | |
141 | 154 | | |
142 | 155 | | |
143 | 156 | | |
144 | | - | |
| 157 | + | |
145 | 158 | | |
146 | 159 | | |
147 | 160 | | |
| |||
0 commit comments