Testing a flow
Build a flow, drive a request through the http.Handler from bb.Handler, and assert on the reply — or unit-test a handler by constructing an agent with bb.FixedModel(...). For structured output, bb.Extract[T] gives you the typed value to assert against. See the package tests under internal/flow and internal/serve for patterns.
Mocks for every public interface
Every package that exports an interface ships a mock.go alongside it, with a Mock<Name> implementation you can inject in place of the real thing — no need to hand-roll a fake per test file. Notably:
model.Mock— amodel.Modelthat streams scriptedChunks/ToolCallsor returns a cannedFail/Rejecterror, withGot/Seenfor asserting what was asked.model.MockSchema— amodel.Schema(tool argument schema) that returns itself fromJSONSchema.agent.MockSchema— anagent.Schema(structured-reply schema) with a settableErrso both the valid and invalidValidatepaths are one field away.flow.MockStore— an in-memoryflow.Storefor durability tests.flow.MockScheduler/flow.MockWebhooks— recordDefer/Registercalls (inCalls/Hooks) instead of actually scheduling anything, so a test can fire the capturedRunitself.engine.MockStore/engine.RecordTracer— the same idea at thepkg/enginelayer.
Reach for these before writing a local stub: a test-only reimplementation of an interface that already has a mock is duplication, not isolation.