Stray "x" appears at the end of every prompt (leftover Claude Code 0.2.70 workaround) #223
Description
Summary
Every message sent through agentapi to Claude Code produces a visible stray x character in the prompt area. The x comes from a workaround introduced in b732081 almost a year ago, which the commit itself promised to remove "a couple of days after the new version is released."
Source of the bug
lib/httpapi/claude.go, in formatClaudeCodeMessage:
// janky hack: send a random character and then a backspace because otherwise
// Claude Code echoes the startSeq back to the terminal.
// This basically simulates a user typing and then removing the character.
parts = append(parts, st.MessagePartText{Content: \"x\b\", Hidden: true})The hack was a workaround for a bug in Claude Code 0.2.70 (anthropics/claude-code#803). With current Claude Code versions, the bracketed-paste start sequence is no longer echoed, so the masking x is rendered straight into the prompt area and the \b has nothing to erase — net result is a visible x on every message.
Environment
- agentapi v0.12.1 (latest release as of writing)
- claude-code 2.1.143
Notes
- PR fix(screentracker): make writeStabilize Phase 1 non-fatal when agents don't echo input #208 (merged 2026-04-10) touched this same file but only added a doc comment to
formatPaste; thex\bline was left in place. - Possibly related to Claude Code 2.1.83 breaks terminal capture #207 ("Claude Code 2.1.83 breaks terminal capture") — both look like consequences of Claude Code's rendering pipeline no longer behaving the way the 0.2.70-era workarounds assumed.
Proposed fix
Remove the parts = append(parts, st.MessagePartText{Content: \"x\b\", Hidden: true}) line. The original Claude Code bug it worked around is long fixed.
Activity