@hbbio/nanoagent
    Preparing search index...

    Interface AgentContext<Memory>

    Agent behaviour contract. All functions must be side‑effect‑free except for getUserInput, which is allowed to perform I/O.

    interface AgentContext<Memory extends ChatMemory> {
        controller?: (state: AgentState<Memory>) => Promise<AgentState<Memory>>;
        getUserInput?: (
            ctx: AgentContext<Memory>,
            state: AgentState<Memory>,
        ) => Promise<string>;
        guidelines?: (memory: Memory) => Promise<string>;
        isFinal: (state: AgentState<Memory>) => Promise<boolean>;
        name?: string;
        nextSequence?: (
            state: AgentState<Memory>,
        ) => Promise<
            {
                ctx: AgentContext<Memory>;
                options?: SequenceOptions;
                state: AgentState<Memory>;
            },
        >;
        registry?: ToolRegistry<Memory>;
    }

    Type Parameters

    Index

    Properties

    controller?: (state: AgentState<Memory>) => Promise<AgentState<Memory>>

    Recovery hook invoked when the loop detects that progress has stalled. Implementations typically append a SystemMessage to re‑orient the agent.

    getUserInput?: (
        ctx: AgentContext<Memory>,
        state: AgentState<Memory>,
    ) => Promise<string>

    Optional function to request user input when the agents needs user input.

    guidelines?: (memory: Memory) => Promise<string>

    System guidelines generator. Should embed the main instruction payload. It is not automatically inserted into the transcript; callers are expected to do so when composing the initial state.

    isFinal: (state: AgentState<Memory>) => Promise<boolean>

    Test whether the agent has reached its goal.

    name?: string

    Context name used only for logging / debugging.

    nextSequence?: (
        state: AgentState<Memory>,
    ) => Promise<
        {
            ctx: AgentContext<Memory>;
            options?: SequenceOptions;
            state: AgentState<Memory>;
        },
    >

    Callback to compute the next sequence in a multi‑stage workflow. Returning undefined ends the workflow after the current sequence.

    registry?: ToolRegistry<Memory>

    Optional registry of callable tools.