Repository navigation
Closed
Description
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
/compactcommand - Attempt to send new messages
- Start a fresh session/new conversation
- Try to use the tool in the new session
Expected Behavior
jcode --resumeshould gracefully handle the token limit by dropping old context or summarizing/compactshould 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 --resumefails silently or with unclear error messages/compacthas 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-contextor--resetflag to completely clear state and start fresh - Make
/compactcommand 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.)
Metadata
Metadata
Assignees
Labels
No labels
Activity
1jehuang commentedon Feb 24, 2026
Released in v0.4.0.\n\nThis includes context-limit recovery work for the "prompt is too long" failure mode:\n- fcbf9dd: Auto-compact and retry on context limit errors\n- f667274: Add context-limit retry cap to avoid infinite loops\n\nClosing this as resolved in v0.4.0. If you still hit this on v0.4.0+, please open a follow-up with logs and repro steps.
docs(m22): reproduce confirmed 2026-05-12, raise priority + MEMORY
perf(compile): memory-adaptive cargo job count to curb OOM (#5)
fix(providers): roll back partial output on mid-stream retry instead …
perf(compile): memory-adaptive cargo job count to curb OOM (1jehuang#5)
fix(providers): roll back partial output on mid-stream retry instead …
perf(compile): memory-adaptive cargo job count to curb OOM (1jehuang#5)
fix(providers): roll back partial output on mid-stream retry instead …
feat(session): make compaction log-bracketed with orphan detection (1…
feat(session): persist the event-sourced log end-to-end via snapshot …
feat(session): add log-bracketed compaction producer seam (1jehuang#5)
docs(research)+test: verify event-sourced log via public API lifecycle
test(session): orphaned bracket fails the public CompactionBracket in…
docs(research): note crash-safe bracket retry in the takeaway 1jehuang#5
test(session): forking mid-bracket is consistent and resolvable
refactor(review-loop): resolve four trade-offs and drop unneeded back…
feat(session): make live producer compaction log-bracketed (1jehuang#5)
feat(agent): write native compaction inside bracket too (1jehuang#5)
feat(tui): write TUI compaction inside bracket too (1jehuang#5)
docs(research): record deepseek-harness plan implementation status
docs(research): state interpretation of the 1jehuang#5 follow-up cand…
docs(research): add explicit Follow-ups section for open items
feat(review): harden the headless review path (1jehuang#2-1jehuang#5)
feat(handoff): resolve remaining manual-selection trade-offs
feat(handoff): resolve remaining manual-selection trade-offs
feat(handoff): typed wire fields and atomic HandoffApply
Merge branch 'chore/upstream-sync-2026-11-10' into 'master'