FakeAgent
FakeAgent is an in-process AG-UI test double that emits a canned streaming response without a real backend. Use it for offline development, CI, and component tests.
#provideFakeAgent()
provideFakeAgent() is the DI-friendly entry point. It is a drop-in replacement for provideAgent({ url }) when no backend is available.
Pass a FakeAgentConfig to customize the canned response:
#FakeAgentConfig
| Option | Type | Description |
|---|---|---|
tokens | string[] | Assistant reply streamed token-by-token. Defaults to a fixed placeholder message. |
reasoningTokens | string[] | Optional reasoning chunks emitted before the text reply. |
delayMs | number | Milliseconds between successive token emissions. Defaults to 60. |
#FakeAgent class
Construct a FakeAgent directly when you need lower-level control, for example to pass it to toAgent() in a test harness.
FakeAgent extends AbstractAgent from @ag-ui/client. Its run() method returns an Observable<BaseEvent> that emits the full event sequence — RUN_STARTED, optional reasoning events, TEXT_MESSAGE_START / TEXT_MESSAGE_CONTENT tokens, TEXT_MESSAGE_END, RUN_FINISHED — then completes.
#TestBed example
FakeAgent and provideFakeAgent() are intended for development and tests
only. Do not use them in production builds.
See also: Fake Agent guide for practical offline-development patterns, and Testing guide for full component-testing recipes.