The agent that turns websites into APIs!
fix(cli): preserve results when SIGINT cancels async providers
kalil032157c488b36ad8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fa50c3e..bc7783b 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, 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 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.- 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 5303bad..5f45469 100644--- a/src/reverse_api/auto_engineer.py+++ b/src/reverse_api/auto_engineer.py@@ -278,7 +278,7 @@ class ClaudeAutoEngineer(ClaudeEngineer):# follow-up loop instead of offering another turn.return last_result- except KeyboardInterrupt:+ except (KeyboardInterrupt, asyncio.CancelledError):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 78ba657..252af52 100644--- a/src/reverse_api/cli.py+++ b/src/reverse_api/cli.py@@ -2189,7 +2189,7 @@ def run_auto_capture(try:result = asyncio.run(engineer.analyze_and_generate())interrupted = isinstance(result, dict) and result.get("error") == "interrupted"- except KeyboardInterrupt:+ except (KeyboardInterrupt, asyncio.CancelledError):result = Noneinterrupted = Truefinally:diff --git a/src/reverse_api/cursor_engineer.py b/src/reverse_api/cursor_engineer.pyindex 843047b..4634066 100644--- a/src/reverse_api/cursor_engineer.py+++ b/src/reverse_api/cursor_engineer.py@@ -606,7 +606,7 @@ class CursorAutoEngineer(CursorEngineer):return last_resultturn_prompt = fuself.message_store.save_prompt(turn_prompt)- except KeyboardInterrupt:+ except (KeyboardInterrupt, asyncio.CancelledError):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 919d84d..9f1c4a7 100644--- a/tests/test_cli_agent_json.py+++ b/tests/test_cli_agent_json.py@@ -1,5 +1,6 @@"""Tests for the agent-friendly CLI surface (--json, --no-interactive, payload shape)."""+import asyncioimport jsonfrom unittest.mock import MagicMock, patch@@ -546,11 +547,12 @@ def test_provider_failure_is_not_reported_as_success(tmp_path, output_flag):@pytest.mark.parametrize("sdk", ["claude", "cursor"])[email protected]("interrupt_type", [KeyboardInterrupt, asyncio.CancelledError])@pytest.mark.parametrize("output_flag,after_result",[("--json", False), ("--json-stream", False), ("--no-interactive", False), (None, False), (None, True)],)-def test_provider_interrupt_output_modes(tmp_path, monkeypatch, sdk, output_flag, after_result):+def test_provider_interrupt_output_modes(tmp_path, monkeypatch, sdk, output_flag, after_result, interrupt_type):from contextlib import ExitStackfrom unittest.mock import AsyncMock@@ -574,20 +576,20 @@ def test_provider_interrupt_output_modes(tmp_path, monkeypatch, sdk, output_flag))stack.enter_context(patch("reverse_api.auto_engineer.ClaudeAutoEngineer._prompt_follow_up",- new=AsyncMock(side_effect=KeyboardInterrupt),+ new=AsyncMock(side_effect=interrupt_type),))else:- client.return_value.__aenter__ = AsyncMock(side_effect=KeyboardInterrupt)+ client.return_value.__aenter__ = AsyncMock(side_effect=interrupt_type)else:stack.enter_context(patch("reverse_api.cursor_engineer._ensure_cursor_bridge_deps", return_value=None))if after_result:stack.enter_context(patch("reverse_api.cursor_engineer.CursorAutoEngineer._one_turn", new=AsyncMock(return_value={})))stack.enter_context(patch("reverse_api.cursor_engineer.CursorAutoEngineer._prompt_follow_up",- new=AsyncMock(side_effect=KeyboardInterrupt),+ new=AsyncMock(side_effect=interrupt_type),))else:- stack.enter_context(patch("reverse_api.cursor_engineer.CursorAutoEngineer._one_turn", new=AsyncMock(side_effect=KeyboardInterrupt)))+ stack.enter_context(patch("reverse_api.cursor_engineer.CursorAutoEngineer._one_turn", new=AsyncMock(side_effect=interrupt_type)))args = ["agent", "-p", "test interruption", "--headless", "-o", str(tmp_path)]if output_flag:args.append(output_flag)@@ -605,3 +607,7 @@ def test_provider_interrupt_output_modes(tmp_path, monkeypatch, sdk, output_flagassert payload["status"] == "error"assert payload["error_kind"] == "interrupted"assert payload["error"] == "interrupted"++ if after_result:+ history = json.loads((tmp_path / "history.json").read_text())+ assert history[-1]["paths"]["script_path"]