-
Notifications
You must be signed in to change notification settings - Fork 1.6k
TEMP: add debug logging for API conversation history issues #4312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add detailed logging to readApiMessages function to help diagnose "Unexpected: No existing API conversation history" errors. The logs will show: - When the history file exists but contains an empty array - When the old history file exists but contains an empty array - When neither history file is found This will help diagnose issues like the one in #4311 where the API conversation history file gets truncated to an empty array during task resumption with orchestrator tasks. Fixes: #4311 Signed-off-by: Eric Wheeler <[email protected]>
Add error handling for JSON parsing failures in readApiMessages: - Wrap JSON.parse calls in try/catch blocks for both current and legacy history files - Add detailed error logging with taskId and file paths - Return empty arrays when parsing fails to maintain function contract - Improve existing debug logging for empty history arrays - Handle file unlinking even when parsing fails This prevents crashes from malformed JSON in history files and provides better debugging information when API conversation history is corrupted. Related to issue #4311. Signed-off-by: Eric Wheeler <[email protected]>
21a8167
to
9d19c68
Compare
See notes on the issue as to why I moved this to draft |
You can leave us in draft if you want, this is not something I am going to put more work into. I just wanted to provide the steps I took for troubleshooting and case it helps someone else along the way. These debug prints are non-intrusive, uncommon, only trigger upon error, and only serve to help troubleshoot this problem if somebody else hits it. IMHO, PRs like this should be merged quickly to help future troubleshooting by others. (Someday if I clean up and delete the branch, then this research could be lost.) |
Context
This PR adds detailed debug logging to the
readApiMessages
function to help diagnose "Unexpected: No existing API conversation history" errors.Implementation
Added logging for three scenarios:
How to Test
When encountering the "Unexpected: No existing API conversation history" error, check the Developer Tools console (Help > Toggle Developer Tools > Console tab) for debug messages with the format:
[Roo-Debug] readApiMessages: ...
These logs will show the taskId and file path, helping to diagnose the issue.
Screenshots
N/A - Console logging only
Get in Touch
Discord: KJ7LNW
does not completely fix #4311 but it may provide debug output that may help us fix it from other users.
Important
Adds debug logging to
readApiMessages
for diagnosing empty or missing API conversation history files.readApiMessages
for empty API conversation history files.apiConversationHistory
file is empty.claude_messages.json
file is empty.readApiMessages
inapiMessages.ts
to include new logging scenarios.This description was created by
for 49a68c1. You can customize this summary. It will automatically update as commits are pushed.