fix(kiro): trigger Claude compact for overlength requests#9
Conversation
There was a problem hiding this comment.
Code Review
This pull request maps upstream content length exceeded errors and exceptions to a specific "prompt too long" error with a 413 Payload Too Large status code, and updates the stream stop reason to "model_context_window_exceeded". Feedback suggests expanding the detection logic in kiro_text_is_content_length_exceeded to also match the generic "input is too long" string to ensure robust error handling.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6733c094b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Prompt is too long.ContentLengthExceededExceptionbefore returning normal assistant/SSE output.Root cause
Claude Code 2.1.156 only enters its reactive compact path when its API-error assistant text is normalized to
Prompt is too long. The gateway was exposing Kiro overlength failures as generic 400Input is too long/Input content length exceeds threshold, and eventstream exceptions could still be treated like normal assistant responses ormax_tokens.What changed
invalid_request_errorJSON with HTTP 413 and parseable<actual> tokens > <limit> tokensdetails.ContentLengthExceededExceptionstop reasons tomodel_context_window_exceeded.Test Plan
cargo test -p llm-access-kiro --jobs 4cargo test -p llm-access --jobs 4 -- --test-threads=1cargo clippy -p llm-access-kiro -p llm-access --jobs 4 -- -D warnings