Documentation
¶
Overview ¶
Package consensus implements multi-model voting for critical tasks. When enabled, a task prompt is fanned out to N providers in parallel. An AI judge then scores each response on correctness, safety, and completeness and returns the best response together with a decision report.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatReport ¶
FormatReport formats a consensus Report as a Markdown section suitable for appending to a task artifact.
func IsCritical ¶
isCritical returns true when the task should trigger consensus. A task is critical if its priority is 0 or 1 (P0/P1) or if it has the "critical" tag.
Types ¶
type CandidateResponse ¶
type CandidateResponse struct {
ProviderName string
Model string
Output string
Duration time.Duration
Err error
}
CandidateResponse holds a single provider's output and metadata.
type Report ¶
type Report struct {
TaskID int `json:"task_id"`
TaskTitle string `json:"task_title"`
Scores []Score `json:"scores"`
Winner string `json:"winner_provider"`
Timestamp time.Time `json:"timestamp"`
}
Report is the full consensus decision record attached to the task artifact.
func RunConsensus ¶
func RunConsensus( ctx context.Context, providers []provider.Provider, prompt string, opts provider.Options, judgeProvider provider.Provider, judgeModel string, n int, taskID int, taskTitle string, ) (string, *Report, error)
RunConsensus fans the prompt out to all provided providers (up to n), collects their responses, and uses judgeProvider to score them. It returns the winning response text plus a full Report for logging.
If only one provider is available (or n == 1), the single response is returned without calling the judge.
providers must contain at least one entry; judgeProvider is used only for the scoring call and may be the same as one of the providers.
type Score ¶
type Score struct {
ProviderName string `json:"provider"`
Model string `json:"model"`
Correctness int `json:"correctness"` // 1–10
Safety int `json:"safety"` // 1–10
Completeness int `json:"completeness"` // 1–10
Total int `json:"total"` // sum of the three dimensions
Rationale string `json:"rationale"`
}
Score holds a judge's assessment of one candidate.