Repository navigation
Add provider-native structured output and scoped sampling - #121
Open
arthurianresolve wants to merge 51 commits into
Open
arthurianresolve wants to merge 51 commits into
arthurianresolve wants to merge 51 commits into
Conversation
…-structured-output # Conflicts: # crates/dspy-rs/src/core/lm/mod.rs # crates/dspy-rs/src/trace/span.rs
arthurianresolve
marked this pull request as ready for review
November 9, 2026 20:20
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
…ides # Conflicts: # crates/dspy-rs/src/core/lm/mod.rs
…ured-output # Conflicts: # crates/dspy-rs/src/adapter/chat.rs # crates/dspy-rs/src/ir/interp.rs # crates/dspy-rs/src/predictors/predict.rs # crates/dspy-rs/src/typesys/coerce.rs
arthurianresolve
added a commit
to arthurianresolve/DSRs
that referenced
this pull request
Nov 19, 2026
Integrate krypticmouse#121 — Add provider-native structured output and scoped sampling
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Feature
Project typed output signatures into provider-compatible JSON Schema and request native structured output when the configured LM supports it.
Use JSON mode for open-ended maps and retain the delimiter parser when native formatting is unavailable. Preserve canonical field names and metadata when parsing provider JSON.
Include scoped sampling identities for retries and sampled optimizer rollouts, plus SIMBA and refine selection improvements carried on this branch. Cache keys include formatted messages, generation settings, output-format options, and sampling identity.
Return an explicit error for image responses without text or tool calls, both on the initial completion and after tool execution. Preserve mixed responses containing usable text or tool calls.
Document automatic response-format selection, custom-endpoint opt-in, and scoped sampling for response-cache reuse.
Keep model endpoint identity useful in traces without disclosing credentials.
Correct task/field docstrings and feature-specific commands in examples 01–09. Exercise their actual signatures through delimiter and native-schema requests, and add a live Ollama matrix with typed correctness checks.
Keep cached system prompts separate by output format, propagate fallible Jinja rendering in native mode, and enforce nested hard assertions while retaining nested soft checks in provider JSON.
Make the local Ollama example's
--inspect-onlypath exit before any request.Add typed signature-level conversation history, tool declarations and tool-call outputs. Route tool-enabled signatures through native function calling or an explicitly configured prompt fallback, preserving typed metadata and strict replay.
Validate special-field inputs before calling the provider, accept absent optional context, and keep tool-loop limits and typed failures consistent across native and fallback paths.
Fixes #72
Fixes #58
Fixes #71
Fixes #75
Fixes #85
Related work
Testing
New Migrate specials.rs (History, ToolCall, NoTool) to typed architecture #72 coverage: 23 LM unit tests and 26 focused integration tests passed (14 special-field cases, 9 tool-loop cases, 3 native-rendering cases). The two explicitly invoked live cases also passed with Ollama 0.40.16 and
llama3.2:3b: native function calling and prompt fallback.The new special types use the current Facet/Schema architecture.
schemarsremains required by the active provider output-schema bridge; these special types do not depend on it. Seedocs/typed-history-tools.mdfor protocol selection and typed examples.The resolved stack at
2b4590f0174dc05582347b8da75b6b58fbce9ca0passed 209 tests with--no-default-featuresand 247 with defaultdata/cachefeatures (2 live tests ignored in each offline run). These are focused library and integration suites, not the full workspace test suite. Later ancestry-only integration merges preserve the validated source trees.Local HTTP tests use the real provider client for the actual example signatures, delimiter and JSON Schema payloads, docstrings, output parsing and malformed-response retention.
Three native/rendering regressions verify output-format cache separation, Jinja errors before provider execution, and nested assertions/soft checks.
Final integrated live matrix: all 9 example cases passed against temporary Ollama 0.40.16 on WSL Ubuntu 24.04 with
llama3.2:latest(3.2B, Q4_K_M; digesta80c4f17acd55265feec403c7aef86be0c25983ab279d83f3bcd3abbcb5b8b72). Cache disabled, temperature 0, schema opt-in enabled; Windows Rust client used the Linux HTTP endpoint. The matrix finished in 103 seconds.The live cases assert Paris/Berlin/Rome, 100/1000, positive sentiment, valid rating ranges and nonempty reasoning where required.
git diff --check— passed. The full workspace test suite was not run.AI Disclosure