Skip to content

Commit 54360e0

Browse files
committed
debug: add SSE stream line counting and parse error details
Shows: - Number of lines read from SSE stream - Parse errors with data preview - Helps identify if stream is empty vs malformed
1 parent 2c341be commit 54360e0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test_http_agentic_tools.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,10 @@ def send_request(self, payload, timeout=60):
190190

191191
# Parse SSE stream for JSON-RPC responses
192192
result_data = None
193+
line_count = 0
193194

194195
for line in response.iter_lines(decode_unicode=True):
196+
line_count += 1
195197
if not line:
196198
continue
197199

@@ -212,14 +214,15 @@ def send_request(self, payload, timeout=60):
212214
print(f"❌ MCP error: {event['error']}")
213215
return None, time.time() - start_time
214216
except json.JSONDecodeError as e:
215-
print(f"⚠️ Failed to parse SSE data: {e}")
217+
print(f"⚠️ Failed to parse SSE data (line {line_count}): {e}")
218+
print(f" Data preview: {data[:200]}")
216219
continue
217220

218221
duration = time.time() - start_time
219222
if result_data:
220223
return result_data, duration
221224
else:
222-
print(f"⚠️ No result found in SSE stream")
225+
print(f"⚠️ No result found in SSE stream ({line_count} lines read)")
223226
return None, duration
224227
else:
225228
print(f"❌ HTTP {response.status_code}: {response.text[:200]}")

0 commit comments

Comments
 (0)