Self-heal CLI invocation and version probing#41
Merged
zachyzissou merged 1 commit intomainfrom Feb 25, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves resiliency and reduces log noise around invoking toonamiaftermath-cli by adapting invocation strategy and version probing based on detected/remembered compatibility, with integration tests to validate the new behavior.
Changes:
- Add adaptive CLI invocation ordering that prefers the most compatible mode and caches the last successful mode in runtime/persisted state.
- Probe for
runsubcommand support and use that signal to reorder invocation attempts. - Make CLI version detection try
versionfirst then--version, caching the working probe mode, with new integration tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/server.py | Adds CLI invocation/version probe mode catalogs, caching, probing, and updated generation/version logic. |
| test_integration.py | Adds integration tests for adaptive attempt ordering and cached version-probe mode behavior. |
Comments suppressed due to low confidence (1)
app/server.py:1014
- In get_cli_version(), a probe that exits 0 but produces empty/whitespace output returns None immediately and never tries the other probe mode. This can incorrectly miss a version string if one mode is silent (or only emits whitespace) while the other prints the version. Consider treating empty output as a failed probe and continuing to the next mode, and prefer a non-empty value after stripping (e.g., check stdout.strip() first, then stderr.strip()).
if return_code == 0:
output = (stdout or stderr).strip()
if output:
app.state.cli_version_mode = mode
first_line = output.splitlines()[0].strip()
return first_line if first_line else output
app.state.cli_version_mode = mode
return None
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
runsubcommand and reorder attempts accordinglyversionfirst, then falling back to--version, and caching the working modeWhy
Recent logs showed recurring noise from known-incompatible command forms (
-mon root command and--versionon Cobra-based builds). This change keeps errors visible when truly unexpected, but stops repeatedly retrying known-bad forms once a working path is learned.Validation
python3 -m compileall app/server.py test_integration.pyuvx ruff check app/server.py test_integration.pyuvx black --check app/server.py test_integration.pyuv run --no-project --python 3.11 --with-requirements requirements.txt python test_integration.py