Skip to content

Stuck at "prompt is too long" #5

@slashwarm

Description

@slashwarm

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

  1. Run a very long task that accumulates over 200,000 tokens in context
  2. Tool hits Anthropic API error: prompt is too long: 202,683 tokens > 200,000 maximum
  3. Attempt to recover with jcode --resume
  4. Attempt to use /compact command
  5. Attempt to send new messages
  6. Start a fresh session/new conversation
  7. 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

  1. Implement context management that automatically summarizes or truncates old conversation history when approaching limits
  2. Add a --clear-context or --reset flag to completely clear state and start fresh
  3. Make /compact command actually reduce token usage by summarizing previous context
  4. Improve error recovery so that hitting the limit doesn't permanently break the tool
  5. Provide better documentation on handling long-running tasks (task chunking, intermediate saves, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions