Skip to content

Self-heal CLI invocation and version probing#41

Merged
zachyzissou merged 1 commit intomainfrom
codex/self-heal-cli-invocation
Feb 25, 2026
Merged

Self-heal CLI invocation and version probing#41
zachyzissou merged 1 commit intomainfrom
codex/self-heal-cli-invocation

Conversation

@zachyzissou
Copy link
Owner

@zachyzissou zachyzissou commented Feb 25, 2026

Summary

  • add adaptive CLI invocation ordering that learns the last successful mode
  • probe whether the CLI supports the run subcommand and reorder attempts accordingly
  • make CLI version detection resilient by trying version first, then falling back to --version, and caching the working mode
  • add integration tests for adaptive attempt ordering and version mode caching

Why

Recent logs showed recurring noise from known-incompatible command forms (-m on root command and --version on 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.py
  • uvx ruff check app/server.py test_integration.py
  • uvx black --check app/server.py test_integration.py
  • uv run --no-project --python 3.11 --with-requirements requirements.txt python test_integration.py

Copilot AI review requested due to automatic review settings February 25, 2026 19:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 run subcommand support and use that signal to reorder invocation attempts.
  • Make CLI version detection try version first 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.

@zachyzissou zachyzissou merged commit e579ca2 into main Feb 25, 2026
17 checks passed
@zachyzissou zachyzissou deleted the codex/self-heal-cli-invocation branch February 25, 2026 19:30
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.

2 participants