The XML Agent is a specialized AI agent designed for language models that excel at reasoning and writing in XML format. It’s particularly well-suited for use with models like Anthropic’s Claude, which have demonstrated strong capabilities in structured XML output.
Name: xmlAgent
Type: XMLAgent
Category: [[Agents]]
Version: 2.0
Tools (Required)
Type: Tool[]
Description: A list of tools that the agent can use to perform tasks or gather information.
Memory (Required)
Type: BaseChatMemory
Description: The memory component used to store and retrieve conversation history.
Chat Model (Required)
Type: BaseChatModel
Description: The chat model used for generating responses and making decisions. Should be capable of XML-structured output.
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
Input Moderation (Optional)
Type: Moderation[]
Description: Moderation tools to detect and prevent harmful input.
Max Iterations (Optional)
Type: number
Description: The maximum number of iterations the agent will perform for a single input.
Additional Params: true
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
The agent is initialized with the provided tools, chat model, memory, and optional parameters.
It receives a user input, which is first checked by any specified moderation tools.
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
The XML-structured response is parsed and returned along with any used tools or source documents.
The conversation history is updated in the memory for future context.
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
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.
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.