Repository navigation
Description
Problem
Since #1363, chat_structured tells every provider the reply's schema in the system message, but only two get a wire-level constraint: the gateway provider sends response_format (json_schema, no strict) and the ollama provider sends format. The claude, openai and copilot providers are prompt-only, so their replies can still drift from the schema and cost a reflection retry, or fail the item after it.
OpenAI's strict structured outputs need every property listed in required and additionalProperties: false, so a pydantic model's schema needs a strict-compatible transform first (pydantic-ai ships OpenAIJsonSchemaTransformer). Anthropic's API constrains output through a tool's input_schema.
Proposed remedy
Add each provider's native mechanism once #595's probes show which deployments honour it, reusing the schema transform from the library rather than a hand-written one. A provider whose deployment doesn't honour it stays prompt-only, and the provider docs say so.
Acceptance criteria
- A request-body test per provider asserts the constraint it sends, or asserts that it sends none and why.
- The schema transform comes from an existing dependency; no hand-rolled schema rewriting.
- Tests are offline, each call phase stays under 1 s, and
uv run devops cipasses.
Found while delivering #1363. Related: #1363, #595.
Proposed design
Problem statement
The claude, openai, and copilot providers in chat_structured rely only on a prompt-level schema instruction. Their replies can drift from the expected schema, causing a reflection retry or an item failure. The gateway and ollama providers already send a wire-level constraint, but the other three do not. This item adds the native constraint for each of those three providers using pydantic-ai output modes.
Acceptance criteria
- Criterion 1: A request-body test per provider (claude, openai, copilot) asserts the constraint it sends, or asserts that it sends none with a stated reason.
Verification: Run the per-provider test suite. Each test inspects the outgoing request body and asserts the presence or absence of the constraint field. - Criterion 2: The schema transform uses pydantic-ai's existing
OpenAIJsonSchemaTransformer; no hand-rolled schema rewriting is added.
Verification: Search the diff for any new schema-transformation function. Confirm the only transform imported isOpenAIJsonSchemaTransformerfrompydantic_ai.profiles.openai. - Criterion 3: All tests are offline, each call phase stays under 1 s, and
uv run devops cipasses.
Verification: Runuv run devops ciin a clean environment. Confirm no network calls in tests, each test phase completes under 1 s, and the full CI pipeline exits 0.
Key questions
- What mechanism provides the per-provider constraint?: pydantic-ai output modes (
NativeOutput,ToolOutput,PromptedOutput) as each provider's profile supports them, rather than each SDK's own mechanism. Land it on refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001's seam. (proposed) - Where does the schema transform come from?: pydantic-ai's
OpenAIJsonSchemaTransformer, already imported in the ollama provider atsrc/devops_cli/ai/models/ollama.py:23. [sources: src/devops_cli/ai/models/ollama.py:23, src/devops_cli/ai/models/init.py:12] - Which providers get a wire-level constraint and which stay prompt-only?: Determined by feat(cli): measured per-deployment capability probes replacing parameter-count failover floors #595's probes showing which deployments honour the constraint. A provider whose deployment does not honour it stays prompt-only, and the provider docs say so. (proposed)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsNew
Activity
dan-petty-bot commentedon Oct 8, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
It reduces schema-drift retries and failures across three providers but the system already functions via prompt-only constraints, so it is an important quality improvement rather than a blocking defect.Eliminating prompt-only drift for claude, openai, and copilot saves reflection retries and prevents item failures, a meaningful reliability gain for users relying on structured outputs.Three providers each need their native constraint wired in plus a shared schema transform from an existing dependency and per-provider request-body tests, but the heavy lifting (transform library) is already available.dan-petty commentedon Oct 8, 2026
Owner decision on #1001, 2026-10-08: the model seam is pydantic-ai models. This item's per-provider constraint then comes from pydantic-ai's output modes (
NativeOutput,ToolOutput,PromptedOutput) as each provider's profile supports them, rather than from each SDK's own mechanism. The acceptance criterion stays a request-body test per provider. Land it on #1001's seam.dan-petty commentedon Oct 26, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The change improves correctness and reliability of AI responses, but is not critical for core functionality.Improves data consistency and reduces retries in AI interactions which benefits end users.Requires integration with multiple providers and testing, but reuses existing schema transforms.Both items work on structured outputs; item 1003 refactors the validation path while this item adds constraints to providers.dan-petty commentedon Oct 28, 2026
Status set to Ready at d509dba (see proposed design in issue body).
refactor(ai): chat_structured is the one structured-output path (#2452)