Fix output order and add Reddit error handling

- SKILL.md: Move "What I learned" BEFORE "Research Complete" stats
- Add error tracking to Report schema (reddit_error, x_error fields)
- Wrap OpenAI API calls in try/catch with clear error messages
- Show explicit error or "no results" messages in compact output
- Fix false positive error detection for null error fields

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Matt Van Horn
2026-01-23 15:26:33 -08:00
parent 72e4f79d65
commit 40f9dc4877
5 changed files with 69 additions and 21 deletions
+8
View File
@@ -101,6 +101,13 @@ def parse_reddit_response(response: Dict[str, Any]) -> List[Dict[str, Any]]:
"""
items = []
# Check for API errors first
if "error" in response and response["error"]:
error = response["error"]
err_msg = error.get("message", str(error)) if isinstance(error, dict) else str(error)
print(f"[REDDIT ERROR] OpenAI API error: {err_msg}", flush=True)
return items
# Try to find the output text
output_text = ""
if "output" in response:
@@ -131,6 +138,7 @@ def parse_reddit_response(response: Dict[str, Any]) -> List[Dict[str, Any]]:
break
if not output_text:
print(f"[REDDIT WARNING] No output text found in OpenAI response. Keys present: {list(response.keys())}", flush=True)
return items
# Extract JSON from the response