Skip to content

Add provider-native structured output and scoped sampling - #121

Open
arthurianresolve wants to merge 51 commits into
krypticmouse:mainfrom
arthurianresolve:feature-structured-output
Open

arthurianresolve wants to merge 51 commits into
krypticmouse:mainfrom
arthurianresolve:feature-structured-output

Conversation

@arthurianresolve

@arthurianresolve arthurianresolve commented Nov 9, 2026 •

Copy link
Copy Markdown

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-only path 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. schemars remains required by the active provider output-schema bridge; these special types do not depend on it. See docs/typed-history-tools.md for protocol selection and typed examples.

  • The resolved stack at 2b4590f0174dc05582347b8da75b6b58fbce9ca0 passed 209 tests with --no-default-features and 247 with default data/cache features (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; digest a80c4f17acd55265feec403c7aef86be0c25983ab279d83f3bcd3abbcb5b8b72). 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

  • OpenAI Codex assisted with implementation, tests, and PR drafting.
  • all fixes and drafts have been human-architected, human-directed and human-reviewed before publication of PR requests.

@arthurianresolve
arthurianresolve marked this pull request as ready for review November 9, 2026 20:20
@mintlify

mintlify Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 46624e5.

Approve preview

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant