Structured output makes a response easier to validate, but a valid shape can still contain a wrong value. Treat schema validation and domain validation as separate checks. An exercise recommendation might satisfy JSON types while referencing an exercise that does not exist or using an impossible duration.
The contract to define first
Validate required fields and types at the boundary, then resolve identifiers and check domain constraints against authoritative data. Keep validation errors machine-readable so repair attempts can target the problem. Bound repair loops and preserve the original request. Never let a repair instruction widen permissions or quietly change the user’s goal.
A worked scenario
A hypothetical plan contains three exercise IDs and session durations. The schema accepts the IDs as strings, but one ID is absent from the catalog. Reject or repair that reference before saving. The user should not discover the problem halfway through a workout.
An implementation and review sequence
- Define shape and domain checks separately
- Resolve identifiers before committing state
- Limit repairs and retain useful validation diagnostics
Failure cases worth testing
| Condition or input | Expected behavior |
|---|---|
| Output is malformed | Reject before domain processing |
| JSON is valid but an ID is unknown | Fail the domain check |
| A repair repeatedly changes the requested plan | Stop and ask for a recoverable next step |
Download the illustrative acceptance checklist (JSON)
Tradeoffs and limits
Very rigid schemas can make exploratory tasks awkward. Use stricter contracts for persisted actions and allow clearly separated free-form explanation where the product needs flexibility.
Use the result to make a decision
The practical output is straightforward: provide schema validation and failed-output recovery examples. Keep the assumptions with the artifact so a product owner, implementer or prospective partner can review the same decision. A useful handoff states the supported scope, the evidence collected and the remaining dependency instead of treating a successful demonstration as proof of every operating condition.
Continue with related implementation detail
Related guide: A production prompt needs a testable contract.
AI action rollback and compensation
AI chat streaming that survives reconnects
References and current platform requirements
MCP specification and tool contracts
Google Cloud: AI security and safety for MCP
Platform capabilities, programme terms and access conditions can change. Check the linked primary references against the version and account you actually use; the patterns above do not establish a provider approval, certification or universal compatibility guarantee.
Discuss the workflow
Bring one workflow, its systems, and the actions requiring human approval.
Explore the relevant AptixLabs service
Does valid JSON guarantee a correct AI result?
Structured output makes a response easier to validate, but a valid shape can still contain a wrong value. Very rigid schemas can make exploratory tasks awkward.
Which failure cases should be included in the review?
Include these explicit cases: Output is malformed: reject before domain processing; JSON is valid but an ID is unknown: fail the domain check; A repair repeatedly changes the requested plan: stop and ask for a recoverable next step.
