createFakeAgentSession
Unpublished development API. This package is under development and is not available as a published release.
Creates an in-memory AgentSession for tests and stories. There is no
transport: the test publishes snapshots through the returned controls, and
every snapshot is frozen and keeps unchanged messages by reference.
Subscribers are notified synchronously, so React tests wrap control calls in
act.
By default submit records the call, appends a user message, and resolves
'success'. Pass onSubmit to stream a reply or return another outcome.
import { createFakeAgentSession } from '@threadplane/core/testing';Declaration · overload 1
export declare function createFakeAgentSession<TTools extends {
[K in keyof TTools]: ToolContract;
} = Record<string, ToolContract>>(init?: FakeAgentSessionInit<TTools>): FakeAgentSession<TTools>;Type parameters
TTools{ [K in keyof TTools]: ToolContract; }Default:Record<string, ToolContract>
Parameters
init· optionalFakeAgentSessionInit<TTools>
Returns
FakeAgentSession<TTools>Examples
const fake = createFakeAgentSession({
onSubmit: (input, fake) => {
const reply = fake.stream();
reply.append(`You said: ${input}`);
reply.complete();
},
});
render(<Chat session={fake.session} />);