-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouting_errors_example_test.go
More file actions
72 lines (61 loc) · 2 KB
/
routing_errors_example_test.go
File metadata and controls
72 lines (61 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package fizeau_test
import (
"errors"
"fmt"
"strings"
fizeau "github.com/easel/fizeau"
)
func ExampleErrHarnessModelIncompatible() {
err := fmt.Errorf("ddx preflight: %w", &fizeau.ErrHarnessModelIncompatible{
Harness: "gemini",
Model: "minimax/minimax-m2.7",
SupportedModels: []string{"gemini-2.5-pro", "gemini-2.5-flash"},
})
var routeErr *fizeau.ErrHarnessModelIncompatible
if errors.As(err, &routeErr) {
fmt.Printf("ddx failed bead: harness=%s model=%s supported=%s\n",
routeErr.Harness,
routeErr.Model,
strings.Join(routeErr.SupportedModels, ","))
}
fmt.Println(errors.Is(err, fizeau.ErrHarnessModelIncompatible{}))
// Output:
// ddx failed bead: harness=gemini model=minimax/minimax-m2.7 supported=gemini-2.5-pro,gemini-2.5-flash
// true
}
func ExampleErrPolicyRequirementUnsatisfied() {
err := fmt.Errorf("ddx preflight: %w", &fizeau.ErrPolicyRequirementUnsatisfied{
Policy: "local",
Requirement: "local-only",
AttemptedPin: "Harness=claude",
})
var routeErr *fizeau.ErrPolicyRequirementUnsatisfied
if errors.As(err, &routeErr) {
fmt.Printf("ddx failed bead: policy=%s conflict=%s requirement=%s\n",
routeErr.Policy,
routeErr.AttemptedPin,
routeErr.Requirement)
}
fmt.Println(errors.Is(err, fizeau.ErrPolicyRequirementUnsatisfied{}))
// Output:
// ddx failed bead: policy=local conflict=Harness=claude requirement=local-only
// true
}
func ExampleRouteDecision_candidates() {
decision := &fizeau.RouteDecision{
Candidates: []fizeau.RouteCandidate{
{Harness: "fiz", Provider: "local", Model: "qwen", Eligible: false, Reason: "provider is in cooldown"},
{Harness: "codex", Model: "gpt-5.4", Eligible: true, Reason: "score=71.2"},
},
}
for _, candidate := range decision.Candidates {
fmt.Printf("%s/%s eligible=%t reason=%s\n",
candidate.Harness,
candidate.Model,
candidate.Eligible,
candidate.Reason)
}
// Output:
// fiz/qwen eligible=false reason=provider is in cooldown
// codex/gpt-5.4 eligible=true reason=score=71.2
}