import * as _langchain_langgraph0 from "@langchain/langgraph"; import { AnnotationRoot, CompiledStateGraph, StateGraph } from "@langchain/langgraph"; import { AgentNameMode, CreateReactAgentParams, withAgentName } from "@langchain/langgraph/prebuilt"; import * as _langchain_core_messages0 from "@langchain/core/messages"; import { DynamicTool, StructuredToolInterface } from "@langchain/core/tools"; import { LanguageModelLike } from "@langchain/core/language_models/base"; import { RunnableToolLike } from "@langchain/core/runnables"; import { InteropZodType } from "@langchain/core/utils/types"; import { RemoteGraph } from "@langchain/langgraph/remote"; //#region src/supervisor.d.ts type OutputMode = "full_history" | "last_message"; /** @inline */ type CreateSupervisorParams, StructuredResponseFormat extends Record = Record> = { /** * List of agents to manage. * Accepts compiled graphs from both `createReactAgent` (`@langchain/langgraph`) * and `createAgent` (`langchain`) via `.graph`. */ agents: (CompiledStateGraph | CompiledStateGraph | RemoteGraph)[]; /** * Language model to use for the supervisor */ llm: LanguageModelLike; /** * Tools to use for the supervisor */ tools?: (StructuredToolInterface | RunnableToolLike | DynamicTool)[]; /** * An optional prompt for the supervisor. Can be one of: * - `string`: This is converted to a SystemMessage and added to the beginning of the list of messages in state["messages"] * - `SystemMessage`: this is added to the beginning of the list of messages in state["messages"] * - `Function`: This function should take in full graph state and the output is then passed to the language model * - `Runnable`: This runnable should take in full graph state and the output is then passed to the language model */ prompt?: CreateReactAgentParams["prompt"]; /** * An optional schema for the final supervisor output. * * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key. * If not provided, `structuredResponse` will not be present in the output state. * * Can be passed in as: * - Zod schema * - JSON schema * - { prompt, schema }, where schema is one of the above. * The prompt will be used together with the model that is being used to generate the structured response. * * @remarks * **Important**: `responseFormat` requires the model to support `.withStructuredOutput()`. * * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished. * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/). */ responseFormat?: InteropZodType | { prompt: string; schema: InteropZodType | Record; } | Record; /** * State schema to use for the supervisor graph */ stateSchema?: AnnotationRootT; /** * Context schema to use for the supervisor graph */ contextSchema?: AnnotationRootT; /** * Mode for adding managed agents' outputs to the message history in the multi-agent workflow. * Can be one of: * - `"full_history"`: add the entire agent message history * - `"last_message"`: add only the last message (default) */ outputMode?: OutputMode; /** * Whether to add the supervisor-to-agent handoff messages (the supervisor * `AIMessage` containing the handoff tool call and the handoff `ToolMessage`) * to the message history forwarded to the expert agent. If `false`, those * handoff bookkeeping messages are omitted from the expert agent's message * history. This is useful for providers that strictly validate tool-call * message sequences. Defaults to `true`. */ addHandoffMessages?: boolean; /** * Whether to add a pair of (AIMessage, ToolMessage) to the message history * when returning control to the supervisor to indicate that a handoff has occurred * Defaults to the value of `addHandoffMessages`. */ addHandoffBackMessages?: boolean; /** * Name of the supervisor node */ supervisorName?: string; /** * Use to specify how to expose the agent name to the underlying supervisor LLM. * - `undefined`: Relies on the LLM provider using the name attribute on the AI message. Currently, only OpenAI supports this. * - `"inline"`: Add the agent name directly into the content field of the AI message using XML-style tags. * Example: "How can I help you" -> "agent_nameHow can I help you?" */ includeAgentName?: AgentNameMode; /** * An optional node to add before the LLM node in the supervisor agent (i.e., the node that calls the LLM). * Useful for managing long message histories (e.g., message trimming, summarization, etc.). * * Pre-model hook must be a callable or a runnable that takes in current graph state and returns a state update in the form of: * ```javascript * { * messages: [new RemoveMessage({ id: REMOVE_ALL_MESSAGES }), ...], * llmInputMessages: [...] * ... * } * ``` * **Important**: At least one of `messages` or `llmInputMessages` MUST be provided and will be used as an input to the `agent` node. * The rest of the keys will be added to the graph state. * * * **Warning**: If you are returning `messages` in the pre-model hook, you should OVERWRITE the `messages` key by doing the following: * ```javascript * { messages: [new RemoveMessage({ id: REMOVE_ALL_MESSAGES }), ...newMessages], ... } * ``` */ preModelHook?: CreateReactAgentParams["preModelHook"]; /** * An optional node to add after the LLM node in the supervisor agent (i.e., the node that calls the LLM). * Useful for implementing human-in-the-loop, guardrails, validation, or other post-processing. * Post-model hook must be a callable or a runnable that takes in current graph state and returns a state update. */ postModelHook?: CreateReactAgentParams["postModelHook"]; }; /** * Create a multi-agent supervisor. * * @param params Parameters for the supervisor. * @returns The supervisor graph. */ declare const createSupervisor: = AnnotationRoot<{ messages: _langchain_langgraph0.BaseChannel<_langchain_core_messages0.BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], _langchain_langgraph0.OverwriteValue<_langchain_core_messages0.BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | _langchain_langgraph0.Messages, unknown>; }>, StructuredResponseFormat extends Record = Record>({ agents, llm, tools, prompt, responseFormat, stateSchema, contextSchema, outputMode, addHandoffMessages, addHandoffBackMessages, supervisorName, includeAgentName, preModelHook, postModelHook }: CreateSupervisorParams) => StateGraph; //#endregion export { type AgentNameMode, CreateSupervisorParams, type OutputMode, createSupervisor, withAgentName }; //# sourceMappingURL=supervisor.d.ts.map