// confidence checks that the evidence an agent read supports the diagnosis // behind the action it proposes. A System One judge reads the diagnosis, what // the agent read and the action, and answers with a level and the gap it found. // The guard is advisory, its verdicts recorded and no ceiling set, until the // eval result shipped in this package shows the judge model passing its // threshold. An action no agent proposed has no diagnosis, so it is not judged. // // Settings: judge_api selects systemone (the default) or openai-decisions. // judge_base_url and judge_model name the endpoint and model; systemone // requires both, and openai-decisions defaults them to the OpenAI API and // gpt-6-luna. eval_max_age_days is how long a passing eval stays trusted // (default 90). // Secret: judge_api_key, optional. package main import ( "context" _ "embed" "errors" "time" "github.com/samcharles93/archipelago/guards/confidence/internal/judge" "github.com/samcharles93/archipelago/sdk/guard" "github.com/samcharles93/archipelago/sdk/judgegate" ) //go:embed eval_result.json var recordedEval []byte type confidence struct { judge *judge.Judge // standing is the judge's recorded eval standing; the guard is advisory // unless it is trusted. standing judgegate.Standing } func build(cfg guard.Config) (guard.Guard, error) { return newConfidence(cfg, recordedEval, time.Now) } func newConfidence(cfg guard.Config, evalJSON []byte, now func() time.Time) (*confidence, error) { client, ok, err := judgegate.NewClient(cfg) if err != nil { return nil, err } if !ok { return nil, errors.New("judge_base_url and judge_model are required") } maxAge, err := judgegate.MaxAge(cfg) if err != nil { return nil, err } j, err := judge.New(client) if err != nil { return nil, err } return &confidence{judge: j, standing: judgegate.StandingOf(evalJSON, client.ModelID(), now(), maxAge)}, nil } // Describe is advisory until the recorded eval passes: the whole guard is a // model's opinion, so there is nothing else to count. func (c *confidence) Describe() guard.Description { return guard.Description{Name: "confidence", Version: "1.0.0", Advisory: !c.standing.Trusted} } func (c *confidence) Judge(ctx context.Context, a guard.Action) (guard.Verdict, error) { tc, ok := judge.CaseOf(a) if !ok { return guard.Verdict{Ceiling: guard.ActQuietly, BlindSpots: []string{"no agent diagnosis came with this action, so there was nothing to check"}}, nil } out, err := c.judge.Assess(ctx, tc) if err != nil { return judgegate.FailedVerdict(out.Call.Failed(err, c.standing)), nil } v := out.Verdict(c.standing) if !c.standing.Trusted { v.BlindSpots = append(v.BlindSpots, "advisory, so it sets no ceiling: "+c.standing.Reason) } return v, nil } func main() { guard.Serve(build) }