Tools & APIs
Tools & APIs in Parlant
Parlant provides a guided approach to tool usage, tightly integrated with its guidance system.
Parlant's tool-calling approach is built from the ground up. It's more comprehensive than the tool-calling mechanisms you may be familiar with from most LLM APIs (including MCP). This is because it's built to enable a deep, seamless integration with its guidance-based behavior control.
Getting Started with Tool Services
The best way to get started with custom tool services is to use the code generation command that comes with parlant-server
.
parlant-server module create my_tool_service --template tool-service
This will automatically create a scaffold module and add it to ./parlant.toml
so that your server automatically loads it when it boots up.
Understanding Tool Usage
In Parlant, tools are always associated with specific guidelines. A tool only executes when its associated guideline is matched to the conversation. This design creates a clear chain of intent: guidelines determine when and why tools are used, rather than leaving it to the LLM's judgment.
In Parlant, business logic (encoded in tools) is separated and worked on independently from presentation (or user-interface) concerns, which are the behavior that's controlled by the guidelines themselves. This allows you to have developers work out the logic in code, with full control—offering these tools in the "tool shed" of a Parlant server—for business experts to then go and utilize in their guideline definitions, as needed.
As an analogy, you can think of Guidelines and Tools like Widgets and Event Handlers in Graphical UI frameworks. A GUI Button has an onClick
event which we can associate with some API function to say, "When this button is clicked, run this function.". In the same way, in Parlant—which is essentally a Conversational UI framework if you think about it—the Guideline is like the Button, the Tool is like the API function, and the association connects the two (like registering an event handler) to say, "When this guideline is applied, run this tool."
Here's a concrete example to illustrate these concepts:
- Condition: The user asks about service features
- Action: Understand their intent and consult the docs to answer
- Tools Associations:
[query_docs(user_query)]
Here, the documentation query tool only runs after the guideline instructs that we should be consulting documentation for this user interaction.
Associating a Guideline with a Tool
To allow a guideline to run a tool, here's what you do:
parlant guideline tool-enable --id GUIDELINE_ID --service SERVICE_NAME --tool TOOL_NAME
Dynamic Behavior Based on Tool Results
When you enable multiple engine iterations, tool results can potentially influence which guidelines become relevant, creating dynamic, data-driven behavior that remains under guideline control.
To learn more about enabling multiple engine iterations, please review the optimization page.
Here's how this works in practice. Consider a banking agent handling transfers. When a user requests a transfer, a guideline with the condition the user wants to make a transfer activates the get_user_account_balance()
tool to check available funds. This tool returns the current balance, which can then trigger additional guideline matches based on its return value.
For instance, if the balance is below $500, we might have a low-balance guideline activate, instructing the agent to say something like: "I see your current balance is low. Are you sure you want to proceed with this transfer? This transaction might put you at risk of overdraft fees."