generated from coulomb/repo-seed
Set response_format json_schema strict=False in OpenRouter adapter
The previous strict=True default rejected the activity-core daily-triage schema (and most real-world application schemas) because OpenAI strict mode requires additionalProperties:false on every object and every property in the required list. Application-supplied schemas typically do not meet that bar — adding additionalProperties recursively at the adapter would be surprising and may break callers that rely on extra fields. Flipping strict to False keeps the schema as a soft constraint; the model still produces structured output and the activity-core canary's 400 from OpenRouter goes away. Callers who need strict enforcement can pass response_format directly via model_params, where the adapter's pass-through handling preserves the strict flag they set. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -181,12 +181,20 @@ def _merge_model_params(payload: Dict[str, Any], model_params: Dict[str, Any]) -
|
||||
except (ValueError, TypeError):
|
||||
schema = None
|
||||
if isinstance(schema, dict):
|
||||
# strict=False: OpenAI's strict mode requires additionalProperties
|
||||
# to be false on every object and every property in the required
|
||||
# list. Most application-supplied schemas are not written that
|
||||
# way (the activity-core daily-triage schema, for example, has
|
||||
# neither). With strict=False, OpenRouter still honours the
|
||||
# schema as a soft constraint and the model's output remains
|
||||
# structured. Callers can opt back into strict by including
|
||||
# `strict: true` themselves in a custom `response_format`.
|
||||
payload["response_format"] = {
|
||||
"type": "json_schema",
|
||||
"json_schema": {
|
||||
"name": "structured_output",
|
||||
"schema": schema,
|
||||
"strict": True,
|
||||
"strict": False,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user