Separate output contract inputs from resolved values

This commit is contained in:
2026-11-21 14:12:34 +00:00
parent dad302f1ff
commit 38a2dcca52
7 changed files with 103 additions and 31 deletions

View File

@@ -160,7 +160,7 @@ type RunRequest struct {
Execution *ExecutionTargetOverride
// Validation optionally replaces the prompt's complete output contract. It
// does not merge individual fields. Nil uses the prompt contract.
Validation *OutputContract
Validation *OutputContractInput
// AppendedMessages are already-rendered messages appended in caller order
// after every prompt definition message. Promptkit neither templates nor
// resolves files in them. Content must be valid UTF-8 and is preserved
@@ -490,8 +490,7 @@ type ExecutionTargetPresence struct {
TimeoutSeconds bool `json:"timeout_seconds"`
}
// OutputContract defines output and validation requirements and has a stable
// JSON representation.
// OutputContract describes resolved output and validation requirements.
//
// A non-nil RunRequest.Validation replaces the complete prompt contract. It
// does not merge fields. The public Engine performs bounded correction after a
@@ -520,6 +519,17 @@ type OutputContract struct {
RepairAttempts int `json:"repair_attempts"`
}
// OutputContractInput replaces a prompt's complete output contract. An omitted
// repair budget defaults to one for active validation and zero for none;
// an explicit zero disables repair. Schema selection follows OutputContract.
type OutputContractInput struct {
Format OutputFormat `json:"format"`
ValidationMode ValidationMode `json:"validation_mode"`
Schema any `json:"schema,omitempty"`
SchemaPath string `json:"schema_path"`
RepairAttempts *int `json:"repair_attempts,omitempty"`
}
// ValidationResult represents a completed output check and has a stable JSON
// representation. An operational inability to perform validation is returned
// as ErrValidation instead of a ValidationResult.