testkit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package testkit provides shared test doubles for harness and server integration tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentTokenEstimate

func ContentTokenEstimate(msgs []*tacklr.Message) int

ContentTokenEstimate is a shared length-based token stand-in for pressure tests.

Types

type RecordedError

type RecordedError struct {
	ID  json.RawMessage
	Err error
}

RecordedError is one WriteError call.

type RecordedResult

type RecordedResult struct {
	ID     json.RawMessage
	Result any
}

RecordedResult is one WriteResult call.

type RecordingWriter

type RecordingWriter struct {
	Results []RecordedResult
	Errors  []RecordedError
	Frames  [][]byte
	// contains filtered or unexported fields
}

RecordingWriter captures MessageWriter traffic for protocol tests.

func (*RecordingWriter) FrameCount

func (r *RecordingWriter) FrameCount() int

FrameCount returns the number of recorded frames (safe for concurrent poll).

func (*RecordingWriter) FramesAsMaps

func (r *RecordingWriter) FramesAsMaps(t *testing.T) []map[string]any

FramesAsMaps decodes recorded frames as JSON objects.

func (*RecordingWriter) SnapshotFrames

func (r *RecordingWriter) SnapshotFrames() [][]byte

SnapshotFrames returns a copy of recorded frames (safe for concurrent poll).

func (*RecordingWriter) WriteError

func (r *RecordingWriter) WriteError(id json.RawMessage, err error) error

func (*RecordingWriter) WriteFrame

func (r *RecordingWriter) WriteFrame(data []byte) error

func (*RecordingWriter) WriteResult

func (r *RecordingWriter) WriteResult(id json.RawMessage, result any) error

type ScriptedModel

type ScriptedModel struct {
	InvokeFn      func(ctx context.Context, msgs []*tacklr.Message, tools []*tacklr.Tool, ch chan<- tacklr.LLMResponseChunk)
	InvokeErr     error
	InvokeErrFn   func(ctx context.Context, msgs []*tacklr.Message, tools []*tacklr.Tool) error
	CountTokensFn func(ctx context.Context, msgs []*tacklr.Message, tools []*tacklr.Tool) (int, error)

	CallNum atomic.Int64

	SystemPrompts   []string
	LastInvokeMsgs  []*tacklr.Message
	LastInvokeTools []*tacklr.Tool
	// contains filtered or unexported fields
}

ScriptedModel is a cancel-aware InferenceStrategy for tests. Default CountTokens is sum of message content lengths (not zero), so window-pressure paths can fire when MaxWindowSize is small. Override CountTokensFn to customize.

func (*ScriptedModel) CompressContextWindow

func (m *ScriptedModel) CompressContextWindow() error

func (*ScriptedModel) CountTokens

func (m *ScriptedModel) CountTokens(ctx context.Context, msgs []*tacklr.Message, tools []*tacklr.Tool) (int, error)

func (*ScriptedModel) Invoke

func (m *ScriptedModel) Invoke(ctx context.Context, msgs []*tacklr.Message, tools []*tacklr.Tool) (chan tacklr.LLMResponseChunk, error)

func (*ScriptedModel) MaxContextWindow

func (m *ScriptedModel) MaxContextWindow() (int, error)

func (*ScriptedModel) Reset

func (m *ScriptedModel) Reset()

func (*ScriptedModel) SetSystemPrompt

func (m *ScriptedModel) SetSystemPrompt(p string)

func (*ScriptedModel) SupportsMIME

func (m *ScriptedModel) SupportsMIME(mimeType string) bool

func (*ScriptedModel) WithApiKey

func (*ScriptedModel) WithModel

func (*ScriptedModel) WithReasoningLevel

func (m *ScriptedModel) WithReasoningLevel(string) tacklr.InferenceStrategy

func (*ScriptedModel) WithStructuredOutput

func (m *ScriptedModel) WithStructuredOutput(any) tacklr.InferenceStrategy

func (*ScriptedModel) WithURL

Jump to

Keyboard shortcuts

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