Documentation
¶
Overview ¶
Package longtest drives the real harness (local sandbox, coding profile) through long scripted sessions: a fake model that behaves like an agent doing 50-200 steps of read_file / search_files / edit_file / execute_command in a generated repository, with realistic tool-output sizes (some 20-60 KB, which trigger spill and masking). It exists to check what only long sessions break: compaction, masking, prompt-prefix stability, steering, memory and goroutines, and the stop paths (retry, loop guard, step budget).
Nothing here needs a network or a key. Live-ready long tasks are in bench/tasks_long.go.
Index ¶
- Constants
- func AppendOnlyExceptMasks(prev, next []*ai.Message) (firstDiff, newlyMasked int, err error)
- func AssertAppendOnly(prev, next []*ai.Message) error
- func CallsText(c llmtest.Call) string
- func DefaultAction(step int) (string, string)
- func ExtraTool(name string, run func(ctx context.Context, args string) (string, error)) tools.Provider
- func Fingerprint(m *ai.Message) string
- func IsMaskStub(m *ai.Message) bool
- func Repo() map[string]string
- func SettledGoroutines(want int, wait time.Duration) int
- func Tokens(c llmtest.Call) int
- type CompactionInfo
- type Outcome
- type Scenario
Constants ¶
const ( AgentsMarker = "LONGTEST-AGENTS-MARKER-7731" Request = "Tune every module in pkg/ (replace each TODO marker with DONE), keeping the notes in AGENTS.md. LONGTEST-REQUEST-MARKER-4419" PlanTitle = "Tune all modules LONGTEST-PLAN-MARKER-2208" )
Markers the assertions look for after compaction.
const ( Modules = 40 BigFiles = 6 )
Variables ¶
This section is empty.
Functions ¶
func AppendOnlyExceptMasks ¶
AppendOnlyExceptMasks is AssertAppendOnly that tolerates one change: a tool result of prev replaced by its mask stub in next (masking moves the boundary as the prompt grows). It returns the index of the first message that differs (len(prev) when none does), so callers can measure how much of the previous request a cache keeps, and how many results were newly masked.
func AssertAppendOnly ¶
AssertAppendOnly reports an error unless next starts with prev, message for message and byte for byte: what a provider's prompt cache needs between two consecutive steps of a run. It is the strict form; use AppendOnlyExceptMasks for runs where tool-output masking is on.
func DefaultAction ¶
DefaultAction is the 4-step cycle of the simulated agent: read a module, search for its marker, edit it, then run a command (every third group one that prints 45 KB, which spills and is later masked).
func ExtraTool ¶
func ExtraTool(name string, run func(ctx context.Context, args string) (string, error)) tools.Provider
ExtraTool wraps a func as a tools.Provider with one tool.
func Fingerprint ¶
Fingerprint is the byte-exact identity of a message as the provider sees it.
func IsMaskStub ¶
IsMaskStub reports whether a tool message is the stub masking leaves behind.
func Repo ¶
Repo returns the generated repository: AGENTS.md, Modules packages of one ~3 KB file each (with one TODO marker to edit), and BigFiles 60 KB logs.
func SettledGoroutines ¶
SettledGoroutines waits (retrying) until the goroutine count is at most want and returns the last count: goroutines that are winding down are not leaks.
Types ¶
type CompactionInfo ¶
type CompactionInfo struct{ Before, After int }
Outcome is what a run left behind. CompactionInfo is a completed work.compaction event.
type Outcome ¶
type Outcome struct {
// Status is "finished" or the RUN_ERROR code / outcome type.
Status string
Dir string
// Calls are the agent's own model requests, in order (summarizer and title calls excluded).
Calls []llmtest.Call
// Replies[i] is the turn answered to Calls[i].
Replies []llmtest.Turn
// Compactions are the indexes into Calls of the first request after a compaction that changed the
// history (summarized, truncated or dropped), from the work.compaction events. It assumes one model
// call per step, i.e. a run without step retries.
Compactions []int
// SummarizerCalls is the number of summarizer requests.
SummarizerCalls int
// CompactionInfo[i] describes Compactions[i] (token estimates from the event).
CompactionInfo []CompactionInfo
Events []store.Event
Steps int
Wall time.Duration
// Shutdown is how long h.Run took to return after the run finished.
Shutdown time.Duration
ModelTime time.Duration
// Heap samples (bytes in use) at each model call when Sample is set.
Heap []uint64
HeapBefore, HeapAfter uint64
GoroutinesBefore, GoroutinesAfter int
RunID string
}
type Scenario ¶
type Scenario struct {
// Steps is the number of model steps of the agent; the last one answers (default 150).
Steps int
// Window is the model's context window in tokens (default 60000).
Window int
// Threshold is COMPACTION_THRESHOLD (default 0.7).
Threshold float64
// MaxSteps is AGENT_MAX_STEPS (default Steps+20).
MaxSteps int
// StepRetries is LLM_STEP_RETRIES (default 3).
StepRetries int
// Steers maps an agent step to a steer sent during that step's model call.
Steers map[int]string
// Action returns the tool call (name, JSON arguments) of an agent step before
// the last; "" ends the step with a plain answer. Default: DefaultAction.
Action func(step int) (name, args string)
// Wrap lets a test change the turn of an agent step (failure injection).
Wrap func(step int, t llmtest.Turn) llmtest.Turn
// Tools are extra tool providers.
Tools []tools.Provider
// Sample records the heap at every model call (a brief stop-the-world each);
// leave it off to measure the harness's own speed.
Sample bool
// Timeout bounds the run (default 3 minutes).
Timeout time.Duration
// ModelDelay is slept in every model call (simulated latency).
ModelDelay time.Duration
// NoMask turns tool-output masking off (COMPACTION_KEEP_RECENT_TOOL_RESULTS=0), so
// the context grows until compaction has to cut it.
NoMask bool
// CancelAtStep, when > 0, cancels the run CancelDelay after the model call of that step
// (to cut a tool that hangs).
CancelAtStep int
CancelDelay time.Duration
// NoFinish makes the model never answer: it keeps calling tools (step budget tests).
NoFinish bool
}
Scenario describes one long run.