ECA becomes unresponsive when tool output causes LLM context overflow
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start by reproducing the freeze with a large tool output, then read eca-process.el for synchronous JSON parsing and eca-chat.el for content insertion and buffer-wide fontification and table alignment. The issue identifies server-side context overflow recovery and client-side rendering as contributing areas, but does not specify a single fix. Done means large tool output and context overflow no longer leave ECA or Emacs unresponsive.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
When a tool (especially shell commands) produces very large output, ECA hits the LLM provider's token limit with:
LLM response status: 400 body: {"error":{"message":"prompt token count of 174837 exceeds the limit of 168000","code":"model_max_prompt_tokens_exceeded"}}
After this error, the ECA server and Emacs become unresponsive/frozen, requiring a restart.
Root Cause Analysis
The issue involves multiple contributing factors on both server and client side.
Server-side
-
No proactive token budget check before API call: The server sends the full message history to the LLM provider without estimating token usage. Context overflow is only detected reactively (HTTP 400 response) and recovered via prune + auto-compact. While the recovery logic works, it doesn't prevent the initial expensive roundtrip and the cascade of effects on the client.
-
Tool output truncation exists but may be insufficient:
outputTruncationdefaults to 2000 lines / 50 KB, but a single tool result at the maximum (50 KB ≈ 12,500 tokens) combined with a long conversation history can still exceed the context limit. The truncation also doesn't account for the cumulative token budget across all messages. -
Potential infinite recovery loop: If auto-compact succeeds but the subsequent resume prompt still triggers context overflow,
auto-compacting?has already been reset tofalse, allowing another compact cycle. There is no counter orrecovery-attempted?guard to preventCompact → Resume → Overflow → Compact → …loops (analogous to the existingauto-continued?guard for truncated responses).
Client-side (Emacs)
-
Synchronous JSON parsing of large messages: The process filter in
eca-process.elparses incoming JSON messages synchronously with no size limit. Before the overflow error, the server sendstoolCallednotifications containing the full tool output. Parsing a multi-MB JSON message blocks the Emacs main thread. -
font-lock-ensurerefontifies entire buffer: After each text content insertion (eca-chat.el),font-lock-ensureruns over the entire chat buffer. Ingfm-modewithmarkdown-fontify-code-blocks-natively, this becomes very expensive for large buffers. -
align-tables/beautify-tablesscan entire buffer: On"finished"status, both functions are called with(point-min), scanning the entire chat buffer for markdown tables — expensive for long conversations. -
Expandable content has no size limit: Tool call outputs are stored and rendered in expandable overlays without any truncation. Large outputs bloat the buffer.
These client-side issues compound: large tool output → expensive JSON parse → expensive rendering → expensive fontification → expensive table alignment, all running synchronously on the Emacs main thread.
Steps to Reproduce
- Start an ECA chat session with a model that has a moderate context window (e.g., 128K-168K tokens)
- Have a conversation long enough to consume a significant portion of the context
- Execute a tool/shell command that produces very large output (e.g.,
find / -name "*.log"or similar) - The LLM provider returns HTTP 400 (token limit exceeded)
- Emacs becomes unresponsive
- Ngôn ngữ chính
- Clojure
- Star
- 1k
- Fork
- 82
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 16
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của editor-code-assistant/eca
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
editor-code-assistant/eca#661 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
editor-code-assistant/eca#657 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
editor-code-assistant/eca#652 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
editor-code-assistant/eca#648 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
editor-code-assistant/eca#644 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của editor-code-assistant/eca
Issue tương tự
-
module:cql
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
.Needs Triage Priority:P3 Type:Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
metabase/metabase#84843 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NoahTheDuke/splint#57 · 1 bình luận ·
-
category:runtime
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
jank-lang/jank#1110 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
IOP MCP
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày