Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: agent_tags for provider traces (#8989)

Kian Jones7133083b81d0
diff --git a/letta/agents/letta_agent_v3.py b/letta/agents/letta_agent_v3.py
index b942b7aeb..6e6cda016 100644
--- a/letta/agents/letta_agent_v3.py
+++ b/letta/agents/letta_agent_v3.py
@@ -168,7 +168,11 @@ class LettaAgentV3(LettaAgentV2):
input_messages_to_persist=input_messages_to_persist,
# TODO need to support non-streaming adapter too
llm_adapter=SimpleLLMRequestAdapter(
- llm_client=self.llm_client, llm_config=self.agent_state.llm_config, agent_id=self.agent_state.id, run_id=run_id
+ llm_client=self.llm_client,
+ llm_config=self.agent_state.llm_config,
+ agent_id=self.agent_state.id,
+ agent_tags=self.agent_state.tags,
+ run_id=run_id,
),
run_id=run_id,
# use_assistant_message=use_assistant_message,
@@ -310,6 +314,7 @@ class LettaAgentV3(LettaAgentV2):
llm_client=self.llm_client,
llm_config=self.agent_state.llm_config,
agent_id=self.agent_state.id,
+ agent_tags=self.agent_state.tags,
run_id=run_id,
)
else:
@@ -317,6 +322,7 @@ class LettaAgentV3(LettaAgentV2):
llm_client=self.llm_client,
llm_config=self.agent_state.llm_config,
agent_id=self.agent_state.id,
+ agent_tags=self.agent_state.tags,
run_id=run_id,
)
diff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.py
index 031feaa8c..1694f6dfe 100644
--- a/letta/server/rest_api/routers/v1/agents.py
+++ b/letta/server/rest_api/routers/v1/agents.py
@@ -628,7 +628,9 @@ async def run_tool_for_agent(
# Get agent with all relationships
agent = await server.agent_manager.get_agent_by_id_async(
- agent_id, actor, include_relationships=["memory", "multi_agent_group", "sources", "tool_exec_environment_variables", "tools"]
+ agent_id,
+ actor,
+ include_relationships=["memory", "multi_agent_group", "sources", "tool_exec_environment_variables", "tools", "tags"],
)
# Find the tool by name among attached tools
@@ -1520,7 +1522,9 @@ async def send_message(
MetricRegistry().user_message_counter.add(1, get_ctx_attributes())
# TODO: This is redundant, remove soon
agent = await server.agent_manager.get_agent_by_id_async(
- agent_id, actor, include_relationships=["memory", "multi_agent_group", "sources", "tool_exec_environment_variables", "tools"]
+ agent_id,
+ actor,
+ include_relationships=["memory", "multi_agent_group", "sources", "tool_exec_environment_variables", "tools", "tags"],
)
# Handle model override if specified in the request
@@ -1799,7 +1803,9 @@ async def _process_message_background(
try:
agent = await server.agent_manager.get_agent_by_id_async(
- agent_id, actor, include_relationships=["memory", "multi_agent_group", "sources", "tool_exec_environment_variables", "tools"]
+ agent_id,
+ actor,
+ include_relationships=["memory", "multi_agent_group", "sources", "tool_exec_environment_variables", "tools", "tags"],
)
# Handle model override if specified
@@ -1966,7 +1972,9 @@ async def send_message_async(
if use_lettuce:
agent_state = await server.agent_manager.get_agent_by_id_async(
- agent_id, actor, include_relationships=["memory", "multi_agent_group", "sources", "tool_exec_environment_variables", "tools"]
+ agent_id,
+ actor,
+ include_relationships=["memory", "multi_agent_group", "sources", "tool_exec_environment_variables", "tools", "tags"],
)
# Allow V1 agents only if the message async flag is enabled
is_v1_message_async_enabled = (
diff --git a/letta/services/streaming_service.py b/letta/services/streaming_service.py
index d79506849..bc5a4cdc9 100644
--- a/letta/services/streaming_service.py
+++ b/letta/services/streaming_service.py
@@ -95,7 +95,9 @@ class StreamingService:
# load agent and check eligibility
agent = await self.server.agent_manager.get_agent_by_id_async(
- agent_id, actor, include_relationships=["memory", "multi_agent_group", "sources", "tool_exec_environment_variables", "tools"]
+ agent_id,
+ actor,
+ include_relationships=["memory", "multi_agent_group", "sources", "tool_exec_environment_variables", "tools", "tags"],
)
# Handle model override if specified in the request