Letta v0.5.2 release
🛠️ Constrain agent behavior with tool rules #1954
We are introducing initial support for "tool rules", which allows developer to define constrains on their tools, such as requiring that a tool terminate agent execution. Programming Letta agents with tool rules are similar to adding constraints with "graphs", e.g. using tool rules you can create a Letta agent that can only use tool A or tool B for its first step, and in its second step can only use tool X having chosen tool A, or tool Y having chosen tool B.
We added the following tool rules:
TerminalToolRule(tool_name=...)
- If the tool is called, the agent ends executionInitToolRule(tool_name=...)
- The tool must be called first when an agent is runToolRule(tool_name=..., children=[...])
- If the tool is called, it must be followed by one of the tools specified inchildren
Tool rules are defined per-agent, and passed when creating agents:
# agent which must always call `first_tool_to_call`, `second_tool_to_call`, then `final_tool` when invoked
agent_state = client.create_agent(
tool_rules = [
InitToolRule(tool_name="first_tool_to_call"),
ToolRule(tool_name="first_secret_word", children=["second_tool_to_call"]),
ToolRule(tool_name="fourth_secret_word", children=["final_tool"]),
TerminalToolRule(tool_name="send_message"),
]
)
By default, the send_message
tool is marked with TerminalToolRule
.
NOTE: All ToolRules
types except for TerminalToolRule
are only supported by models and providers which support structured outputs, which is currently only OpenAI with gpt-4o
and gpt-4o-mini
🤖 Tags for agents (for associating agents with end users) #1984
You can now specify and query agents via an AgentState.tags
field. If you want to associate end user IDs on your application, we recommend using tags to associate an agent with a specific end user:
# create agent for a specific user
client.create_agent(tags=["my_user_id"])
# get agents for a user
agents = client.get_agents(tags=["my_user_id"])
Read the full v0.5.2 changelog on GitHub.