Node Details

  • Name: xmlAgent

  • Type: XMLAgent

  • Category: [[Agents]]

  • Version: 2.0

Parameters

  1. Tools (Required)

    • Type: Tool[]

    • Description: A list of tools that the agent can use to perform tasks or gather information.

  2. Memory (Required)

    • Type: BaseChatMemory

    • Description: The memory component used to store and retrieve conversation history.

  3. Chat Model (Required)

    • Type: BaseChatModel

    • Description: The chat model used for generating responses and making decisions. Should be capable of XML-structured output.

  4. System Message (Optional)

    • Type: string

    • Default: A predefined message instructing the agent on XML usage and tool execution.

    • Description: Custom instructions for the agent’s behavior and XML formatting.

    • Additional Params: true

  5. Input Moderation (Optional)

    • Type: Moderation[]

    • Description: Moderation tools to detect and prevent harmful input.

  6. Max Iterations (Optional)

    • Type: number

    • Description: The maximum number of iterations the agent will perform for a single input.

    • Additional Params: true

Input

  • A string containing the user’s message or query.

Output

  • An object containing:

    • text: The agent’s response to the user’s input

    • sourceDocuments: (optional) Any source documents used in formulating the response

    • usedTools: (optional) A list of tools used by the agent during processing

How It Works

  1. The agent is initialized with the provided tools, chat model, memory, and optional parameters.

  2. It receives a user input, which is first checked by any specified moderation tools.

  3. The agent processes the input using the following steps:

    • Analyzes the query and determines if tool use is necessary

    • If needed, selects and executes tools using XML-structured commands

    • Reasons about the tool outputs and formulates a response

    • Generates the final answer in XML format

  4. The XML-structured response is parsed and returned along with any used tools or source documents.

  5. The conversation history is updated in the memory for future context.

Use Cases

  • Complex query resolution requiring structured reasoning

  • Task execution with clear step-by-step breakdowns

  • Data analysis and reporting with structured output

  • API interaction and structured data manipulation

  • Scenarios requiring clear separation of reasoning steps and final answers

Special Features

  • XML-Structured Reasoning: Uses XML format for clear, structured thought processes and tool usage.

  • Tool Integration: Can use a variety of tools, calling them with XML-formatted inputs.

  • Memory Management: Maintains conversation history for contextual understanding.

  • Moderation: Can implement input moderation to ensure safe interactions.

  • Flexible Iteration Control: Allows setting a maximum number of reasoning-action cycles.

Notes

  • The agent is optimized for language models that excel at XML formatting, such as Anthropic’s Claude.

  • The system message can be customized to tailor the agent’s behavior and XML usage patterns.

  • XML structure allows for clear separation of thought processes, tool usage, and final answers.

  • The agent uses specific XML tags like <tool>, <tool_input>, <observation>, and <final_answer> for structured interactions.

  • This agent is particularly effective for tasks that benefit from step-by-step reasoning and clear output structure.

The XML Agent provides a powerful solution for building AI systems that require structured reasoning and output. Its use of XML format allows for clear, parseable responses that separate the agent’s thought process, tool usage, and final answers. This makes it especially valuable for applications where transparency in the AI’s decision-making process is important, or where structured output is required for further processing or integration with other systems.