Skip to content

Fix REPL y/N ^M input and hide LLM gateway URL in errors#459

Open
RMtz88 wants to merge 7 commits into
aliasrobotics:mainfrom
RMtz88:fix/repl-console-input-and-llm-errors
Open

Fix REPL y/N ^M input and hide LLM gateway URL in errors#459
RMtz88 wants to merge 7 commits into
aliasrobotics:mainfrom
RMtz88:fix/repl-console-input-and-llm-errors

Conversation

@RMtz88

@RMtz88 RMtz88 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix /compact and other y/N REPL prompts that echoed ^M on Enter after prompt_toolkit by restoring cooked TTY state and routing confirmations through read_repl_yes_no (prompt_toolkit).
  • Replace gateway URLs in user-facing LLM retry/503 error messages with the branded label Alias Robotics® LLM servers (URLs remain in debug logs only).

Test plan

  • pytest tests/repl/test_multiline_prompt.py tests/repl/test_tty_input.py tests/sdk/test_httpx_client_errors.py tests/test_compact_command.py
  • Manual: run cai, execute /compact, confirm y + Enter works without ^M
  • Manual: trigger a 503/429 and confirm no gateway URL appears in the console error line

Made with Cursor

Rufino Cabrera and others added 7 commits June 11, 2026 12:30
Restore cooked TTY state after prompt_toolkit exits so Rich console.input
and other follow-up prompts (e.g. /compact confirmation) accept Enter normally.
Force cooked canonical TTY mode after prompt_toolkit and route /compact
confirmation through read_repl_yes_no, which restores the terminal and
strips stray carriage returns from the answer.
Rich console.input still echoed ^M after prompt_toolkit even with cooked
TTY restore. Route compact confirmation through prompt_toolkit like the
main CAI> prompt and other interactive agent flows.
Replace endpoint URLs in httpx retry exhaustion errors with the branded
Alias Robotics® LLM servers label; URLs remain in debug logs only.
A streaming tool call cut off after the opening brace would leave
state.function_calls[i].arguments = "{". CAI persisted that into
conversation history verbatim, and on the next turn the upstream
litellm proxy strict-parsed it as JSON and rejected the whole
request with HTTP 400 ("unexpected end of data: line 1 column 2"),
wedging the session.

- openai_chatcompletions.py: at end-of-stream, validate every
  accumulated function_call.arguments string. If empty or not
  valid JSON, normalize to "{}" before emitting events.
- message_builder.py: same guard when replaying assistant tool_calls
  out of memory, so a poisoned history loaded from disk also recovers.
The previous repair pass rewrote any non-parseable arguments string to
"{}", which clobbered legitimate accumulator contents in
test_stream_response_yields_events_for_tool_call (concatenated raw
deltas like "arg1arg2"). Narrow the guard: only when the stripped
buffer starts with "{" or "[" *and* fails to parse do we replace it
with "{}". Everything else is left untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant