
serv_shadow_agent when an incorrect answer costs more than an additional validation call.
What the shadow agent does
The normal model first produces a draft. SERV then asks a validator to judge that draft against the original request. If the draft fails, SERV asks the model to revise it and validates the new draft, up to the configured iteration limit. The caller receives the final draft. SERV records whether it passed unchanged, was corrected, exhausted its attempts, or could not be validated. It does not expose the validator as a tool call to your application.Configure the validator
hint adds task-specific criteria to the default meaningful-and-valid check. Make it observable and testable, such as “the answer must include the account ID” or “the recommendation must state missing information.” Avoid vague hints like “be better.”
max_iterations defaults to 3 and accepts values from 1 to 10. More attempts can improve difficult outputs, but increase latency and cost. Start with the default and raise it only when your evaluation data justifies the expense.
Because the validator sees the original task context, keep the important requirements in the system prompt and user request. Validate structured data in your application as well.
