Fix REPL y/N ^M input and hide LLM gateway URL in errors#459
Open
RMtz88 wants to merge 7 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/compactand other y/N REPL prompts that echoed^Mon Enter afterprompt_toolkitby restoring cooked TTY state and routing confirmations throughread_repl_yes_no(prompt_toolkit).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.pycai, execute/compact, confirmy+ Enter works without^MMade with Cursor