Documentation
¶
Overview ¶
Package agenttest provides a scriptable agent.Provider for testing application code built on go-agent — agent wiring, tool registration, hooks, and run-loop behavior — without any network calls or API cost.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockProvider ¶
type MockProvider struct {
// Responses is consumed in order, one per Generate call; the last
// entry repeats if Generate is called more times than there are
// entries. Ignored when OnGenerate is set.
Responses []*agent.Response
// OnGenerate, if set, is called instead of consuming Responses.
OnGenerate func(req *agent.Request) (*agent.Response, error)
// NameValue overrides the provider name returned by Name(). Defaults
// to "mock".
NameValue string
// CapabilitiesValue is returned by Capabilities(), so tests can
// exercise capability-gated code paths (e.g. WithThinking validation).
CapabilitiesValue agent.Capabilities
// contains filtered or unexported fields
}
MockProvider is a scriptable agent.Provider. Set Responses for a fixed script, or OnGenerate for responses computed from the request (e.g. to assert on tool results from a previous turn before deciding what to return next).
func (*MockProvider) Calls ¶
func (m *MockProvider) Calls() []*agent.Request
Calls returns every request Generate has received so far, in order.
func (*MockProvider) Capabilities ¶
func (m *MockProvider) Capabilities() agent.Capabilities
Capabilities implements agent.Capable.
func (*MockProvider) Name ¶
func (m *MockProvider) Name() string
type MockStreamingProvider ¶
type MockStreamingProvider struct {
MockProvider
// StreamFunc builds the event stream for a Stream call. If nil, Stream
// synthesizes one from Generate (via Responses/OnGenerate): a single
// text_delta (if the response has text) and a tool_call_start per tool
// use, followed by message_done — enough to exercise RunStream call
// sites without hand-writing an EventStream.
StreamFunc func(req *agent.Request) (agent.EventStream, error)
}
MockStreamingProvider extends MockProvider with a scriptable Stream method, for testing streaming call sites (Agent.RunStream) without a real StreamingProvider. It is a distinct type from MockProvider — rather than MockProvider always implementing Stream — so tests can also exercise Agent's non-streaming-provider fallback path (see agent.WithStreamingFallback) with a provider that genuinely has no Stream method, matching how a real minimal Provider looks.
func (*MockStreamingProvider) Stream ¶
func (m *MockStreamingProvider) Stream(ctx context.Context, req *agent.Request) (agent.EventStream, error)
Stream implements agent.StreamingProvider.