/ docs / agent / configuration.md
configuration.md
  1  # Configuration
  2  
  3  An agent takes two main arguments, an LLM and a list of tools.
  4  
  5  The txtai agent framework is built with [smolagents](https://github.com/huggingface/smolagents). Additional options can be passed in the `Agent` constructor.
  6  
  7  ```python
  8  from datetime import datetime
  9  
 10  from txtai import Agent
 11  
 12  wikipedia = {
 13      "name": "wikipedia",
 14      "description": "Searches a Wikipedia database",
 15      "provider": "huggingface-hub",
 16      "container": "neuml/txtai-wikipedia"
 17  }
 18  
 19  arxiv = {
 20      "name": "arxiv",
 21      "description": "Searches a database of scientific papers",
 22      "provider": "huggingface-hub",
 23      "container": "neuml/txtai-arxiv"
 24  }
 25  
 26  def today() -> str:
 27      """
 28      Gets the current date and time
 29  
 30      Returns:
 31          current date and time
 32      """
 33  
 34      return datetime.today().isoformat()
 35  
 36  agent = Agent(
 37      model="Qwen/Qwen3-4B-Instruct-2507",
 38      tools=[today, wikipedia, arxiv, "websearch"],
 39  )
 40  ```
 41  
 42  ## model
 43  
 44  ```yaml
 45  model: string|llm instance
 46  ```
 47  
 48  LLM model path or LLM pipeline instance. The `llm` parameter is also supported for backwards compatibility.
 49  
 50  See the [LLM pipeline](../../pipeline/text/llm) for more information.
 51  
 52  ## tools
 53  
 54  ```yaml
 55  tools: list
 56  ```
 57  
 58  List of tools to supply to the agent. Supports the following configurations.
 59  
 60  ### function
 61  
 62  A function tool takes the following dictionary fields.
 63  
 64  | Field       | Description              |
 65  |:------------|:-------------------------|
 66  | name        | name of the tool         |
 67  | description | tool description         |
 68  | target      | target method / callable |
 69  
 70  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.
 71  
 72  ### embeddings
 73  
 74  Embeddings indexes have built-in support. Provide the following dictionary configuration to add an embeddings index as a tool.
 75  
 76  | Field       | Description                                |
 77  |:------------|:-------------------------------------------|
 78  | name        | embeddings index name                      |
 79  | description | embeddings index description               | 
 80  | **kwargs    | Parameters to pass to [embeddings.load](../../embeddings/methods/#txtai.embeddings.Embeddings.load) |
 81  
 82  ### tool
 83  
 84  The following shortcut strings load tools directly. Passing a Tool instance is also supported.
 85  
 86  | Tool        | Description                                               |
 87  |:------------|:----------------------------------------------------------|
 88  | bash        | Runs a shell command through subprocess                   |
 89  | defaults    | Loads all of these tools as the default toolkit           |
 90  | edit        | Edits a file in place and returns a diff                  |
 91  | glob        | Finds matching file patterns in a directory               |
 92  | grep        | Finds matching file content in a directory                |
 93  | http.*      | HTTP Path to a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/docs/getting-started/intro) server |
 94  | python      | Runs a Python action                                      |
 95  | read        | Reads file or url content, supports text extraction       |
 96  | todowrite   | Generates a task list to organize complex tasks           |
 97  | websearch   | Runs a websearch using the built-in websearch tool        |
 98  | webview     | Extracts content from a web page. Alias for `read` tool   |
 99  | write       | Writes content to file                                    |
100  | *.md        | Loads a [`skill.md`](https://agentskills.io/specification) file |
101  
102  ## instructions
103  
104  ```yaml
105  instructions: string|path
106  ```
107  
108  Supports loading an `agents.md` file. Can be provided directly as a string or as a path to a file.
109  
110  [Read more about agents.md here](https://github.com/agentsmd/agents.md)
111  
112  ## template
113  
114  ```yaml
115  template: string
116  ```
117  
118  Customize the prompt template used by this agent. Supports Jinja templates. Uses a default template when this parameter is not provided.
119  Must include `{{ text }}` and `{{ memory }}` placeholders.
120  
121  ## memory
122  
123  ```yaml
124  memory: int
125  ```
126  
127  Keeps a rolling window of `memory` inputs and outputs. These are added to future prompts and serve as "agent memory".
128  
129  Supports storing memory by `session` to enable multiple conversation threads. Defaults to shared memory when not set. See the [method documentation](../methods#txtai.agent.base.Agent.__call__) for more information.
130  
131  ## method
132  
133  ```yaml
134  method: code|tool
135  ```
136  
137  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.
138  
139  Additional options can be directly passed. See [CodeAgent](https://huggingface.co/docs/smolagents/main/en/reference/agents#smolagents.CodeAgent) or [ToolCallingAgent](https://huggingface.co/docs/smolagents/main/en/reference/agents#smolagents.ToolCallingAgent) for a list of parameters.
140  
141  [Read more here](https://huggingface.co/docs/smolagents/main/en/guided_tour).