mock

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package mock ships two credential-free LLM providers and a recording wrapper that pair for offline testing of agent flows:

  • "echo" returns the user's last message as the model response. Zero config; useful for "does the binary boot?" smoke tests.

  • "scripted" replays a JSONL transcript turn-by-turn. Pair it with a recording captured against a real provider to exercise the agent loop without burning API quota.

  • NewRecorder wraps any model.LLM and appends each turn (request + response stream) to an io.Writer as JSONL. Recorded transcripts are consumed by the scripted provider via the same shared RecordedTurn type defined in format.go.

Tool execution at replay time uses the live environment, so the scripted provider faithfully replays the LLM side but not the wider tool surface — fine for testing prompt construction and loop shape, not for bit-exact session reproduction.

Index

Constants

View Source
const (
	ProviderEcho     = "echo"
	ProviderScripted = "scripted"
)

Provider names registered by this package.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is the mock implementation of models.Provider. It holds a single model.LLM (echo or scripted) and returns it from Model — the modelID argument is ignored because mocks aren't model-specific.

func NewEcho

func NewEcho() *Provider

NewEcho returns an echo Provider directly. Useful for library callers that want the mock without going through models.Resolve.

func NewScripted

func NewScripted(path string, strict bool) (*Provider, error)

NewScripted returns a scripted Provider that plays back the JSONL transcript at path. strict toggles request-shape validation per turn (see scriptedLLM for details).

func (*Provider) Model

func (p *Provider) Model(_ context.Context, _ string) (adkmodel.LLM, error)

Model returns the wrapped LLM. The modelID is accepted for interface compatibility but ignored; mock providers don't differentiate by model name.

func (*Provider) Name

func (p *Provider) Name() string

Name reports the provider identity ("echo" or "scripted").

Jump to

Keyboard shortcuts

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