Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

switched to start truncation from end truncation

Alishahryar107b0c9233e9d
diff --git a/messaging/handler.py b/messaging/handler.py
index 7ac54d83..3bd7908e 100644
--- a/messaging/handler.py
+++ b/messaging/handler.py
@@ -384,7 +384,7 @@ class ClaudeMessageHandler:
thinking_text = "".join(components["thinking"])
# Truncate thinking if too long, it's usually less critical than final content
if len(thinking_text) > 1000:
- thinking_text = thinking_text[:995] + "..."
+ thinking_text = "..." + thinking_text[-995:]
# Ensure it doesn't break a code block if we eventually support them inside thinking
lines.append(f"💭 **Thinking:**\n```\n{thinking_text}\n```")
@@ -435,13 +435,16 @@ class ClaudeMessageHandler:
else "⏳ **Claude is working...**"
)
- # If too long, truncate the main content but keep the status and close code blocks
+ # If too long, truncate the start of the content (keep the end)
available_limit = LIMIT - len(status_text) - 20 # 20 for truncation marker
- truncated_main = main_text[:available_limit].rstrip() + "\n... (truncated)"
+ raw_truncated = main_text[-available_limit:].lstrip()
- # Close any open code blocks
- if truncated_main.count("```") % 2 != 0:
- truncated_main += "\n```"
+ # Check for unbalanced code blocks
+ prefix = "... (truncated)\n"
+ if raw_truncated.count("```") % 2 != 0:
+ prefix += "```\n"
+
+ truncated_main = prefix + raw_truncated
return truncated_main + status_text