MCPcopy Create free account
hub / github.com/AI45Lab/Code / resolve_mode

Function resolve_mode

core/src/llm/structured.rs:890–902  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

888/// otherwise they fall back to forced `Tool` mode rather than silently
889/// degrading to unconstrained text.
890fn 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.
905fn build_directive(req: &StructuredRequest, mode: StructuredMode) -> StructuredDirective {

Callers 2

generate_blockingFunction · 0.85
generate_streamingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected