description: "Prerequisite mounting, production AgentLoop drivers, and explicit Inbox stubs for agent-loop tests."
English | 中文
dsh-agent-loop-testkit mounts the standard prerequisite services a test needs before loading the concrete AgentLoop — the LLM runtime, session store, session-projection registry, system-prompt registry, tool registry, and agent registry — in dependency order, with one call. A second helper mounts the production loop and returns a narrow driver for creating real Agents and claiming their real Inbox input. Consumer tests that need only the public queue operations can instead use an explicitly process-local Inbox stub, while tests with no pending-input behavior can use a fail-fast unsupported Inbox. Adapters, optional plugins, load order, and teardown stay in the test's hands. The package registers no model-facing behavior of its own.
This package gives an AgentLoop test a working service topology and keeps the choice between production Inbox behavior and a structural stub explicit.
Use mountAgentLoopTestHarness() when the test covers durable Inbox events, projection recovery or validation, live Inbox notifications, or loop-driver claims. Mount any load-order-sensitive consumers after the prerequisites and before creating the Agent. The context owns the loop and every Agent returned by the harness.
import { Context } from '@deepseek-ai/cordis'
import { SessionId, type UserMessage } from '@deepseek-ai/dsh-session'
import {
mountAgentLoopTestDependencies,
mountAgentLoopTestHarness,
} from '@deepseek-ai/dsh-agent-loop-testkit'
const ctx = new Context()
await mountAgentLoopTestDependencies(ctx)
// Register the test adapter and any load-order-sensitive plugins here.
const harness = await mountAgentLoopTestHarness(ctx)
const agent = await harness.create(SessionId('test-agent'))
declare const message: UserMessage
agent.inbox.append('next-turn', message)
const admitted = harness.claim(agent, 'next-turn', 1)
The dependency helper forwards system-prompt and tool-registry configuration through options and provides no test defaults beyond those services' own defaults. A plugin-load failure rejects the helper call; services activated earlier in the sequence remain context-owned and unwind when the context is disposed.
Use createInboxStub() when the test subject needs mutable pending lists but does not exercise durability, projection validation, live Inbox notifications, or the driver's claim policy. The stub implements the public queue operations with two process-local arrays and never writes to a Session. Use unsupportedInbox() when the test subject must not touch pending input; every mutation throws at the first unexpected dependency.
import { createInboxStub } from '@deepseek-ai/dsh-agent-loop-testkit'
const agent = {
// ...
inbox: createInboxStub(),
}
Use the dependency and loop helpers for tests whose subject is production loop or durable Inbox behavior. Use the structural stub for consumer-domain tests that only need queue editing. Mount dependencies directly when a test probes service injection failures or partial topologies, because the helper hides exactly the wiring those tests must control.
The harness mounts no LLM adapter. Register an adapter before sending work that would start a model request. Dispose the owning context after every test so Agents reach quiescence and their scoped registrations unwind.
Read these pages when the package-level behavior is not enough. They move from the loop to the services the helper mounts and the tests that use it.
None, as these test-only utilities neither assemble nor modify model requests.
None; the package itself sends no provider request.
These limits define what the utilities do not share. They are current package constraints, not a task backlog.