Summary
After hitting the Anthropic API token limit (200,000 tokens), the jcode tool enters an unusable state. None of the recovery mechanisms work, and the tool cannot be used in new sessions.
Environment
- Tool: jcode
- Anthropic API model: all of them
- OS: Ubuntu 24.04.4 LTS (WSL2)
- jcode version: jcode v0.3.3 (eaa8834)
Steps to Reproduce
- Run a very long task that accumulates over 200,000 tokens in context
- Tool hits Anthropic API error:
prompt is too long: 202,683 tokens > 200,000 maximum
- Attempt to recover with
jcode --resume
- Attempt to use
/compact command
- Attempt to send new messages
- Start a fresh session/new conversation
- Try to use the tool in the new session
Expected Behavior
jcode --resume should gracefully handle the token limit by dropping old context or summarizing
/compact should reduce the context size and allow continued operation
- A new session should work independently without inheriting the previous session's state
- The tool should provide guidance on how to recover
Actual Behavior
jcode --resume fails silently or with unclear error messages
/compact has no effect
- New messages cannot be sent
- Fresh sessions are also affected (unable to use the tool)
- Tool remains completely unusable after hitting the limit
Error Message
✗ Anthropic API error (400 Bad Request): {"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 202683 tokens > 200000 maximum"},"request_id":"req_011CYRsajgCLywGNopbWMARY"}
Additional Context
- The context limit was reached during a legitimate long-running task
- Even starting a completely new session doesn't resolve the issue
- No recovery mechanism appears to be functional
Suggested Fixes
- Implement context management that automatically summarizes or truncates old conversation history when approaching limits
- Add a
--clear-context or --reset flag to completely clear state and start fresh
- Make
/compact command actually reduce token usage by summarizing previous context
- Improve error recovery so that hitting the limit doesn't permanently break the tool
- Provide better documentation on handling long-running tasks (task chunking, intermediate saves, etc.)
Summary
After hitting the Anthropic API token limit (200,000 tokens), the jcode tool enters an unusable state. None of the recovery mechanisms work, and the tool cannot be used in new sessions.
Environment
Steps to Reproduce
prompt is too long: 202,683 tokens > 200,000 maximumjcode --resume/compactcommandExpected Behavior
jcode --resumeshould gracefully handle the token limit by dropping old context or summarizing/compactshould reduce the context size and allow continued operationActual Behavior
jcode --resumefails silently or with unclear error messages/compacthas no effectError Message
Additional Context
Suggested Fixes
--clear-contextor--resetflag to completely clear state and start fresh/compactcommand actually reduce token usage by summarizing previous context