Resolve the requested mode against the provider's native capability. `Auto`/`Tool` always resolve to forced `Tool` mode — the most reliable cross-provider strategy (the synthetic `emit_*` tool is made mandatory via the provider's `tool_choice`). `Strict`/`Json` use native `response_format` only when the provider reports [`NativeStructuredSupport::JsonSchema`]; otherwise they fall back to forced `
(requested: StructuredMode, support: NativeStructuredSupport)
| 888 | /// otherwise they fall back to forced `Tool` mode rather than silently |
| 889 | /// degrading to unconstrained text. |
| 890 | fn resolve_mode(requested: StructuredMode, support: NativeStructuredSupport) -> StructuredMode { |
| 891 | match requested { |
| 892 | StructuredMode::Prompt => StructuredMode::Prompt, |
| 893 | StructuredMode::Strict if support == NativeStructuredSupport::JsonSchema => { |
| 894 | StructuredMode::Strict |
| 895 | } |
| 896 | StructuredMode::Json if support == NativeStructuredSupport::JsonSchema => { |
| 897 | StructuredMode::Json |
| 898 | } |
| 899 | // Auto, Tool, or Strict/Json on a provider without json_schema support. |
| 900 | _ => StructuredMode::Tool, |
| 901 | } |
| 902 | } |
| 903 | |
| 904 | /// Build the provider directive for an already-resolved mode. |
| 905 | fn build_directive(req: &StructuredRequest, mode: StructuredMode) -> StructuredDirective { |
no outgoing calls
no test coverage detected