fix(cli): don't brick the chat REPL when the first turn fails upstream #110
Reference in New Issue
Block a user
Delete Branch "fix/chat-repl-thread-brick"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A failed first turn (e.g. anthropic 429 before the
finalframe) made streamOnce resolve '' as the thread id; the REPL stored it and every later message sentthreadId: "", which mcpd's z.string().min(1) rejects with HTTP 400 — permanently bricking the session, since no turn could succeed to repair the id.Fix, two independent layers:
string | undefined(undefined when nofinalframe arrived); the REPL keeps its previous thread state on undefined. One-shot mode skips the thread footer when there is none.7 regression tests in chat-thread-brick.test.ts, including the full REPL chain (failed turn 1 → turn 2 body has no threadId key). CLI suite 726 passed, lint + tsc clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_016dNpnBqyyz9GxfznVcX2sP