fix: summary tag handling, TUI autocomplete focus, tool output flooding

1. Summary tags: Reverse the logic — for models like gpt-4.1 that wrap
   their actual response in <summary> tags (with thinking/CoT before it),
   extract the inner content instead of stripping it. Streaming uses a
   preflight buffer that waits for <summary>; if none appears, flushes
   everything normally.

2. TUI autocomplete: Change @mention accept key from Tab to right-arrow
   so autocomplete doesn't steal focus from the input widget. Only
   triggers when there's an active mention context with matches.

3. Tool output: Truncate tool results >4000 chars in LLM message history
   to prevent the model from echoing full file contents. Add soul-layer
   instruction telling the agent to summarize tool results rather than
   repeating them verbatim.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Joao Moura
2026-05-14 16:17:44 -04:00
parent 3eb1da2d9c
commit 126d0010ba
2 changed files with 97 additions and 34 deletions

View File

@@ -71,7 +71,7 @@ except ImportError:
class ChatTextArea(TextArea):
"""Multiline chat input: Enter submits, Shift+Enter inserts newline, Tab completes @mentions."""
"""Multiline chat input: Enter submits, Shift+Enter inserts newline, Right-arrow completes @mentions."""
BINDINGS = [
Binding("enter", "submit", "Send", show=False),
@@ -161,10 +161,14 @@ class ChatTextArea(TextArea):
event.prevent_default()
self.action_submit()
return
if event.key == "tab":
event.prevent_default()
self.action_complete()
return
if event.key == "right":
ctx = self._get_mention_context()
if ctx is not None:
_, _, prefix = ctx
if self._get_matches(prefix):
event.prevent_default()
self.action_complete()
return
if event.key == "escape":
self._last_mention_prefix = None
self.post_message(self.MentionChanged("", []))
@@ -834,7 +838,7 @@ class AgentTUI(App[None]):
hint.display = False
return
names = " ".join(f"@{n}" for n in event.matches[:6])
hint.update(f"Tab to complete: {names}")
hint.update(f" to complete: {names}")
hint.display = True
# ── Message routing ──