harness

package
v1.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package harness is what a workspace's harness learns from its runs (spec_048_harness_learning): the evidence of what went wrong in its sessions, drawn from the audit log without a model, for the reflector and /skills update and /agents update to propose changes from.

Index

Constants

View Source
const MaxItems = 200

MaxItems bounds the evidence, so the reflector's prompt stays small.

Variables

This section is empty.

Functions

func IsCorrection

func IsCorrection(prompt string) bool

IsCorrection reports whether a prompt rejects the last answer.

Types

type Evidence

type Evidence struct {
	Since time.Time
	// Items are patterns first, then the most frequent and most recent.
	Items []Item
	// Dropped is how many items MaxItems left out.
	Dropped int
	// Used counts the turns each skill and agent was in ("skill/deploy",
	// "agent/qa"), whether they went well or not.
	Used map[string]int
	// NoAudit means the audit log is off, so there's no evidence.
	NoAudit bool
}

Evidence is what went wrong in a workspace's sessions since a time.

func Build

func Build(in Inputs) Evidence

Build makes the evidence from in.

func (Evidence) About

func (e Evidence) About(about string) Evidence

About is the evidence about skills, agents or rules (with guardrails) only, for /skills update, /agents update and /rules update; "" all of it.

func (Evidence) Patterns

func (e Evidence) Patterns() int

Patterns is how many items are patterns: what the welcome tile counts (HE-05).

func (Evidence) Score added in v0.8.4

func (e Evidence) Score() int

Score is what the suggestion to reflect weighs (HE-62): the patterns, the costly ones (an undo, a limit, a refusal by the user) twice.

func (Evidence) Text

func (e Evidence) Text() string

Text is the evidence as the reflector reads it: one line per item, then where it was seen.

type Inputs

type Inputs struct {
	// Since is where the evidence starts.
	Since time.Time
	// Audit is the workspace's audit log since then, in the order written.
	Audit []audit.Entry
	// NoAudit means the audit log is off, so there's no evidence.
	NoAudit bool
	// Sessions are the workspace's sessions, by ID. Unless it's nil, the
	// entries of sessions it leaves out (evals' cases) are skipped, and so
	// are those that name neither a session nor a workspace.
	Sessions map[string]Session
	// Fixes are the health judge's latest suggestions, by item
	// ("skill/deploy", HL-10).
	Fixes map[string][]string
}

Inputs are what the evidence is made from.

type Item

type Item struct {
	Kind Kind
	// Subject is the tool, rule, guardrail, skill or agent it's about.
	Subject string
	// Target is the command or path, or for a limit which one.
	Target string
	Count  int
	First  time.Time
	Last   time.Time
	// Seen are the latest occurrences, at most three, newest first.
	Seen []Seen
	// Fixes are the health judge's suggestions for the subject.
	Fixes []string
	// contains filtered or unexported fields
}

Item is one thing that happened, as often as it happened.

func (Item) Patterned

func (it Item) Patterned() bool

Patterned reports whether the item is a pattern (HE-03 step 1): it happened at least twice, or once with a cost: a change undone, a turn at a limit, an action the user refused.

type Kind

type Kind string

Kind is what an evidence item is about.

const (
	ToolFailed Kind = "tool_failed" // a tool call that failed, or a command that exited nonzero
	Denied     Kind = "denied"      // an action the user, the auto reviewer or a permission rule refused
	Blocked    Kind = "blocked"     // a guardrail's block
	Revised    Kind = "revised"     // a rule that sent the work back, or blocked it
	Steered    Kind = "steered"     // a message the user sent while the agent worked
	Corrected  Kind = "corrected"   // a prompt that rejects the last answer
	Undone     Kind = "undone"      // /undo, or a rewind
	Stopped    Kind = "stopped"     // a turn the user stopped
	Limited    Kind = "limited"     // a turn that reached a limit (Target: steps, cost or time)
	Skill      Kind = "skill"       // a skill used in turns that went wrong
	Agent      Kind = "agent"       // an agent invoked in turns that went wrong
	// ScratchRemade is a file under .agents/scratch written again in
	// another session; ScratchScript a script there run again in another
	// session (HE-61). Each counts sessions, not writes or runs.
	ScratchRemade Kind = "scratch_remade"
	ScratchScript Kind = "scratch_script"
)

Kinds of evidence (HE-02).

type Seen

type Seen struct {
	Session string
	Title   string
	Origin  string
	// Turn counts the session's prompts within the evidence, from 1.
	Turn    int
	Time    time.Time
	Excerpt string
	// Agent is the agent that was refused or whose tool failed, when the
	// audit log says.
	Agent string
	// Then is, for a failed call, what worked after it in the same turn:
	// the next call of the same tool that succeeded, by its command or
	// path, or "the same call, retried" (HE-60); "" when none did.
	Then string
}

Seen is one occurrence of an item.

type Session

type Session struct {
	Title string
	// Origin is a job's ("worker") or a detached ("background") run; ""
	// a chat.
	Origin string
	// Agent is the session's agent.
	Agent string
}

Session is what the evidence says about a session.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL