Skip to content

Commit e2be77d

Browse files
authored
Merge pull request #276 from omertuc/logging2
Add debug logging when creating a new agent
2 parents e1c09c3 + 4028988 commit e2be77d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/app/endpoints/query.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ def get_agent( # pylint: disable=too-many-arguments,too-many-positional-argumen
8585
if conversation_id is not None:
8686
agent = _agent_cache.get(conversation_id)
8787
if agent:
88-
logger.debug("Reusing existing agent with key: %s", conversation_id)
88+
logger.debug(
89+
"Reusing existing agent with conversation_id: %s", conversation_id
90+
)
8991
return agent, conversation_id
92+
logger.debug("No existing agent found for conversation_id: %s", conversation_id)
9093

9194
logger.debug("Creating new agent")
9295
# TODO(lucasagomes): move to ReActAgent
@@ -100,6 +103,7 @@ def get_agent( # pylint: disable=too-many-arguments,too-many-positional-argumen
100103
enable_session_persistence=True,
101104
)
102105
conversation_id = agent.create_session(get_suid())
106+
logger.debug("Created new agent and conversation_id: %s", conversation_id)
103107
_agent_cache[conversation_id] = agent
104108
conversation_id_to_agent_id[conversation_id] = agent.agent_id
105109

src/app/endpoints/streaming_query.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ async def get_agent(
6363
if conversation_id is not None:
6464
agent = _agent_cache.get(conversation_id)
6565
if agent:
66-
logger.debug("Reusing existing agent with key: %s", conversation_id)
66+
logger.debug(
67+
"Reusing existing agent with conversation_id: %s", conversation_id
68+
)
6769
return agent, conversation_id
70+
logger.debug("No existing agent found for conversation_id: %s", conversation_id)
6871

6972
logger.debug("Creating new agent")
7073
agent = AsyncAgent(
@@ -77,6 +80,7 @@ async def get_agent(
7780
enable_session_persistence=True,
7881
)
7982
conversation_id = await agent.create_session(get_suid())
83+
logger.debug("Created new agent and conversation_id: %s", conversation_id)
8084
_agent_cache[conversation_id] = agent
8185
conversation_id_to_agent_id[conversation_id] = agent.agent_id
8286
return agent, conversation_id

0 commit comments

Comments
 (0)