[PR #1097] [CLOSED] fix: improve prompt length error handling and auto-recovery #9809

Closed
opened 2026-02-16 18:14:12 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/1097
Author: @chrissouk-001
Created: 7/17/2025
Status: Closed

Base: devHead: fix/prompt-too-long-error-handling


📝 Commits (3)

  • c404aeb perf: optimize file operations and reduce code duplication in glob/ls tools
  • 0398df5 refactor: move file utilities from util/file-tools.ts to util/fs.ts
  • 621ad2a fix: improve prompt length error handling and auto-recovery

📊 Changes

5 files changed (+198 additions, -74 deletions)

View changed files

📝 packages/opencode/src/session/index.ts (+85 -48)
📝 packages/opencode/src/session/message-v2.ts (+5 -0)
📝 packages/opencode/src/tool/glob.ts (+12 -20)
📝 packages/opencode/src/tool/ls.ts (+9 -6)
packages/opencode/src/util/fs.ts (+87 -0)

📄 Description

Fixes #1092 by adding proper handling for "prompt is too long" errors from AI providers.

Changes

  • Add APICallError handling for prompt length errors
  • Implement automatic summarization retry when prompt exceeds limits
  • Add new PromptTooLongError type for better error reporting
  • Fix TypeScript type narrowing issues

When users hit context limits, the system now automatically summarizes and retries instead of failing with a generic error.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/1097 **Author:** [@chrissouk-001](https://github.com/chrissouk-001) **Created:** 7/17/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/prompt-too-long-error-handling` --- ### 📝 Commits (3) - [`c404aeb`](https://github.com/anomalyco/opencode/commit/c404aeb49d469b845d015d5f63f2b576ef22d10c) perf: optimize file operations and reduce code duplication in glob/ls tools - [`0398df5`](https://github.com/anomalyco/opencode/commit/0398df5f884ddb02e9220a4a9d530b4deddf3965) refactor: move file utilities from util/file-tools.ts to util/fs.ts - [`621ad2a`](https://github.com/anomalyco/opencode/commit/621ad2a6ba4557a2c4573ee3b0c1df3c4557fa6c) fix: improve prompt length error handling and auto-recovery ### 📊 Changes **5 files changed** (+198 additions, -74 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/session/index.ts` (+85 -48) 📝 `packages/opencode/src/session/message-v2.ts` (+5 -0) 📝 `packages/opencode/src/tool/glob.ts` (+12 -20) 📝 `packages/opencode/src/tool/ls.ts` (+9 -6) ➕ `packages/opencode/src/util/fs.ts` (+87 -0) </details> ### 📄 Description Fixes #1092 by adding proper handling for "prompt is too long" errors from AI providers. ## Changes - Add `APICallError` handling for prompt length errors - Implement automatic summarization retry when prompt exceeds limits - Add new `PromptTooLongError` type for better error reporting - Fix TypeScript type narrowing issues When users hit context limits, the system now automatically summarizes and retries instead of failing with a generic error. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:12 -05:00
yindo closed this issue 2026-02-16 18:14:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9809