{"version":3,"file":"agent.cjs","names":["Serializable","RunnableSequence","patchConfig"],"sources":["../../src/agents/agent.ts"],"sourcesContent":["import type {\n  StructuredToolInterface,\n  ToolInterface,\n} from \"@langchain/core/tools\";\nimport type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { CallbackManager, Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { BasePromptTemplate } from \"@langchain/core/prompts\";\nimport { AgentAction, AgentFinish, AgentStep } from \"@langchain/core/agents\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { ChainValues } from \"@langchain/core/utils/types\";\nimport { Serializable } from \"@langchain/core/load/serializable\";\nimport {\n  Runnable,\n  patchConfig,\n  type RunnableConfig,\n  RunnableSequence,\n  RunnableLike,\n} from \"@langchain/core/runnables\";\nimport { LLMChain } from \"../chains/llm_chain.js\";\nimport type {\n  AgentActionOutputParser,\n  AgentInput,\n  RunnableMultiActionAgentInput,\n  RunnableSingleActionAgentInput,\n  SerializedAgent,\n  StoppingMethod,\n} from \"./types.js\";\n\n/**\n * Record type for arguments passed to output parsers.\n */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport type OutputParserArgs = Record<string, any>;\n\n/**\n * Error class for parse errors in LangChain. Contains information about\n * the error message and the output that caused the error.\n */\nclass ParseError extends Error {\n  output: string;\n\n  constructor(msg: string, output: string) {\n    super(msg);\n    this.output = output;\n  }\n}\n\n/**\n * Abstract base class for agents in LangChain. Provides common\n * functionality for agents, such as handling inputs and outputs.\n */\nexport abstract class BaseAgent extends Serializable {\n  declare ToolType: StructuredToolInterface;\n\n  abstract get inputKeys(): string[];\n\n  get returnValues(): string[] {\n    return [\"output\"];\n  }\n\n  get allowedTools(): string[] | undefined {\n    return undefined;\n  }\n\n  /**\n   * Return the string type key uniquely identifying this class of agent.\n   */\n  _agentType(): string {\n    throw new Error(\"Not implemented\");\n  }\n\n  /**\n   * Return the string type key uniquely identifying multi or single action agents.\n   */\n  abstract _agentActionType(): string;\n\n  /**\n   * Return response when agent has been stopped due to max iterations\n   */\n  returnStoppedResponse(\n    earlyStoppingMethod: StoppingMethod,\n    _steps: AgentStep[],\n    _inputs: ChainValues,\n    _callbackManager?: CallbackManager\n  ): Promise<AgentFinish> {\n    if (earlyStoppingMethod === \"force\") {\n      return Promise.resolve({\n        returnValues: { output: \"Agent stopped due to max iterations.\" },\n        log: \"\",\n      });\n    }\n\n    throw new Error(`Invalid stopping method: ${earlyStoppingMethod}`);\n  }\n\n  /**\n   * Prepare the agent for output, if needed\n   */\n  async prepareForOutput(\n    _returnValues: AgentFinish[\"returnValues\"],\n    _steps: AgentStep[]\n  ): Promise<AgentFinish[\"returnValues\"]> {\n    return {};\n  }\n}\n\n/**\n * Abstract base class for single action agents in LangChain. Extends the\n * BaseAgent class and provides additional functionality specific to\n * single action agents.\n */\nexport abstract class BaseSingleActionAgent extends BaseAgent {\n  _agentActionType(): string {\n    return \"single\" as const;\n  }\n\n  /**\n   * Decide what to do, given some input.\n   *\n   * @param steps - Steps the LLM has taken so far, along with observations from each.\n   * @param inputs - User inputs.\n   * @param callbackManager - Callback manager.\n   *\n   * @returns Action specifying what tool to use.\n   */\n  abstract plan(\n    steps: AgentStep[],\n    inputs: ChainValues,\n    callbackManager?: CallbackManager,\n    config?: RunnableConfig\n  ): Promise<AgentAction | AgentFinish>;\n}\n\n/**\n * Abstract base class for multi-action agents in LangChain. Extends the\n * BaseAgent class and provides additional functionality specific to\n * multi-action agents.\n */\nexport abstract class BaseMultiActionAgent extends BaseAgent {\n  _agentActionType(): string {\n    return \"multi\" as const;\n  }\n\n  /**\n   * Decide what to do, given some input.\n   *\n   * @param steps - Steps the LLM has taken so far, along with observations from each.\n   * @param inputs - User inputs.\n   * @param callbackManager - Callback manager.\n   *\n   * @returns Actions specifying what tools to use.\n   */\n  abstract plan(\n    steps: AgentStep[],\n    inputs: ChainValues,\n    callbackManager?: CallbackManager,\n    config?: RunnableConfig\n  ): Promise<AgentAction[] | AgentFinish>;\n}\n\nfunction isAgentAction(input: unknown): input is AgentAction {\n  return !Array.isArray(input) && (input as AgentAction)?.tool !== undefined;\n}\n\nexport function isRunnableAgent(x: BaseAgent) {\n  return (\n    (x as RunnableMultiActionAgent | RunnableSingleActionAgent).runnable !==\n    undefined\n  );\n}\n\n// TODO: Remove in the future. Only for backwards compatibility.\n// Allows for the creation of runnables with properties that will\n// be passed to the agent executor constructor.\nexport class AgentRunnableSequence<\n  // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n  RunInput = any,\n  // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n  RunOutput = any,\n> extends RunnableSequence<RunInput, RunOutput> {\n  streamRunnable?: boolean;\n\n  singleAction: boolean;\n\n  // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n  static fromRunnables<RunInput = any, RunOutput = any>(\n    [first, ...runnables]: [\n      RunnableLike<RunInput>,\n      ...RunnableLike[],\n      // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n      RunnableLike<any, RunOutput>,\n    ],\n    config: { singleAction: boolean; streamRunnable?: boolean; name?: string }\n  ): AgentRunnableSequence<RunInput, Exclude<RunOutput, Error>> {\n    const sequence = RunnableSequence.from(\n      [first, ...runnables],\n      config.name\n    ) as AgentRunnableSequence<RunInput, Exclude<RunOutput, Error>>;\n    sequence.singleAction = config.singleAction;\n    sequence.streamRunnable = config.streamRunnable;\n    return sequence;\n  }\n\n  static isAgentRunnableSequence(x: Runnable): x is AgentRunnableSequence {\n    return typeof (x as AgentRunnableSequence).singleAction === \"boolean\";\n  }\n}\n\n/**\n * Class representing a single-action agent powered by runnables.\n * Extends the BaseSingleActionAgent class and provides methods for\n * planning agent actions with runnables.\n */\nexport class RunnableSingleActionAgent extends BaseSingleActionAgent {\n  lc_namespace = [\"langchain\", \"agents\", \"runnable\"];\n\n  runnable: Runnable<\n    ChainValues & { steps: AgentStep[] },\n    AgentAction | AgentFinish\n  >;\n\n  get inputKeys(): string[] {\n    return [];\n  }\n\n  /**\n   * Whether to stream from the runnable or not.\n   * If true, the underlying LLM is invoked in a streaming fashion to make it\n   * possible to get access to the individual LLM tokens when using\n   * `streamLog` with the Agent Executor. If false then LLM is invoked in a\n   * non-streaming fashion and individual LLM tokens will not be available\n   * in `streamLog`.\n   *\n   * Note that the runnable should still only stream a single action or\n   * finish chunk.\n   */\n  streamRunnable = true;\n\n  defaultRunName = \"RunnableAgent\";\n\n  constructor(fields: RunnableSingleActionAgentInput) {\n    super(fields);\n    this.runnable = fields.runnable;\n    this.defaultRunName =\n      fields.defaultRunName ?? this.runnable.name ?? this.defaultRunName;\n    this.streamRunnable = fields.streamRunnable ?? this.streamRunnable;\n  }\n\n  async plan(\n    steps: AgentStep[],\n    inputs: ChainValues,\n    callbackManager?: CallbackManager,\n    config?: RunnableConfig\n  ): Promise<AgentAction | AgentFinish> {\n    const combinedInput = { ...inputs, steps };\n    const combinedConfig = patchConfig(config, {\n      callbacks: callbackManager,\n      runName: this.defaultRunName,\n    });\n    if (this.streamRunnable) {\n      const stream = await this.runnable.stream(combinedInput, combinedConfig);\n      let finalOutput: AgentAction | AgentFinish | undefined;\n      for await (const chunk of stream) {\n        if (finalOutput === undefined) {\n          finalOutput = chunk;\n        } else {\n          throw new Error(\n            [\n              `Multiple agent actions/finishes received in streamed agent output.`,\n              `Set \"streamRunnable: false\" when initializing the agent to invoke this agent in non-streaming mode.`,\n            ].join(\"\\n\")\n          );\n        }\n      }\n      if (finalOutput === undefined) {\n        throw new Error(\n          [\n            \"No streaming output received from underlying runnable.\",\n            `Set \"streamRunnable: false\" when initializing the agent to invoke this agent in non-streaming mode.`,\n          ].join(\"\\n\")\n        );\n      }\n      return finalOutput;\n    } else {\n      return this.runnable.invoke(combinedInput, combinedConfig);\n    }\n  }\n}\n\n/**\n * Class representing a multi-action agent powered by runnables.\n * Extends the BaseMultiActionAgent class and provides methods for\n * planning agent actions with runnables.\n */\nexport class RunnableMultiActionAgent extends BaseMultiActionAgent {\n  lc_namespace = [\"langchain\", \"agents\", \"runnable\"];\n\n  // TODO: Rename input to \"intermediate_steps\"\n  runnable: Runnable<\n    ChainValues & { steps: AgentStep[] },\n    AgentAction[] | AgentAction | AgentFinish\n  >;\n\n  defaultRunName = \"RunnableAgent\";\n\n  stop?: string[];\n\n  streamRunnable = true;\n\n  get inputKeys(): string[] {\n    return [];\n  }\n\n  constructor(fields: RunnableMultiActionAgentInput) {\n    super(fields);\n    this.runnable = fields.runnable;\n    this.stop = fields.stop;\n    this.defaultRunName =\n      fields.defaultRunName ?? this.runnable.name ?? this.defaultRunName;\n    this.streamRunnable = fields.streamRunnable ?? this.streamRunnable;\n  }\n\n  async plan(\n    steps: AgentStep[],\n    inputs: ChainValues,\n    callbackManager?: CallbackManager,\n    config?: RunnableConfig\n  ): Promise<AgentAction[] | AgentFinish> {\n    const combinedInput = { ...inputs, steps };\n    const combinedConfig = patchConfig(config, {\n      callbacks: callbackManager,\n      runName: this.defaultRunName,\n    });\n    let output;\n    if (this.streamRunnable) {\n      const stream = await this.runnable.stream(combinedInput, combinedConfig);\n      let finalOutput: AgentAction | AgentFinish | AgentAction[] | undefined;\n      for await (const chunk of stream) {\n        if (finalOutput === undefined) {\n          finalOutput = chunk;\n        } else {\n          throw new Error(\n            [\n              `Multiple agent actions/finishes received in streamed agent output.`,\n              `Set \"streamRunnable: false\" when initializing the agent to invoke this agent in non-streaming mode.`,\n            ].join(\"\\n\")\n          );\n        }\n      }\n      if (finalOutput === undefined) {\n        throw new Error(\n          [\n            \"No streaming output received from underlying runnable.\",\n            `Set \"streamRunnable: false\" when initializing the agent to invoke this agent in non-streaming mode.`,\n          ].join(\"\\n\")\n        );\n      }\n      output = finalOutput;\n    } else {\n      output = await this.runnable.invoke(combinedInput, combinedConfig);\n    }\n\n    if (isAgentAction(output)) {\n      return [output];\n    }\n\n    return output;\n  }\n}\n\nexport class RunnableAgent extends RunnableMultiActionAgent {}\n\n/**\n * Interface for input data for creating a LLMSingleActionAgent.\n */\nexport interface LLMSingleActionAgentInput {\n  llmChain: LLMChain;\n  outputParser: AgentActionOutputParser;\n  stop?: string[];\n}\n\n/**\n * Class representing a single action agent using a LLMChain in LangChain.\n * Extends the BaseSingleActionAgent class and provides methods for\n * planning agent actions based on LLMChain outputs.\n * @example\n * ```typescript\n * const customPromptTemplate = new CustomPromptTemplate({\n *   tools: [new Calculator()],\n *   inputVariables: [\"input\", \"agent_scratchpad\"],\n * });\n * const customOutputParser = new CustomOutputParser();\n * const agent = new LLMSingleActionAgent({\n *   llmChain: new LLMChain({\n *     prompt: customPromptTemplate,\n *     llm: new ChatOpenAI({ model: \"gpt-4o-mini\", temperature: 0 }),\n *   }),\n *   outputParser: customOutputParser,\n *   stop: [\"\\nObservation\"],\n * });\n * const executor = new AgentExecutor({\n *   agent,\n *   tools: [new Calculator()],\n * });\n * const result = await executor.invoke({\n *   input:\n *     \"Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?\",\n * });\n * ```\n */\nexport class LLMSingleActionAgent extends BaseSingleActionAgent {\n  lc_namespace = [\"langchain\", \"agents\"];\n\n  llmChain: LLMChain;\n\n  outputParser: AgentActionOutputParser;\n\n  stop?: string[];\n\n  constructor(input: LLMSingleActionAgentInput) {\n    super(input);\n    this.stop = input.stop;\n    this.llmChain = input.llmChain;\n    this.outputParser = input.outputParser;\n  }\n\n  get inputKeys(): string[] {\n    return this.llmChain.inputKeys;\n  }\n\n  /**\n   * Decide what to do given some input.\n   *\n   * @param steps - Steps the LLM has taken so far, along with observations from each.\n   * @param inputs - User inputs.\n   * @param callbackManager - Callback manager.\n   *\n   * @returns Action specifying what tool to use.\n   */\n  async plan(\n    steps: AgentStep[],\n    inputs: ChainValues,\n    callbackManager?: CallbackManager\n  ): Promise<AgentAction | AgentFinish> {\n    const output = await this.llmChain.call(\n      {\n        intermediate_steps: steps,\n        stop: this.stop,\n        ...inputs,\n      },\n      callbackManager\n    );\n    return this.outputParser.parse(\n      output[this.llmChain.outputKey],\n      callbackManager\n    );\n  }\n}\n\n/**\n * Interface for arguments used to create an agent in LangChain.\n */\nexport interface AgentArgs {\n  outputParser?: AgentActionOutputParser;\n\n  callbacks?: Callbacks;\n\n  /**\n   * @deprecated Use `callbacks` instead.\n   */\n  callbackManager?: CallbackManager;\n}\n\n/**\n * Class responsible for calling a language model and deciding an action.\n *\n * @remarks This is driven by an LLMChain. The prompt in the LLMChain *must*\n * include a variable called \"agent_scratchpad\" where the agent can put its\n * intermediary work.\n */\nexport abstract class Agent extends BaseSingleActionAgent {\n  llmChain: LLMChain;\n\n  outputParser: AgentActionOutputParser | undefined;\n\n  private _allowedTools?: string[] = undefined;\n\n  get allowedTools(): string[] | undefined {\n    return this._allowedTools;\n  }\n\n  get inputKeys(): string[] {\n    return this.llmChain.inputKeys.filter((k) => k !== \"agent_scratchpad\");\n  }\n\n  constructor(input: AgentInput) {\n    super(input);\n\n    this.llmChain = input.llmChain;\n    this._allowedTools = input.allowedTools;\n    this.outputParser = input.outputParser;\n  }\n\n  /**\n   * Prefix to append the observation with.\n   */\n  abstract observationPrefix(): string;\n\n  /**\n   * Prefix to append the LLM call with.\n   */\n  abstract llmPrefix(): string;\n\n  /**\n   * Return the string type key uniquely identifying this class of agent.\n   */\n  abstract _agentType(): string;\n\n  /**\n   * Get the default output parser for this agent.\n   */\n  static getDefaultOutputParser(\n    _fields?: OutputParserArgs\n  ): AgentActionOutputParser {\n    throw new Error(\"Not implemented\");\n  }\n\n  /**\n   * Create a prompt for this class\n   *\n   * @param _tools - List of tools the agent will have access to, used to format the prompt.\n   * @param _fields - Additional fields used to format the prompt.\n   *\n   * @returns A PromptTemplate assembled from the given tools and fields.\n   * */\n  static createPrompt(\n    _tools: StructuredToolInterface[],\n    // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n    _fields?: Record<string, any>\n  ): BasePromptTemplate {\n    throw new Error(\"Not implemented\");\n  }\n\n  /** Construct an agent from an LLM and a list of tools */\n  static fromLLMAndTools(\n    _llm: BaseLanguageModelInterface,\n    _tools: StructuredToolInterface[],\n\n    _args?: AgentArgs\n  ): Agent {\n    throw new Error(\"Not implemented\");\n  }\n\n  /**\n   * Validate that appropriate tools are passed in\n   */\n  static validateTools(_tools: StructuredToolInterface[]): void {}\n\n  _stop(): string[] {\n    return [`\\n${this.observationPrefix()}`];\n  }\n\n  /**\n   * Name of tool to use to terminate the chain.\n   */\n  finishToolName(): string {\n    return \"Final Answer\";\n  }\n\n  /**\n   * Construct a scratchpad to let the agent continue its thought process\n   */\n  async constructScratchPad(\n    steps: AgentStep[]\n  ): Promise<string | BaseMessage[]> {\n    return steps.reduce(\n      (thoughts, { action, observation }) =>\n        thoughts +\n        [\n          action.log,\n          `${this.observationPrefix()}${observation}`,\n          this.llmPrefix(),\n        ].join(\"\\n\"),\n      \"\"\n    );\n  }\n\n  private async _plan(\n    steps: AgentStep[],\n    inputs: ChainValues,\n    suffix?: string,\n    callbackManager?: CallbackManager\n  ): Promise<AgentAction | AgentFinish> {\n    const thoughts = await this.constructScratchPad(steps);\n    const newInputs: ChainValues = {\n      ...inputs,\n      agent_scratchpad: suffix ? `${thoughts}${suffix}` : thoughts,\n    };\n\n    if (this._stop().length !== 0) {\n      newInputs.stop = this._stop();\n    }\n\n    const output = await this.llmChain.predict(newInputs, callbackManager);\n    if (!this.outputParser) {\n      throw new Error(\"Output parser not set\");\n    }\n    return this.outputParser.parse(output, callbackManager);\n  }\n\n  /**\n   * Decide what to do given some input.\n   *\n   * @param steps - Steps the LLM has taken so far, along with observations from each.\n   * @param inputs - User inputs.\n   * @param callbackManager - Callback manager to use for this call.\n   *\n   * @returns Action specifying what tool to use.\n   */\n  plan(\n    steps: AgentStep[],\n    inputs: ChainValues,\n    callbackManager?: CallbackManager\n  ): Promise<AgentAction | AgentFinish> {\n    return this._plan(steps, inputs, undefined, callbackManager);\n  }\n\n  /**\n   * Return response when agent has been stopped due to max iterations\n   */\n  async returnStoppedResponse(\n    earlyStoppingMethod: StoppingMethod,\n    steps: AgentStep[],\n    inputs: ChainValues,\n    callbackManager?: CallbackManager\n  ): Promise<AgentFinish> {\n    if (earlyStoppingMethod === \"force\") {\n      return {\n        returnValues: { output: \"Agent stopped due to max iterations.\" },\n        log: \"\",\n      };\n    }\n\n    if (earlyStoppingMethod === \"generate\") {\n      try {\n        const action = await this._plan(\n          steps,\n          inputs,\n          \"\\n\\nI now need to return a final answer based on the previous steps:\",\n          callbackManager\n        );\n        if (\"returnValues\" in action) {\n          return action;\n        }\n\n        return { returnValues: { output: action.log }, log: action.log };\n      } catch (err) {\n        // fine to use instanceof because we're in the same module\n        // oxlint-disable-next-line no-instanceof/no-instanceof\n        if (!(err instanceof ParseError)) {\n          throw err;\n        }\n        return { returnValues: { output: err.output }, log: err.output };\n      }\n    }\n\n    throw new Error(`Invalid stopping method: ${earlyStoppingMethod}`);\n  }\n\n  /**\n   * Load an agent from a json-like object describing it.\n   */\n  static async deserialize(\n    data: SerializedAgent & {\n      llm?: BaseLanguageModelInterface;\n      tools?: ToolInterface[];\n    }\n  ): Promise<Agent> {\n    switch (data._type) {\n      case \"zero-shot-react-description\": {\n        const { ZeroShotAgent } = await import(\"./mrkl/index.js\");\n        return ZeroShotAgent.deserialize(data);\n      }\n      default:\n        throw new Error(\"Unknown agent type\");\n    }\n  }\n}\n"],"mappings":";;;;;;;AAsCA,IAAM,aAAN,cAAyB,MAAM;CAC7B;CAEA,YAAY,KAAa,QAAgB;EACvC,MAAM,GAAG;EACT,KAAK,SAAS;CAChB;AACF;;;;;AAMA,IAAsB,YAAtB,cAAwCA,kCAAAA,aAAa;CAKnD,IAAI,eAAyB;EAC3B,OAAO,CAAC,QAAQ;CAClB;CAEA,IAAI,eAAqC,CAEzC;;;;CAKA,aAAqB;EACnB,MAAM,IAAI,MAAM,iBAAiB;CACnC;;;;CAUA,sBACE,qBACA,QACA,SACA,kBACsB;EACtB,IAAI,wBAAwB,SAC1B,OAAO,QAAQ,QAAQ;GACrB,cAAc,EAAE,QAAQ,uCAAuC;GAC/D,KAAK;EACP,CAAC;EAGH,MAAM,IAAI,MAAM,4BAA4B,q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