Documentation
¶
Overview ¶
Package wefttest provides a scriptable weft.Model, in the spirit of httptest: write the agent's dialogue as a sequence of scripted model steps and test agents offline, deterministically, with no network.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrScriptExhausted = errors.New("wefttest: model script exhausted (agent made more model calls than the script provides)")
ErrScriptExhausted is the stream error a Model yields when the agent makes more model calls than the script provides — almost always a test bug worth failing loudly.
Functions ¶
func Golden ¶
Golden compares got against the committed golden file at path. With -update it writes got (creating parent directories); otherwise a mismatch fails the test with a line diff, and a missing file fails with a hint to regenerate. Note the flag goes after the package list (`go test ./... -update`): placed before it, the go tool routes it to the wrong package's binary.
func TestManifest(t *testing.T) {
b, err := weft.Manifest(newAgent())
if err != nil { t.Fatal(err) }
wefttest.Golden(t, "weft.json", b)
}
Types ¶
type Call ¶
type Call struct {
Name string
Args string // raw JSON; "{}" when empty
ID string // optional; "call_N" within the turn when empty
}
Call describes one scripted tool invocation.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is a scripted weft.Model. It plays one Turn per Stream call, in order, and records every ModelRequest it received for assertions.
func (*Model) Info ¶
Info identifies the scripted model, so RunStart.Model and manifests carry a non-zero value in tests.
func (*Model) Requests ¶
func (m *Model) Requests() []weft.ModelRequest
Requests returns every ModelRequest the agent sent, in order — assert on system prompts, transcript shape, and the tool catalog the model saw.
type Turn ¶
type Turn struct {
// contains filtered or unexported fields
}
Turn is the script for one model call, built by Say, ToolCalls, or Fail.
func MaxTokens ¶
MaxTokens scripts a step that hit the output-token limit: the text so far, then a max_tokens finish. The run records it on RunResult.StopReason (and the StepRecord) rather than failing; truncated tool-call arguments decode as error results the model recovers from.
func Say ¶
Say scripts a completed assistant reply: one text delta, then a normal stop. Usage is fixed at 10 input / 5 output tokens per scripted step, so usage accounting is assertable.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package conformance is the provider adapter contract as an executable table.
|
Package conformance is the provider adapter contract as an executable table. |