Documentation
¶
Overview ¶
Package flowjudge validates multi-agent voice flows by simulating a live room and judging turns with an LLM — not hardcoded word lists.
Typical use (ADSL desks):
h := flowjudge.New(llm,
flowjudge.WithAgentRunner(adsl.FlowJudgeRunner(rt)),
flowjudge.WithJudge(flowjudge.JudgeConfig{Rubric: flowjudge.VoiceRoomRubric}),
)
rep, err := h.Simulate(ctx, flowjudge.Room{
Human: flowjudge.ScriptedHuman{"Hey Julia, let's speak English.", "Bring everyone."},
Pick: flowjudge.FixedPicker("agent/Julia", "agent/sarah"),
})
Harness.Run still supports scripted steps. Quality defaults to the AI judge when WithJudge is set; optional mechanical [Check]s are only for infra (empty reply, latency), not product language rules.
Index ¶
- Constants
- func Spoken(text string) string
- type AIHuman
- type AgentRunner
- type AgentRunnerFunc
- type AgentTurn
- type Check
- type Failure
- type Flow
- type Harness
- func (h *Harness) JudgeCall(ctx context.Context, transcript []string) (Verdict, error)
- func (h *Harness) JudgeTurn(ctx context.Context, mode string, speaker string, utterance string, ...) (Verdict, error)
- func (h *Harness) Run(ctx context.Context, flow Flow) (Report, error)
- func (h *Harness) Simulate(ctx context.Context, room Room) (RoomReport, error)
- type Human
- type JudgeConfig
- type Option
- type Report
- type Room
- type RoomReport
- type RoomState
- type ScriptedHuman
- type SpeakerPicker
- type SpeakerPickerFunc
- type Step
- type StepReport
- type StepResult
- type Verdict
Constants ¶
const VoiceRoomRubric = `` /* 953-byte string literal not displayed */
VoiceRoomRubric is the default LLM-as-judge brief for multi-agent voice desks.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AIHuman ¶
type AIHuman struct {
Provider niro.Provider
Model string
Persona string
Options niro.Options
MaxLines int
}
AIHuman uses an LLM to improvise the next user line in the room.
type AgentRunner ¶
type AgentRunner interface {
RunTurn(ctx context.Context, agentID string, input map[string]any, history []niro.Message) (AgentTurn, error)
}
AgentRunner runs one agent turn (e.g. ADSL Runtime.RunAgent + Collect).
type AgentRunnerFunc ¶
type AgentRunnerFunc func(ctx context.Context, agentID string, input map[string]any, history []niro.Message) (AgentTurn, error)
AgentRunnerFunc adapts a function to AgentRunner.
type AgentTurn ¶
AgentTurn is the result of an AgentRunner call.
type Check ¶
type Check func(StepResult) []Failure
Check judges one step result. Return zero or more failures.
func DeskDefaults ¶
func DeskDefaults() []Check
DeskDefaults is an alias of InfraDefaults kept for older call sites.
func InfraDefaults ¶
func InfraDefaults() []Check
InfraDefaults is the only automatic mechanical gate: non-empty reply. Product quality belongs to the AI judge (WithJudge / Harness.Simulate).
func LatencyUnder ¶
LatencyUnder fails when step latency exceeds d.
type Harness ¶
type Harness struct {
// contains filtered or unexported fields
}
Harness runs flows against a provider and/or agent runner.
func (*Harness) JudgeTurn ¶
func (h *Harness) JudgeTurn(ctx context.Context, mode string, speaker string, utterance string, transcript []string) (Verdict, error)
JudgeTurn asks the judge model to score one agent utterance in room context.
type Human ¶
type Human interface {
Next(ctx context.Context, st RoomState) (text string, done bool, err error)
}
Human produces the next human utterance (scripted or AI).
type JudgeConfig ¶
type JudgeConfig struct {
Provider niro.Provider // defaults to harness provider
Model string
Rubric string // defaults to VoiceRoomRubric
Options niro.Options
}
JudgeConfig configures the AI self-validator.
type Option ¶
type Option func(*Harness)
Option configures a Harness.
func WithAgentRunner ¶
func WithAgentRunner(r AgentRunner) Option
WithAgentRunner enables Step.Agent / Harness.Simulate execution.
func WithJudge ¶
func WithJudge(cfg JudgeConfig) Option
WithJudge enables LLM-as-judge self-validation (preferred quality path).
func WithOptions ¶
WithOptions sets default generation options for raw provider turns.
type Report ¶
type Report struct {
Name string
Steps []StepReport
}
Report is the full flow outcome.
type Room ¶
type Room struct {
Name string
HumanName string // default "Alex"
Human Human
// Pick chooses which agent speaks next. Required.
Pick SpeakerPicker
// Present is passed into each agent Input["present"] (optional roster).
Present []string
// MaxHumanTurns stops after this many human utterances (0 = until Human done).
MaxHumanTurns int
// PeerBeats inserts this many peer-continue turns after each human+reply pair.
PeerBeats int
// JudgeEachTurn runs the AI judge after every agent utterance (default: when WithJudge).
JudgeEachTurn *bool
// JudgeCall runs a final whole-transcript AI judge (default: when WithJudge).
JudgeCall *bool
MaxLatency time.Duration // optional infra gate only
}
Room simulates being in a live multi-agent voice call.
type RoomReport ¶
type RoomReport struct {
Name string
Transcript []string
Turns []StepReport
Call *Verdict
}
RoomReport holds per-turn and optional whole-call AI verdicts.
func (RoomReport) Passed ¶
func (r RoomReport) Passed() bool
Passed is true when every turn passed and the optional call judge passed.
func (RoomReport) String ¶
func (r RoomReport) String() string
String summarizes the room simulation.
type RoomState ¶
type RoomState struct {
Transcript []string
LastSpeaker string
HumanTurns int
AgentTurns int
ExpectPeer bool
HumanName string
}
RoomState is the live simulation snapshot.
type ScriptedHuman ¶
type ScriptedHuman []string
ScriptedHuman plays fixed lines in order (like a rehearsal script).
type SpeakerPicker ¶
type SpeakerPicker interface {
Pick(ctx context.Context, st RoomState) (agentID string, peerContinue bool, err error)
}
SpeakerPicker chooses the next agent id and whether this is a peer-continue beat.
func FixedPicker ¶
func FixedPicker(agentIDs ...string) SpeakerPicker
FixedPicker cycles agent ids; peer beats use ExpectPeer from room state.
type SpeakerPickerFunc ¶
type SpeakerPickerFunc func(ctx context.Context, st RoomState) (agentID string, peerContinue bool, err error)
SpeakerPickerFunc adapts a function to SpeakerPicker.
func (SpeakerPickerFunc) Pick ¶
Pick implements SpeakerPicker.
type Step ¶
type Step struct {
Name string
// Agent path (ADSL / custom runner).
Agent string
Input map[string]any
// Raw LLM path.
System string
User string
// Mode for the AI judge: "human" (default) or "peer".
Mode string
// Label appended into shared history as "Label: text" after the step.
// Defaults to Agent name, else Name.
As string
// Append this line to history before the turn (e.g. human utterance).
HistoryAppend string
Checks []Check
SkipJudge bool // skip AI judge even when WithJudge is set
MaxLatency time.Duration
Options niro.Options // optional per-step override
}
Step is one turn in a flow.
Prefer Agent+Input with WithAgentRunner for ARDL desks. Otherwise set System/User for a raw provider turn (prompt-level harness).
Quality is judged by the LLM when WithJudge is set — do not encode product language rules as Checks. Checks are for infra only (empty, latency).
type StepReport ¶
type StepReport struct {
Name string
Agent string
Text string
Latency time.Duration
Failures []Failure
Judge *Verdict
}
StepReport is the outcome of one step.
func (StepReport) Passed ¶
func (s StepReport) Passed() bool
Passed reports whether the step had no failures.