Tools Overview
Tools let your LLM do things. Instead of stopping at text, it can run a command, query a database, call another agent, or reach out to a service.
In Lectic, you configure tools for each interlocutor in the YAML frontmatter describing that interlocutor. A tool call follows a four-step process:
- User Prompt: You ask a question or give an instruction that requires the use of a tool (e.g., “What is the current date?”).
- LLM Tool Call: The LLM, instead of answering directly, outputs a special block of text indicating which tool it wants to use and with what arguments.
- Lectic Executes: Lectic detects this tool-use block, stops the LLM, executes the specified tool, and captures its output.
- LLM Final Response: Lectic sends the tool’s output back to the LLM, which then uses that information to formulate its final answer to you.
Tool call syntax
Lectic uses an XML block for tool calls. The opening tag names the tool, and the block contains two children: an <arguments> element and a <results> element.
<tool-call with="NAME">starts the block.<arguments>holds one element per parameter in the tool’s schema. If a tool takes no inputs,<arguments>can be empty.<results>is filled by Lectic after execution. Each tool result is serialized as a<result>element inside<results>.</tool-call>closes the block.
You will see these blocks in the assistant’s container directive. Lectic writes the block once the model asks for a tool, then appends results after running it.
Example
Here is a minimal configuration and a typical exchange. The tool returns the current date via the system date command.
---
interlocutor:
name: Assistant
prompt: You are a helpful assistant.
provider: anthropic
model: claude-3-haiku-20240307
tools:
- exec: date
name: get_date
---
What's the date today?And here is what the assistant block might look like after Lectic runs the call and records the result.
:::Assistant
I will call the date tool first.
<tool-call with="get_date">
<arguments><arguments>[ ]</arguments></arguments>
<results>
<result type="text">
┆ <│stdout>Fri Mar 15 14:35:18 PDT 2024\n<│/stdout>
</result>
<result type="text">
┆ <│exitCode>0<│/exitCode>
</result>
</results>
</tool-call>
Today's date is March 15th, 2024.
:::Parallel Tool Execution
Tool calls are executed in parallel. If an LLM decides to use multiple tools in a single turn, Lectic will run all of them concurrently, rather than one after another. This significantly speeds up complex tasks that involve gathering information from multiple sources.
Available Tool Types
Lectic supports a variety of tool types, each with its own capabilities and configuration options. Read the individual tool guides for usage details and best practices:
- Exec: Execute shell commands and scripts.
- SQLite: Query SQLite databases.
- MCP: Connect to Model Context Protocol (MCP) servers.
- Agent: Allow one interlocutor to call another as a tool.
- Other Tools: Includes
think,serve, and native provider tools.