Skip to content

Commit 4caabe4

Browse files
committed
clean up logs
1 parent 20d0c9b commit 4caabe4

File tree

4 files changed

+113
-6
lines changed

4 files changed

+113
-6
lines changed

agents/ld_agent_helpers.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,19 @@ async def ainvoke(self, request_data: dict) -> dict:
240240
tool_name = tool_call.name
241241
tool_calls_summary.append(tool_name)
242242

243-
# Try to extract details
243+
# Try to extract details with search query
244244
if hasattr(tool_call, 'args'):
245-
tool_details.append({
246-
"tool": tool_name,
245+
detail = {
246+
"name": tool_name,
247247
"args": tool_call.args
248-
})
248+
}
249+
# Extract search query from args if present
250+
if isinstance(tool_call.args, dict):
251+
if 'query' in tool_call.args:
252+
detail["search_query"] = tool_call.args['query']
253+
elif 'search_query' in tool_call.args:
254+
detail["search_query"] = tool_call.args['search_query']
255+
tool_details.append(detail)
249256

250257
return {
251258
"user_input": user_input,

agents/supervisor_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def create_supervisor_agent(supervisor_config, support_config, security_config,
124124
# Create child agents with config manager
125125
support_agent = create_support_agent(support_config, config_manager)
126126
security_agent = create_security_agent(security_config, config_manager)
127-
128-
log_student(f"SUPERVISOR INSTRUCTIONS: {supervisor_config.instructions}")
127+
128+
log_debug(f"SUPERVISOR INSTRUCTIONS: {supervisor_config.instructions}")
129129

130130
def pii_prescreen_node(state: SupervisorState):
131131
"""

test_semantic_scholar_timeout.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
"""Test Semantic Scholar with timeout controls"""
2+
import asyncio
3+
import sys
4+
import os
5+
6+
# Add project root to path
7+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
8+
9+
# Load environment variables
10+
from dotenv import load_dotenv
11+
load_dotenv()
12+
13+
from tools_impl.mcp_research_tools import get_mcp_research_tools
14+
15+
async def test_with_timeout(timeout_seconds: int):
16+
"""Test Semantic Scholar with a specific timeout"""
17+
print(f"\n{'='*60}")
18+
print(f"Testing with {timeout_seconds} second timeout")
19+
print(f"{'='*60}\n")
20+
21+
try:
22+
# Initialize MCP tools
23+
print("Initializing MCP tools...")
24+
mcp_tools = await get_mcp_research_tools()
25+
26+
# Get Semantic Scholar tool
27+
semantic_tool = mcp_tools.get_tool("semantic_scholar")
28+
if not semantic_tool:
29+
print("❌ Semantic Scholar tool not found!")
30+
print(f"Available tools: {mcp_tools.get_available_tools()}")
31+
return False
32+
33+
print(f"✅ Semantic Scholar tool found: {semantic_tool.name}")
34+
print(f"Description: {semantic_tool.description}\n")
35+
36+
# Test with timeout
37+
print(f"Executing search with {timeout_seconds}s timeout...")
38+
print(f"Query: 'transformer models natural language processing'")
39+
print(f"Num results: 5\n")
40+
41+
start_time = asyncio.get_event_loop().time()
42+
43+
try:
44+
# Run with timeout
45+
result = await asyncio.wait_for(
46+
semantic_tool.ainvoke({
47+
"query": "transformer models natural language processing",
48+
"num_results": 5
49+
}),
50+
timeout=timeout_seconds
51+
)
52+
53+
elapsed = asyncio.get_event_loop().time() - start_time
54+
print(f"\n✅ Completed in {elapsed:.2f} seconds")
55+
print(f"Results returned: {len(result) if isinstance(result, list) else 'N/A'}")
56+
return True
57+
58+
except asyncio.TimeoutError:
59+
elapsed = asyncio.get_event_loop().time() - start_time
60+
print(f"\n⏱️ TIMEOUT after {elapsed:.2f} seconds")
61+
print(f"Expected timeout: {timeout_seconds}s")
62+
return False
63+
64+
except Exception as e:
65+
print(f"\n❌ Error: {e}")
66+
import traceback
67+
print(traceback.format_exc())
68+
return False
69+
70+
async def main():
71+
"""Run timeout tests"""
72+
print("\n" + "="*60)
73+
print("SEMANTIC SCHOLAR TIMEOUT TEST")
74+
print("="*60)
75+
76+
# Test 1: 30 second timeout (should fail with rate limiting)
77+
print("\nTest 1: 30 second timeout (likely to hit rate limits)")
78+
result_30s = await test_with_timeout(30)
79+
80+
# Wait a bit between tests
81+
await asyncio.sleep(2)
82+
83+
# Test 2: 120 second timeout (should complete despite rate limiting)
84+
print("\n\nTest 2: 120 second timeout (should handle rate limits)")
85+
result_120s = await test_with_timeout(120)
86+
87+
# Summary
88+
print("\n" + "="*60)
89+
print("TEST SUMMARY")
90+
print("="*60)
91+
print(f"30s timeout: {'PASSED' if result_30s else 'FAILED (EXPECTED)'}")
92+
print(f"120s timeout: {'PASSED' if result_120s else 'FAILED'}")
93+
print("\nRecommendation: Use 120s timeout for Semantic Scholar to handle rate limiting")
94+
95+
if __name__ == "__main__":
96+
asyncio.run(main())

ui/chat_interface.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,13 @@ def process_tool_display(tools, tool_details):
789789

790790
if selected_user_id != st.session_state.user_id:
791791
st.session_state.user_id = selected_user_id
792+
# Clear both message histories when switching users
793+
st.session_state.messages = []
794+
st.session_state.sanitized_messages = []
792795
st.rerun()
793796

794797
if st.button("Clear Chat"):
795798
st.session_state.messages = []
799+
st.session_state.sanitized_messages = []
796800
st.rerun()
797801

0 commit comments

Comments
 (0)