* docs: restructure architecture documentation to sideline legacy agent types This commit reorganizes the agent architecture documentation to address confusion around legacy agent types (memgpt_agent, memgpt_v2_agent) and clarify that users should not specify agent_type for new projects. The documentation was causing confusion for both users and LLMs: - References to memgpt_agent, memgpt_v2_agent, and letta_v1_agent were scattered throughout main docs - The naming progression (memgpt → memgpt_v2 → letta_v1) is non-standard - LLMs trained on these docs were recommending deprecated architectures - Discord users were confused about which agent type to use - send_message tool and heartbeat references were in mainline docs - architectures_overview.mdx - Landing page explaining legacy types exist - migration_guide.mdx - Step-by-step migration with code snippets - naming_history.mdx - Hidden page explaining progression for LLMs - memgpt_agents_legacy.mdx - Moved from main docs with deprecation warnings - heartbeats_legacy.mdx - Moved from main docs with deprecation warnings - Removed "Agent Architectures" subsection from main nav - Moved "MemGPT Agents" to top-level (renamed "Agent Memory & Architecture") - Removed "Heartbeats" page from main nav - Added "Legacy & Migration" section with 5 sub-pages - Added redirects for old URLs - pages/agents/memgpt_agents.mdx - Completely rewritten to focus on current architecture without mentioning legacy agent types - pages/agents/sleep_time_agents.mdx - Changed from agent_type to enableSleeptime - pages/agents/base_tools.mdx - Added stronger deprecation warning for send_message - pages/agents/overview.mdx - Updated assistant_message description - pages/agents/tool_rules.mdx - Removed send_message default rule examples - pages/agents/message_types.mdx - Removed heartbeat message type section - pages/agents/json_mode.mdx - Removed send_message requirements - pages/agents/archival_best_practices.mdx - Removed send_message tool rule example - pages/agents/react_agents.mdx - Removed heartbeat mechanism reference - pages/getting-started/prompts.mdx - Removed send_message note - pages/ade-guide/simulator.mdx - Removed tip about removing send_message - pages/advanced/custom_memory.mdx - Changed send_message to "respond to user" - pages/deployment/railway.mdx - Removed legacy tools array from example - pages/selfhosting/overview.mdx - Changed send_message example to memory_insert - pages/agents/heartbeats.mdx - Moved to legacy section Added to memory: aggressively remove send_message and heartbeat references from main docs. Keep legacy content only in /guides/legacy/ section. Don't add notes about legacy in main docs - just remove the references entirely. * docs: remove evals tab from navigation The evals content is not ready for public documentation yet. * docs: move send_message to deprecated tools table with legacy link - Removed Legacy Tools section - Added send_message to Deprecated Tools table with link to legacy guide - Removed undefined warning text * docs: move ReAct agents to legacy section - Moved pages/agents/react_agents.mdx to pages/legacy/react_agents_legacy.mdx - Added deprecation warning at top - Updated slug to guides/legacy/react_agents_legacy - Added to Legacy & Migration navigation section - Added redirect from old URL to new legacy location ReAct agents are a legacy architecture that lacks long-term memory capabilities compared to the current Letta architecture. * docs: move workflow and low-latency architectures to legacy - Moved pages/agents/workflows.mdx to pages/legacy/workflows_legacy.mdx - Moved pages/agents/low_latency_agents.mdx to pages/legacy/low_latency_agents_legacy.mdx - Deleted pages/agents/architectures.mdx (overview page no longer needed) - Removed 'Agent Memory & Architecture' from main Agents section - Added workflows and low-latency to Legacy & Migration section - Added redirects for old URLs These agent architectures (workflow_agent, voice_convo_agent) are legacy. For new projects, users should use the current Letta architecture with tool rules or voice-optimized configurations instead. * docs: remove orphaned stateful workflows page - Deleted pages/agents/stateful_workflows.mdx - Page was not linked in navigation or from other docs - Feature (message_buffer_autoclear flag) is already documented in API reference - Avoids confusion with legacy workflow architectures
92 lines
3.2 KiB
Plaintext
92 lines
3.2 KiB
Plaintext
---
|
|
title: Creating Tool Rules
|
|
slug: guides/agents/tool-rules
|
|
---
|
|
|
|
Tool rules allows developer to define constrains on their tools, such as requiring that a tool terminate agent execution or be followed by another tool.
|
|
|
|
<Frame>
|
|
```mermaid
|
|
flowchart LR
|
|
subgraph init["InitToolRule"]
|
|
direction LR
|
|
start((Start)) --> init_tool["must_run_first"]
|
|
init_tool --> other1["...other tools..."]
|
|
end
|
|
|
|
subgraph terminal["TerminalToolRule"]
|
|
direction LR
|
|
other2["...other tools..."] --> term_tool["terminal_tool"] --> stop1((Stop))
|
|
end
|
|
|
|
subgraph sequence["ChildToolRule (children)"]
|
|
direction LR
|
|
parent_tool["parent_tool"] --> child1["child_tool_1"]
|
|
parent_tool --> child2["child_tool_2"]
|
|
parent_tool --> child3["child_tool_3"]
|
|
end
|
|
|
|
classDef stop fill:#ffcdd2,stroke:#333
|
|
classDef start fill:#c8e6c9,stroke:#333
|
|
class stop1 stop
|
|
class start start
|
|
```
|
|
</Frame>
|
|
|
|
Letta currently supports the following tool rules (with more being added):
|
|
|
|
* `TerminalToolRule(tool_name=...)`
|
|
* If the tool is called, the agent ends execution
|
|
* `InitToolRule(tool_name=...)`
|
|
* The tool must be called first when an agent is run
|
|
* `ChildToolRule(tool_name=..., children=[...])`
|
|
* If the tool is called, it must be followed by one of the tools specified in `children`
|
|
* `ParentToolRule(tool_name=..., children=[...])`
|
|
* The tool must be called before the tools specified in `children` can be called
|
|
* `ConditionalToolRule(tool_name=..., child_output_mapping={...})`
|
|
* If the tool is called, it must be followed by one of the tools specified in `children` based off the tool's output
|
|
* `ContinueToolRule(tool_name=...)`
|
|
* If the tool is called, the agent must continue execution
|
|
* `MaxCountPerStepToolRule(tool_name=..., max_count_limit=...)`
|
|
* The tool cannot be called more than `max_count_limit` times in a single step
|
|
|
|
## Default tool rules
|
|
|
|
Depending on your agent configuration, there may be default tool rules applied to improve performance.
|
|
|
|
## Tool rule examples
|
|
|
|
For example, you can ensure that the agent will stop execution after the `roll_d20` tool is called by specifying tool rules in the agent creation:
|
|
<CodeGroup>
|
|
```typescript TypeScript {6-11}
|
|
// create a new agent
|
|
const agentState = await client.createAgent({
|
|
// create the agent with an additional tool
|
|
tools: [tool.name],
|
|
// add tool rules that terminate execution after specific tools
|
|
toolRules: [
|
|
// exit after roll_d20 is called
|
|
{toolName: tool.name, type: "exit_loop"},
|
|
],
|
|
});
|
|
|
|
console.log(`Created agent with name ${agentState.name} with tools ${agentState.tools}`);
|
|
```
|
|
```python Python {6-11}
|
|
# create a new agent
|
|
agent_state = client.create_agent(
|
|
# create the agent with an additional tool
|
|
tools=[tool.name],
|
|
# add tool rules that terminate execution after specific tools
|
|
tool_rules=[
|
|
# exit after roll_d20 is called
|
|
TerminalToolRule(tool_name=tool.name, type="exit_loop"),
|
|
],
|
|
)
|
|
|
|
print(f"Created agent with name {agent_state.name} with tools {agent_state.tools}")
|
|
```
|
|
</CodeGroup>
|
|
|
|
You can see a full working example of tool rules [here](https://github.com/letta-ai/letta/blob/0.5.2/examples/tool_rule_usage.py).
|