Skip to content

Commit 2952b2a

Browse files
Merge pull request #232 from microsoft/PSL-US-18217
feat: clean up logging
2 parents 852ff81 + 0cb3df5 commit 2952b2a

File tree

5 files changed

+55
-77
lines changed

5 files changed

+55
-77
lines changed

src/backend/app_kernel.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,8 @@ async def input_task_endpoint(input_task: InputTask, request: Request):
139139
# Convert input task to JSON for the kernel function, add user_id here
140140

141141
# Use the planner to handle the task
142-
result = await group_chat_manager.handle_input_task(input_task)
142+
await group_chat_manager.handle_input_task(input_task)
143143

144-
print(f"Result: {result}")
145144
# Get plan from memory store
146145
plan = await memory_store.get_plan_by_session(input_task.session_id)
147146

@@ -178,7 +177,6 @@ async def input_task_endpoint(input_task: InputTask, request: Request):
178177
}
179178

180179
except Exception as e:
181-
logging.exception(f"Error handling input task: {e}")
182180
track_event_if_configured(
183181
"InputTaskError",
184182
{
@@ -781,18 +779,17 @@ async def delete_all_messages(request: Request) -> Dict[str, str]:
781779
authenticated_user = get_authenticated_user_details(request_headers=request.headers)
782780
user_id = authenticated_user["user_principal_id"]
783781
if not user_id:
782+
track_event_if_configured(
783+
"UserIdNotFound", {"status_code": 400, "detail": "no user"}
784+
)
784785
raise HTTPException(status_code=400, detail="no user")
785786

786787
# Initialize memory context
787788
kernel, memory_store = await initialize_runtime_and_context("", user_id)
788789

789-
logging.info("Deleting all plans")
790790
await memory_store.delete_all_items("plan")
791-
logging.info("Deleting all sessions")
792791
await memory_store.delete_all_items("session")
793-
logging.info("Deleting all steps")
794792
await memory_store.delete_all_items("step")
795-
logging.info("Deleting all agent_messages")
796793
await memory_store.delete_all_items("agent_message")
797794

798795
# Clear the agent factory cache
@@ -842,6 +839,9 @@ async def get_all_messages(request: Request):
842839
authenticated_user = get_authenticated_user_details(request_headers=request.headers)
843840
user_id = authenticated_user["user_principal_id"]
844841
if not user_id:
842+
track_event_if_configured(
843+
"UserIdNotFound", {"status_code": 400, "detail": "no user"}
844+
)
845845
raise HTTPException(status_code=400, detail="no user")
846846

847847
# Initialize memory context

src/backend/context/cosmos_memory_kernel.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ async def initialize(self):
8484
id=self._cosmos_container,
8585
partition_key=PartitionKey(path="/session_id"),
8686
)
87-
logging.info("Successfully connected to CosmosDB")
8887
except Exception as e:
8988
logging.error(
9089
f"Failed to initialize CosmosDB container: {e}. Continuing without CosmosDB for testing."

src/backend/handlers/runtime_interrupt_kernel.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ async def on_message(
5555
Returns:
5656
The original message (for pass-through functionality)
5757
"""
58-
print(
59-
f"NeedsUserInputHandler received message: {message} from sender: {sender_type}/{sender_key}"
60-
)
61-
6258
if isinstance(message, GetHumanInputMessage):
6359
self.question_for_human = message
6460
self.messages.append(
@@ -67,7 +63,6 @@ async def on_message(
6763
"content": message.content,
6864
}
6965
)
70-
print("Captured question for human in NeedsUserInputHandler")
7166
elif isinstance(message, GroupChatMessage):
7267
# Ensure we extract content consistently with the original implementation
7368
content = (
@@ -81,7 +76,6 @@ async def on_message(
8176
"content": content,
8277
}
8378
)
84-
print(f"Captured group chat message in NeedsUserInputHandler - {message}")
8579
elif isinstance(message, dict) and "content" in message:
8680
# Handle messages directly from AzureAIAgent
8781
self.question_for_human = GetHumanInputMessage(content=message["content"])
@@ -91,7 +85,6 @@ async def on_message(
9185
"content": message["content"],
9286
}
9387
)
94-
print("Captured question from AzureAIAgent in NeedsUserInputHandler")
9588

9689
return message
9790

@@ -111,7 +104,6 @@ def get_messages(self) -> List[Dict[str, Any]]:
111104
"""Get captured messages and clear buffer."""
112105
messages = self.messages.copy()
113106
self.messages.clear()
114-
print("Returning and clearing captured messages in NeedsUserInputHandler")
115107
return messages
116108

117109

@@ -133,38 +125,28 @@ async def on_message(self, message: Any, sender_type: str = None) -> Any:
133125
Returns:
134126
The original message (for pass-through functionality)
135127
"""
136-
print(
137-
f"on_message called in AssistantResponseHandler with message from sender: {sender_type} - {message}"
138-
)
139-
140128
if hasattr(message, "body") and sender_type in ["writer", "editor"]:
141129
# Ensure we're handling the content consistently with the original implementation
142130
self.assistant_response = (
143131
message.body.content
144132
if hasattr(message.body, "content")
145133
else str(message.body)
146134
)
147-
print("Assistant response set in AssistantResponseHandler")
148135
elif isinstance(message, dict) and "value" in message and sender_type:
149136
# Handle message from AzureAIAgent
150137
self.assistant_response = message["value"]
151-
print(
152-
"Assistant response from AzureAIAgent set in AssistantResponseHandler"
153-
)
154138

155139
return message
156140

157141
@property
158142
def has_response(self) -> bool:
159143
"""Check if response is available."""
160144
has_response = self.assistant_response is not None
161-
print(f"has_response called, returning: {has_response}")
162145
return has_response
163146

164147
def get_response(self) -> Optional[str]:
165148
"""Get captured response."""
166149
response = self.assistant_response
167-
print(f"get_response called, returning: {response}")
168150
return response
169151

170152

@@ -201,7 +183,6 @@ def register_handlers(kernel: sk.Kernel, session_id: str) -> tuple:
201183
kernel.set_variable(f"input_handler_{session_id}", user_input_handler)
202184
kernel.set_variable(f"response_handler_{session_id}", assistant_handler)
203185

204-
print(f"Registered handlers for session {session_id} with kernel")
205186
return user_input_handler, assistant_handler
206187

207188

0 commit comments

Comments
 (0)