Commit c2b5c44
authored
fix: populate required OpenResponses fields with non-null defaults (#4994)
# What does this PR do?
The OpenResponses conformance suite validates responses using strict Zod
schemas. Several fields that the OpenAI spec marks as **optional**
(omittable) are treated by OpenResponses as **required and
non-nullable**. llama-stack was returning \`null\` for these fields,
failing Zod validation before any semantic checks could run.
## Why not just change the schema types?
The Python schema in `openai_responses.py` is the source of truth for
our generated OpenAPI spec, which is diffed against
`openai-spec-2.3.0.yml` via `oasdiff --check-regression` in pre-commit.
Changing a field from `list | None` to `list` (non-nullable) would alter
the generated spec and lower our OpenAI conformance score.
**Example `logprobs` on `OutputTextContent`:**
The OpenAI spec at `docs/static/openai-spec-2.3.0.yml` defines:
```yaml
OutputTextContent:
properties:
logprobs:
items:
$ref: '#/components/schemas/LogProb'
type: array # non-nullable when present
required:
- type
- text
- annotations # logprobs is NOT required — field may be omitted
```
The OpenAI spec says: *if logprobs is present it must be an array, never
null* but the field itself is optional (can be absent). Our old code
returned `null`, which violates even the OpenAI spec. OpenResponses goes
further and requires the field to always be present.
The fix: **keep the schema as `list | None = None`** (preserving our
oasdiff baseline) but **always emit `[]` in construction code** when
logprobs aren't available. This satisfies both: it's a valid non-null
array per OpenAI spec, and it's always present per OpenResponses. The
same rationale applies to every other field fixed in this PR.
## Fields fixed
For each field the schema definition is unchanged; only the construction
code is updated to emit a concrete non-null default:
- `background`: always `False` for non-background responses (was `None`)
- `tool_choice`: defaults to `"auto"` when not specified (was `None`)
- `truncation`: defaults to `"disabled"` when not specified (was `None`)
- `service_tier`: defaults to `"default"` when not specified (was
`None`)
- `tools`: always an array; `available_tools()` already returns `[]` not
`None`
- `temperature`: defaults to `1.0` when not specified (was `None`)
- `top_p`: defaults to `1.0` when not specified (was `None`)
- `logprobs`: always `[]` when not requested (was `None`, which also
violates the OpenAI spec)
Closes #4987
Closes #4988
Closes #4990
## Test Plan
- Integration tests for all three modes (docker, library, server) with
GPT provider pass
- `conformance.mdx` score is unchanged (no regression in OpenAI spec
conformance)
- OpenResponses conformance test (informational) passes
Signed-off-by: Charlie Doern <cdoern@redhat.com>1 parent 0fc1c91 commit c2b5c44
4 files changed
Lines changed: 17 additions & 10 deletions
File tree
- src
- llama_stack_api
- llama_stack/providers/inline/agents/meta_reference/responses
- tests/integration/responses
Lines changed: 14 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
223 | 229 | | |
224 | 230 | | |
225 | | - | |
| 231 | + | |
226 | 232 | | |
227 | | - | |
228 | 233 | | |
229 | 234 | | |
230 | 235 | | |
| |||
250 | 255 | | |
251 | 256 | | |
252 | 257 | | |
| 258 | + | |
253 | 259 | | |
254 | 260 | | |
255 | 261 | | |
| |||
258 | 264 | | |
259 | 265 | | |
260 | 266 | | |
261 | | - | |
| 267 | + | |
| 268 | + | |
262 | 269 | | |
263 | | - | |
| 270 | + | |
264 | 271 | | |
265 | 272 | | |
266 | 273 | | |
| |||
271 | 278 | | |
272 | 279 | | |
273 | 280 | | |
274 | | - | |
| 281 | + | |
275 | 282 | | |
276 | | - | |
| 283 | + | |
277 | 284 | | |
278 | 285 | | |
279 | 286 | | |
| |||
1050 | 1057 | | |
1051 | 1058 | | |
1052 | 1059 | | |
1053 | | - | |
| 1060 | + | |
1054 | 1061 | | |
1055 | 1062 | | |
1056 | 1063 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
712 | 712 | | |
713 | 713 | | |
714 | 714 | | |
715 | | - | |
| 715 | + | |
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
0 commit comments