Package model/modeltest
Go module github.com/bide-ai/bide; all packages.
github.com/bide-ai/bide/model/modeltest · pkg.go.dev · Stability: core
Package modeltest checks an HTTP-backed agent.Model against the streaming contract the agent loop relies on:
Functions
func CheckFinish(t testing.TB, f agent.Finish): CheckFinish checks the Finish a first-party adapter sends.func CheckSSEPrefix(t testing.TB, streamSSE func(body io.ReadCloser, send func(agent.Emit) bool), body []byte, cut int): CheckSSEPrefix checks, on top of ReadSSE's properties for body and for its first cut bytes, that a response cut short is never a success that differs from the whole response's success: a connection that closes partway must not turn a truncated answer into a complete one.func Run(t *testing.T, newModel func(baseURL string, client *http.Client) agent.Model, event func(i int) string): Run runs the checks.func ToolConfig(t *testing.T, newModel func(baseURL string, client *http.Client) agent.Model): ToolConfig checks that the adapter refuses a tool setup every provider rejects with agent.ErrConfig, before it sends anything: a tool name outside [a-zA-Z0-9_-] or longer than 64 characters, two tools with one name, and a tool choice that cannot be met (an unknown mode; "required" or "tool" with no tools declared; "tool" naming no tool or one not declared).func ToolNames(t *testing.T, newModel func(baseURL string, client *http.Client) agent.Model, refused, accepted []string): ToolNames checks the adapter's own tool-name rule against names an MCP server may list (the MCP grammar is 1 to 128 of A-Z a-z 0-9 _ - ., wider than every provider's): each name in refused must fail with agent.ErrConfig that quotes the name, before anything is sent, and each name in accepted must reach the provider.
type SSEResult
go
type SSEResult struct {
Emits []agent.Emit
Msg agent.Message
Usage agent.Usage
Err error
}SSEResult is what an adapter's SSE reader made of one response body: every Emit it sent, in order, and the message, usage, and error a consumer reading them gets.
Constructors and functions
func ReadSSE(t testing.TB, streamSSE func(body io.ReadCloser, send func(agent.Emit) bool), body []byte) SSEResult: ReadSSE runs an adapter's SSE reader (streamSSE, which reads body and sends each event through send) over body and checks the properties every response must keep, whatever its bytes: