Testing (Unit + Integration + Replay)
Unit Testing Agents
import { AgentNetworkEvent, S } from '@m4trix/core/matrix';
const requestEvent = AgentNetworkEvent.of('user-request', S.Struct({ query: S.String }));
const responseEvent = AgentNetworkEvent.of('agent-response', S.Struct({ answer: S.String }));
const envelope = requestEvent.makeBound(
{ runId: crypto.randomUUID() },
{ query: 'Hello' },
);
// Call your agent's logic (you may need to extract it for testing)
const emitted: unknown[] = [];
const emit = (e: unknown) => emitted.push(e);
await myAgentLogic({ triggerEvent: envelope, emit, params: {} });
expect(emitted).toHaveLength(1);
expect(emitted[0]).toMatchObject({ name: 'agent-response', payload: { answer: expect.any(String) } });Integration Testing the Network
Replay
Evals
Last updated