Fix error handling and edge cases across auth, keys, and agent systems#207
Merged
Conversation
Source fixes (each with a regression test):
- main: bare `assembly` with a corrupt config.toml printed a traceback —
`_offer_or_help` now skips the key probe/wizard when the config error was
deferred, so help renders cleanly.
- auth/flow: `find_or_create_cli_key` minted into projects[0]; now picks the
first entry that actually carries a project, so login no longer fails when an
earlier membership has a null project.
- code_gen/stream: generated `--llm` chain crashed on a null gateway message
content; emit `... .content or ""`.
- app/init_exec: derive the Voice Agent host from the authoritative
`Environment.agents_host` field instead of string-munging `streaming_host`.
- agent_cascade/text: `split_sentences` fragmented decimals/abbreviations
("$3.50"); a terminator now only ends a sentence at end-of-text or before
whitespace.
- init/devserver: the venv-interpreter swap matched only `python`; also match
`python3` so an edited Procfile still runs inside the project venv.
- commands/keys: `keys create` raised KeyError on a response missing api_key;
validate and raise a clean APIError instead.
- ui/update_check: gate the `/usr/local/` Homebrew heuristic to macOS (Linux
pip installs were told to run `brew upgrade`); use `removeprefix("v")`
instead of `lstrip("v")` for the release tag.
- agent/session: guard `base64.b64decode` so one corrupt audio frame is dropped
rather than tearing down the live session.
Moved the find_or_create_cli_key tests to tests/test_auth_flow_projects.py to
keep test_auth_flow.py under the 500-line gate.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0119PsP7ZmuXMsoMke7DBBd2
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.
This PR hardens error handling and fixes edge cases across multiple subsystems to prevent crashes and improve user experience.
Summary
Fixes malformed API responses, corrupt configuration handling, invalid base64 audio frames, and platform-specific upgrade detection. Also improves sentence splitting logic to preserve decimals and abbreviations, and corrects environment variable resolution for Voice Agents.
Key Changes
Auth & Keys
find_or_create_cli_keytests into a dedicated module to keeptest_auth_flow.pyunder the 500-line gatekeys createto reject API responses missing or with emptyapi_keyfield, surfacing cleanAPIErrorinstead ofKeyErrorfind_or_create_cli_keyto use the first project entry that actually has a project object (not just the first entry), handling accounts where the first membership lacks a projectConfiguration & Startup
config.tomlby checkingdeferred_config_errorbefore attempting to resolve credentials, preventing traceback when config is unparseableassemblycommand with corrupt configAgent Session
on_reply_audiowith try-except to gracefully drop corrupt audio frames instead of crashing the live conversation sessionText Processing
split_sentencesto only treat terminators (.,!,?) as sentence boundaries when they end the text or are followed by whitespace, preserving decimals ("$3.50") and abbreviations, and keeping stacked terminators ("...", "?!") intactEnvironment & Deployment
_active_env_varsto use the authoritativeagents_hostfield from the environment instead of deriving it via string replacement ofstreaming_hostdev_commandto swap bothpythonandpython3leading tokens for the venv interpreterdetect_upgrade_commandto only treat/usr/local/binas Homebrew on macOS (darwin), not on Linux where it's a conventional source/manual build prefixCode Generation
Testing
find_or_create_cli_keytests to newtest_auth_flow_projects.pymodulehttps://claude.ai/code/session_0119PsP7ZmuXMsoMke7DBBd2