Configuration
An agent takes two main arguments, an LLM and a list of tools.
The txtai agent framework is built with smolagents. Additional options can be passed in the Agent constructor.
from datetime import datetime
from txtai import Agent
wikipedia = {
"name": "wikipedia",
"description": "Searches a Wikipedia database",
"provider": "huggingface-hub",
"container": "neuml/txtai-wikipedia"
}
arxiv = {
"name": "arxiv",
"description": "Searches a database of scientific papers",
"provider": "huggingface-hub",
"container": "neuml/txtai-arxiv"
}
def today() -> str:
"""
Gets the current date and time
Returns:
current date and time
"""
return datetime.today().isoformat()
agent = Agent(
model="Qwen/Qwen3-4B-Instruct-2507",
tools=[today, wikipedia, arxiv, "websearch"],
)
model
model: string|llm instance
LLM model path or LLM pipeline instance. The llm parameter is also supported for backwards compatibility.
See the LLM pipeline for more information.
tools
tools: list
List of tools to supply to the agent. Supports the following configurations.
function
A function tool takes the following dictionary fields.
| Field | Description |
|---|---|
| name | name of the tool |
| description | tool description |
| target | target method / callable |
A function or callable method can also be directly supplied in the tools list. In this case, the fields are inferred from the method documentation.
embeddings
Embeddings indexes have built-in support. Provide the following dictionary configuration to add an embeddings index as a tool.
| Field | Description |
|---|---|
| name | embeddings index name |
| description | embeddings index description |
| **kwargs | Parameters to pass to embeddings.load |
tool
The following shortcut strings load tools directly. Passing a Tool instance is also supported.
| Tool | Description |
|---|---|
| http.* | HTTP Path to a Model Context Protocol (MCP) server |
| python | Runs a Python action |
| *.md | Loads a skill.md file |
| websearch | Runs a websearch using the built-in websearch tool |
| webview | Extracts content from a web page |
instructions
instructions: string|path
Supports loading an agents.md file. Can be provided directly as a string or as a path to a file.
Read more about agents.md here
template
template: string
Customize the prompt template used by this agent. Supports Jinja templates. Uses a default template when this parameter is not provided.
Must include {{ text }} and {{ memory }} placeholders.
memory
memory: int
Keeps a rolling window of memory inputs and outputs. These are added to future prompts and serve as "agent memory".
Supports storing memory by session to enable multiple conversation threads. Defaults to shared memory when not set. See the method documentation for more information.
method
method: code|tool
Sets the agent method. Supports either a code or tool (default) calling agent. A code agent generates Python code and executes that. A tool calling agent generates JSON blocks and calls the agents within those blocks.
Additional options can be directly passed. See CodeAgent or ToolCallingAgent for a list of parameters.