agent-testing

Test AdonisJS agent loops offline with fake model providers and in-memory SPI doubles.

1|Updated Jul 7, 2026
One-click install
npx skills add https://github.com/DavideCarvalho/adonis-agora-agent --skill agent-testing-davidecarvalho
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: agent-testing
Source: https://github.com/DavideCarvalho/adonis-agora-agent/tree/main/packages/adonis/skills/agent-testing
Command: npx skills add https://github.com/DavideCarvalho/adonis-agora-agent --skill agent-testing-davidecarvalho

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Testing an AI agent normally requires API keys, a database, and live model calls, making tests slow, costly, and non-deterministic. This Skill shows how to run a full agent turn — model call, tool execution, governance, and cost accounting — entirely offline using the testing doubles shipped with @adonis-agora/agent. ## Core Features & Use Cases - Scripted fake model turns: FakeModelProvider accepts a pure script function of (args, turnIndex) so you can script tool-call round-trips deterministically without closure counters. - In-memory SPI doubles: InMemoryAgentStore, InMemoryTokenStreamSink, InMemoryQuotaStore, InMemoryGovernanceQueries, and more implement the same SPIs as production adapters, so tests exercise real loop code paths. - Typed stream assertions: Subscribe to runs and assert on discriminated StreamFrames ({ t: 'text' } / { t: 'component' }) instead of raw SSE bytes. - Use Case: Write a test that scripts a first-turn tool call to getWeather, auto-approves the HITL gate via awaitApproval, runs the loop through AgentDepsFactory + InlineAgentRunner, and asserts the final streamed text — all with no API key. ## Quick Start Write a test that runs runAgentLoop with FakeModelProvider and the in-memory store and sink, scripting a tool-call turn and asserting the streamed text output.

Frequently Asked Questions about agent-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test an AI agent without an API key?▼

Use FakeModelProvider from @adonis-agora/agent/testing with a script function, plus in-memory doubles like InMemoryAgentStore and InMemoryTokenStreamSink. These implement the same SPIs as production adapters, so runAgentLoop executes the real code paths offline.

How do I script a tool-call turn in an agent test?▼

Pass FakeModelProvider a pure function of (args, turnIndex): return a toolCall object when turnIndex is 0, then return final text on the next turn. turnIndex is derived from assistant messages in history, keeping scripts deterministic and replay-safe.

Why does my scripted tool call fail with ToolForbiddenError in tests?▼

The offered-tools filter drops role-forbidden tools before the model turn, so a tool the actor's roles cannot reach is never offered. Align the test actor's roles with the tool spec or the roles policy defaults, such as using an ADMIN actor.

Can I assert on streamed agent output in tests?▼

Yes, subscribe to the run via InMemoryTokenStreamSink.subscribe(runId) and narrow on typed StreamFrames: { t: 'text', v } for prose and { t: 'component', name, data } for Generative-UI emissions. Tests never see the SSE wire encoding, which happens later in the route handler.

How do I test human-in-the-loop approval flows?▼

Provide the awaitApproval hook when calling runAgentLoop and return 'approve' or { approved: true } to auto-approve in tests. This exercises the same HITL gate the production durable runner uses without manual intervention.