Skip to content

Commit c13a63c

Browse files
author
Heena Ugale
committed
Update reflection agent with clean emoji-free logging and improved WebSocket streaming
1 parent cb6033c commit c13a63c

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

agentic_ai/agents/agent_framework/multi_agent/reflection_agent.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def __init__(self, state_store: Dict[str, Any], session_id: str, access_token: s
2525
self._current_turn = state_store.get(self._turn_key, 0)
2626

2727
# Log that reflection agent is being used
28-
print(f"🔥 REFLECTION AGENT INITIALIZED - Session: {session_id}")
29-
logger.info(f"🔥 REFLECTION AGENT INITIALIZED - Session: {session_id}")
28+
print(f"REFLECTION AGENT INITIALIZED - Session: {session_id}")
29+
logger.info(f"REFLECTION AGENT INITIALIZED - Session: {session_id}")
3030

3131
def set_websocket_manager(self, manager: Any) -> None:
3232
"""Allow backend to inject WebSocket manager for streaming events."""
@@ -117,8 +117,8 @@ async def _maybe_create_tools(self, headers: Dict[str, str]) -> List[MCPStreamab
117117

118118
async def chat_async(self, prompt: str) -> str:
119119
"""Run Primary Agent → Reviewer → Primary Agent refinement pipeline for customer support."""
120-
print(f"🔥 REFLECTION AGENT chat_async called with prompt: {prompt[:50]}...")
121-
logger.info(f"🔥 REFLECTION AGENT chat_async called with prompt: {prompt[:50]}...")
120+
print(f"REFLECTION AGENT chat_async called with prompt: {prompt[:50]}...")
121+
logger.info(f"REFLECTION AGENT chat_async called with prompt: {prompt[:50]}...")
122122

123123
await self._setup_reflection_agents()
124124
if not (self._primary_agent and self._reviewer and self._thread):
@@ -129,20 +129,20 @@ async def chat_async(self, prompt: str) -> str:
129129

130130
# Use streaming if WebSocket manager is available
131131
if self._ws_manager:
132-
print(f"🔥 REFLECTION AGENT: Using STREAMING path")
133-
logger.info(f"🔥 REFLECTION AGENT: Using STREAMING path")
132+
print(f"REFLECTION AGENT: Using STREAMING path")
133+
logger.info(f"REFLECTION AGENT: Using STREAMING path")
134134
return await self._chat_async_streaming(prompt)
135135

136136
# Non-streaming path (fallback)
137-
print(f"🔥 REFLECTION AGENT: Using NON-STREAMING path")
138-
logger.info(f"🔥 REFLECTION AGENT: Using NON-STREAMING path")
137+
print(f"REFLECTION AGENT: Using NON-STREAMING path")
138+
logger.info(f"REFLECTION AGENT: Using NON-STREAMING path")
139139
return await self._chat_async_non_streaming(prompt)
140140

141141
async def _chat_async_streaming(self, prompt: str) -> str:
142142
"""Handle reflection workflow with streaming support via WebSocket."""
143143

144-
print(f"🔥 STREAMING: Starting reflection workflow for: {prompt[:50]}...")
145-
logger.info(f"🔥 STREAMING: Starting reflection workflow for: {prompt[:50]}...")
144+
print(f"STREAMING: Starting reflection workflow for: {prompt[:50]}...")
145+
logger.info(f"STREAMING: Starting reflection workflow for: {prompt[:50]}...")
146146

147147
# Notify UI that reflection workflow is starting
148148
if self._ws_manager:
@@ -165,8 +165,8 @@ async def _chat_async_streaming(self, prompt: str) -> str:
165165
)
166166

167167
# Step 1: Primary Agent (Customer Support) handles the customer inquiry
168-
print(f"🔥 STREAMING STEP 1: Primary Agent processing customer inquiry")
169-
logger.info(f"🔥 STREAMING STEP 1: Primary Agent processing customer inquiry")
168+
print(f"STREAMING STEP 1: Primary Agent processing customer inquiry")
169+
logger.info(f"STREAMING STEP 1: Primary Agent processing customer inquiry")
170170

171171
# Notify UI about Step 1
172172
if self._ws_manager:
@@ -216,8 +216,8 @@ async def _chat_async_streaming(self, prompt: str) -> str:
216216
initial_response = ''.join(step1_response)
217217

218218
# Step 2: Reviewer checks the customer support response
219-
print(f"🔥 STREAMING STEP 2: Reviewer evaluating response quality")
220-
logger.info(f"🔥 STREAMING STEP 2: Reviewer evaluating response quality")
219+
print(f"STREAMING STEP 2: Reviewer evaluating response quality")
220+
logger.info(f"STREAMING STEP 2: Reviewer evaluating response quality")
221221

222222
# Send complete primary agent response
223223
if self._ws_manager:
@@ -289,8 +289,8 @@ async def _chat_async_streaming(self, prompt: str) -> str:
289289

290290
# Step 3: Determine if refinement is needed
291291
if "APPROVE" not in feedback_result_text.upper():
292-
print(f"🔥 STREAMING STEP 3: REFINEMENT NEEDED - Primary Agent improving response")
293-
logger.info(f"🔥 STREAMING STEP 3: REFINEMENT NEEDED - Primary Agent improving response")
292+
print(f"STREAMING STEP 3: REFINEMENT NEEDED - Primary Agent improving response")
293+
logger.info(f"STREAMING STEP 3: REFINEMENT NEEDED - Primary Agent improving response")
294294

295295
# Notify UI about Step 3 - refinement
296296
if self._ws_manager:
@@ -362,8 +362,8 @@ async def _chat_async_streaming(self, prompt: str) -> str:
362362
},
363363
)
364364
else:
365-
print(f"🔥 STREAMING STEP 3: APPROVED - Response approved by reviewer")
366-
logger.info(f"🔥 STREAMING STEP 3: APPROVED - Response approved by reviewer")
365+
print(f"STREAMING STEP 3: APPROVED - Response approved by reviewer")
366+
logger.info(f"STREAMING STEP 3: APPROVED - Response approved by reviewer")
367367

368368
# Notify UI about approval
369369
if self._ws_manager:

0 commit comments

Comments
 (0)