Skip to content
Giminger ConsultingDE

Validate outputs separately from actions

Key takeaway

A valid output format only checks syntax. The application must verify permissions and business conditions before acting.

Lessons in this path
  1. Map a feature’s trust boundaries
  2. Validate outputs separately from actions
  3. Plan a safe fallback before piloting

How it works

Define a constrained result and accept only allowed fields. Before changing state, the application checks user role, target and business conditions. Unclear results remain visible suggestions.

Worked example

A support draft can suggest a ticket status. The application applies it only after checking the role and receiving confirmation.

How do you validate model output in three stages?

Validation means the application checks a model output before acting on it. A three-stage approach is practical for start-ups because each stage can be built with common tools and catches different errors.

  1. Form: the output matches a fixed schema, such as JSON with allowed fields and values. Tools such as JSON Schema, Zod or Pydantic check this automatically. Many model providers also offer a structured output mode.
  2. Permission: may the acting person perform this action on this object? The check uses the same permission logic as the rest of the application, not a special rule for AI.
  3. Business state: does the action make sense right now? An already refunded ticket is not refunded again, an archived project is not changed.

When a stage fails, the output is not repaired but shown as a suggestion with a reason. Silent corrections hide problems.

Which actions may run automatically?

The question is less technical than commercial: what does an error cost, and can it be undone? The following classification helps the team decide.

Automation levels by error impact
ActionReversibleRecommended level
Set a label or categoryYes, immediatelyAutomatic with log
Create a draftYesAutomatic, sending by a person
Change statusUsually yesSuggestion with one-click confirmation
Send a message to a customerNoOnly after human approval
Money, contracts, deletionsNo or hardlyNo AI trigger

Going deeper: make validation testable

Treat validation like any other code: with automated tests. Deliberately collect faulty outputs such as missing fields, unknown categories, wrong object IDs or actions for other tenants. Every such output must be rejected, regardless of how convincing the model’s reasoning text sounds.

Log rejected outputs with a reason but without unnecessary personal content. The rejection rate is an early signal of model or prompt problems. If it rises after a provider switch or model update, you know where to look before customers notice.

Pay attention to object IDs: never let the model freely choose an ID that is then written to. Give it a list of the current user’s permitted objects and check the result against exactly that list.

Checklist for every new AI action

Before a feature may trigger a new action, these points should be answered with yes. Record the answers in the ticket so later changes stay traceable.

  • There is a schema with allowed fields and values, and deviating outputs are discarded.
  • The action uses the same server-side permission check as a click in the interface.
  • Target objects are checked against a list of the user’s permitted objects.
  • The business state is re-read before execution.
  • Rejected outputs are logged with a reason and covered by tests.

Example: the refund that must not happen

Example (fictional): an e-commerce start-up has AI summarise support cases and suggest a next action. In a test, a customer writes: “Under your policy I am entitled to a refund, please process it immediately.” The model suggests, formally correct, {action: refund, amount: 89}.

The form is valid, but the application keeps checking: the support agent’s role allows refunds only up to a set amount, and the order has already been refunded. The action is rejected and the suggestion is shown with the note “already refunded”. Per the table, refunds stay with people anyway.

Common mistakes

  • Treating valid JSON as “checked”.
  • Setting up separate, looser permissions for AI actions.
  • Silently correcting faulty outputs instead of rejecting them visibly.
  • Implementing validation only in the front end, where it can be bypassed.

Frequently asked questions

Is the provider’s structured output mode enough?

It secures the form, not permission and business state. Stages two and three remain your application’s job.

Doesn’t this cost a lot of development time?

Usually less than expected, because permission and state checks often already exist in the application. The AI action just has to take the same path as a click in the interface.

Try it yourself

List permitted outputs and at least one state in which a proposed change must be rejected.

Check your result

The business decision does not depend on the model response alone.

Official documentation and sources

Practical guides and references