Skip to content

Commit 9c77760

Browse files
eranco74thoraxe
authored andcommitted
Add debug logging when creating a new agent
Signed-off-by: Eran Cohen <[email protected]>
1 parent 9b0e427 commit 9c77760

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
@@ -86,8 +86,11 @@ def get_agent( # pylint: disable=too-many-arguments,too-many-positional-argumen
8686
if conversation_id is not None:
8787
agent = _agent_cache.get(conversation_id)
8888
if agent:
89-
logger.debug("Reusing existing agent with key: %s", conversation_id)
89+
logger.debug(
90+
"Reusing existing agent with conversation_id: %s", conversation_id
91+
)
9092
return agent, conversation_id
93+
logger.debug("No existing agent found for conversation_id: %s", conversation_id)
9194

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

src/app/endpoints/streaming_query.py

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

7073
logger.debug("Creating new agent")
7174
agent = AsyncAgent(
@@ -78,6 +81,7 @@ async def get_agent(
7881
enable_session_persistence=True,
7982
)
8083
conversation_id = await agent.create_session(get_suid())
84+
logger.debug("Created new agent and conversation_id: %s", conversation_id)
8185
_agent_cache[conversation_id] = agent
8286
conversation_id_to_agent_id[conversation_id] = agent.agent_id
8387
return agent, conversation_id

0 commit comments

Comments
 (0)