langchain.js
    Preparing search index...

    Interface AgentTypeConfig<TResponse, TState, TContext, TMiddleware, TTools>

    Type bag that encapsulates all agent type parameters.

    This interface bundles all the generic type parameters used throughout the agent system into a single configuration object. This pattern simplifies type signatures and makes it easier to add new type parameters without changing multiple function signatures.

    // Define a type configuration
    type MyAgentTypes = AgentTypeConfig<
    { name: string; email: string }, // Response type
    typeof MyStateSchema, // State schema
    typeof MyContextSchema, // Context schema
    typeof myMiddleware, // Middleware array
    typeof myTools // Tools array
    >;

    // Use with ReactAgent
    const agent: ReactAgent<MyAgentTypes> = createAgent({ ... });
    interface AgentTypeConfig<
        TResponse extends
            Record<string, any>
            | ResponseFormatUndefined = Record<string, any> | ResponseFormatUndefined,
        TState extends
            StateDefinitionInit
            | undefined = StateDefinitionInit | undefined,
        TContext extends
            AnyAnnotationRoot
            | BaseMessage = AnyAnnotationRoot | BaseMessage,
        TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[],
        TTools extends
            readonly (BaseMessage | BaseMessage)[] = readonly (
            BaseMessage
            | BaseMessage
        )[],
    > {
        Context: TContext;
        Middleware: TMiddleware;
        Response: TResponse;
        State: TState;
        Tools: TTools;
    }

    Type Parameters

    • TResponse extends Record<string, any> | ResponseFormatUndefined = Record<string, any> | ResponseFormatUndefined

      The structured response type when using responseFormat. Defaults to Record<string, any>. Set to ResponseFormatUndefined when no response format is configured.

    • TState extends StateDefinitionInit | undefined = StateDefinitionInit | undefined

      The custom state schema type. Can be an AnnotationRoot, InteropZodObject, or undefined. The state persists across agent invocations when using a checkpointer.

    • TContext extends AnyAnnotationRoot | BaseMessage = AnyAnnotationRoot | BaseMessage

      The context schema type. Context is read-only and not persisted between invocations. Defaults to AnyAnnotationRoot.

    • TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[]

      The middleware array type. Must be a readonly array of AgentMiddleware instances.

    • TTools extends readonly (BaseMessage | BaseMessage)[] = readonly (BaseMessage | BaseMessage)[]

      The combined tools type from both createAgent tools parameter and middleware tools. This is a readonly array of ClientTool | ServerTool.

    Hierarchy (View Summary)

    Index

    Properties

    Context: TContext

    The context schema type

    Middleware: TMiddleware

    The middleware array type

    Response: TResponse

    The structured response type when using responseFormat

    State: TState

    The custom state schema type

    Tools: TTools

    The combined tools type from agent and middleware