The agent that turns websites into APIs!
fix(cli): distinguish task cancellation from user interruption
kalil0321d77dbdfce35e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex bc7783b..7c157d8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Click now requires version 8.3.3 or newer to fix [PYSEC-2026-2132](https://osv.dev/vulnerability/PYSEC-2026-2132). LiteLLM releases that pin `click==8.1.8` (including 1.83.7) cannot share an environment with this release. Use RAE's built-in pricing, run such LiteLLM releases in a separate environment, or select a LiteLLM release whose requirements allow the patched Click version. Optional LiteLLM pricing detection remains available only when its dependencies are compatible; do not downgrade Click to enable it.### Fixed-- Report agent provider runs that produce no result as failures: JSON/NDJSON emits an error result, and plain output prints the error to stderr; all exit with code 1. Preserve Claude/Cursor cancellation as `interrupted` in non-interactive mode. Interactive cancellation keeps exit code 0 and any completed partial result, including when a real Ctrl+C cancels an asyncio task, rather than reporting a provider failure.+- Report agent provider runs that produce no result as failures: JSON/NDJSON emits an error result, and plain output prints the error to stderr; all exit with code 1. Preserve Claude/Cursor Ctrl+C as `interrupted` in non-interactive mode. Interactive Ctrl+C keeps exit code 0 and any completed partial result, including when the signal cancels an asyncio task. Programmatic cancellations propagate to asyncio callers and produce a CLI failure with exit code 1, while preserving partial results.- Raise security minimums to Click >=8.3.3, aiohttp >=3.14.3, cryptography >=50.0.0, AnyIO >=4.14.2, PyJWT >=2.13.0, python-multipart >=0.0.30, Starlette >=1.3.1, and SoupSieve >=2.9.0 (collector extra). Export these floors in package metadata so upgrades cannot retain vulnerable versions that only the repository lockfile excluded.- Refresh the locked Claude Agent SDK and MCP dependencies so the development environment also uses MCP 2.x and `httpx2`, without the legacy `httpx`, `httpx-sse`, and `httpcore` packages. Add subprocess smoke tests for CLI startup with legacy HTTP client imports blocked.diff --git a/src/reverse_api/auto_engineer.py b/src/reverse_api/auto_engineer.pyindex 5f45469..11a1468 100644--- a/src/reverse_api/auto_engineer.py+++ b/src/reverse_api/auto_engineer.py@@ -278,7 +278,12 @@ class ClaudeAutoEngineer(ClaudeEngineer):# follow-up loop instead of offering another turn.return last_result- except (KeyboardInterrupt, asyncio.CancelledError):+ except asyncio.CancelledError as exc:+ # Keep cancellation semantics for asyncio callers while retaining+ # the partial result for the CLI, including SIGINT via Runner.+ exc.partial_result = last_result # type: ignore[attr-defined]+ raise+ except KeyboardInterrupt:self.ui.console.print("\n [dim]run aborted[/dim]")if not self.interactive:raisediff --git a/src/reverse_api/cli.py b/src/reverse_api/cli.pyindex 252af52..3c96848 100644--- a/src/reverse_api/cli.py+++ b/src/reverse_api/cli.py@@ -2186,12 +2186,17 @@ def run_auto_capture(engineer.start_sync()interrupted = False+ cancelled = Falsetry:result = asyncio.run(engineer.analyze_and_generate())interrupted = isinstance(result, dict) and result.get("error") == "interrupted"- except (KeyboardInterrupt, asyncio.CancelledError):- result = None+ except KeyboardInterrupt as exc:+ result = getattr(exc.__context__, "partial_result", None)interrupted = True+ console.print("\n [dim]run aborted[/dim]")+ except asyncio.CancelledError as exc:+ result = getattr(exc, "partial_result", None)+ cancelled = Truefinally:# Always stop sync when doneengineer.stop_sync()@@ -2212,6 +2217,8 @@ def run_auto_capture(**({"error": "interrupted"}if interrupted+ else {"error": "Agent analysis cancelled."}+ if cancelledelse {"error": "Agent analysis produced no result."}if result is Noneelse {}diff --git a/src/reverse_api/cursor_engineer.py b/src/reverse_api/cursor_engineer.pyindex 4634066..a381d5a 100644--- a/src/reverse_api/cursor_engineer.py+++ b/src/reverse_api/cursor_engineer.py@@ -606,7 +606,12 @@ class CursorAutoEngineer(CursorEngineer):return last_resultturn_prompt = fuself.message_store.save_prompt(turn_prompt)- except (KeyboardInterrupt, asyncio.CancelledError):+ except asyncio.CancelledError as exc:+ # Keep cancellation semantics for asyncio callers while retaining+ # the partial result for the CLI, including SIGINT via Runner.+ exc.partial_result = last_result # type: ignore[attr-defined]+ raise+ except KeyboardInterrupt:self.ui.console.print("\n [dim]run aborted[/dim]")if not self.interactive:raisediff --git a/tests/test_cli_agent_json.py b/tests/test_cli_agent_json.pyindex 8a8e31f..58ddfb8 100644--- a/tests/test_cli_agent_json.py+++ b/tests/test_cli_agent_json.py@@ -595,7 +595,15 @@ def test_provider_interrupt_output_modes(tmp_path, monkeypatch, sdk, output_flagif output_flag:args.append(output_flag)result = CliRunner().invoke(main, args)- if output_flag is None:+ if interrupt_type is asyncio.CancelledError:+ assert result.exit_code == 1, result.output+ if output_flag in ("--json", "--json-stream"):+ payload = json.loads(result.stdout.strip().splitlines()[-1])+ assert payload["status"] == "error"+ assert payload["error"] == "Agent analysis cancelled."+ else:+ assert "Agent analysis cancelled." in result.stderr+ elif output_flag is None:assert result.exit_code == 0, result.outputassert "run aborted" in result.outputassert "produced no result" not in result.output