diff options
| author | Mohamed Hegazy <8000722+mhegazy@users.noreply.github.com> | 2026-05-30 22:32:02 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-30 22:32:02 -0700 |
| commit | 3d368d2972d9af8f52e96ae7d86d2686967af31f (patch) | |
| tree | d53d81ca144defe40aaf27062d176f4696289dac /plugins | |
| parent | 2a822c0787435b7924377c26b7d02be171df7814 (diff) | |
| parent | 84011d43b1de3303592d566a01b9466d5f7be191 (diff) | |
Merge pull request #2105 from anthropics/fix-2098-output-config-format
security-guidance: migrate _call_claude from deprecated output_format to output_config.format (#2098)
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/security-guidance/hooks/llm.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/plugins/security-guidance/hooks/llm.py b/plugins/security-guidance/hooks/llm.py index 5cb55f54..72728c39 100644 --- a/plugins/security-guidance/hooks/llm.py +++ b/plugins/security-guidance/hooks/llm.py @@ -479,10 +479,21 @@ def _call_claude(prompt, output_schema, thinking_budget=10000, max_tokens=16000, "max_tokens": max_tokens, "system": CLAUDE_CODE_SYSTEM_PROMPT, "messages": [{"role": "user", "content": prompt}], - "output_format": { - "type": "json_schema", - "schema": output_schema - } + # API moved the structured-output schema from top-level `output_format` + # to `output_config.format` per + # https://platform.claude.com/docs/en/build-with-claude/structured-outputs. + # The old form "continues to work for a transition period" for some + # auth modes (API key + non-streaming), but is rejected with + # `invalid_request_error: output_format: This field is deprecated. + # Use 'output_config.format' instead.` for others (OAuth Bearer + + # newer CLI versions hit it consistently — reporter saw 462 errors + # in one day). See #2098. + "output_config": { + "format": { + "type": "json_schema", + "schema": output_schema, + }, + }, } if thinking_budget > 0: # Models trained on adaptive thinking (4.6+) reject the budget_tokens @@ -490,7 +501,10 @@ def _call_claude(prompt, output_schema, thinking_budget=10000, max_tokens=16000, # models (4.5 and earlier, all 3.x) reject adaptive. Pick by model. if _model_supports_adaptive_thinking(payload["model"]): payload["thinking"] = {"type": "adaptive"} - payload["output_config"] = {"effort": "high"} + # Merge `effort` into the existing output_config dict (which + # now carries the `format` schema) rather than reassigning — + # otherwise the schema is silently overwritten. See #2098. + payload["output_config"]["effort"] = "high" else: payload["thinking"] = { "type": "enabled", |
