testkit

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 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 testkit holds the Agent-free test doubles the root package's tests use, exported so a test in a package ABOVE the root (such as tools_test) can script a provider the same way. It imports core and schema only; a helper that constructed an Agent would import the root, and the root's own internal tests could not then import it.

Index

Constants

View Source
const TestAPI core.API = "test-api"

TestAPI is the wire API every scripted provider registers under.

Variables

This section is empty.

Functions

func AssistantWithTools

func AssistantWithTools(reason core.StopReason, blocks ...core.ContentBlock) core.AssistantMessage

AssistantWithTools is an assistant message carrying the given blocks.

func EchoTool

func EchoTool(name string, calls *atomic.Int32) core.Tool

EchoTool is a tool that answers {"echoed":true} and counts its calls.

func TestModel

func TestModel() *core.Model

TestModel is a resolved model on TestAPI.

func ToolUse

func ToolUse(t *testing.T, id, name, args string) core.ToolUseBlock

ToolUse builds a tool_use block from raw argument bytes.

Types

type Scripted

type Scripted struct {
	Turns []core.AssistantMessage

	// Seen records the message list each turn was asked to complete, so a
	// test can assert what the loop actually sent and when.
	Seen []core.Messages
	// Systems records the assembled system prompt per turn.
	Systems [][]core.ContentBlock
	// contains filtered or unexported fields
}

Scripted is a provider that replays a predetermined sequence of assistant messages, one per turn, and answers "done" once the script is exhausted. It is the executable double the loop is tested against; provider/faux is the shipped, supported form of the same idea.

func (*Scripted) SentAt

func (s *Scripted) SentAt(turn int) core.Messages

SentAt returns the messages the provider was asked to complete on turn.

func (*Scripted) Stream

func (s *Scripted) Stream(ctx context.Context, req core.Request) (<-chan core.StreamEvent, error)

Stream implements core.ProviderClient.

func (*Scripted) TurnsRun

func (s *Scripted) TurnsRun() int

TurnsRun reports how many requests the double has answered.

Jump to

Keyboard shortcuts

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