ENG-9646: Reflex Init --agents#6620
Conversation
Greptile SummaryThis PR adds a
Confidence Score: 3/5The new --agents path has a real defect in its error handling that would produce an unhandled traceback on any network failure and would also break the bundled test verifying that behaviour. The exception handler in initialize_agents_md catches only httpx.HTTPError, which does not cover httpx.RequestError subclasses (ConnectError, TimeoutException, etc.). Any network-level failure escapes as an unhandled exception, and the accompanying test that exercises exactly this failure mode would itself fail for the same reason. The rest of the change is straightforward and follows existing patterns. reflex/utils/frontend_skeleton.py and tests/units/utils/test_utils.py need attention for the exception-handling gap. Important Files Changed
Reviews (1): Last reviewed commit: "change source" | Re-trigger Greptile |
| except httpx.HTTPError as e: | ||
| console.error(f"Failed to fetch AGENTS.md from {url} due to {e}.") | ||
| raise SystemExit(1) from None |
There was a problem hiding this comment.
httpx.HTTPError only covers HTTP-protocol-level errors (like HTTPStatusError for non-2xx responses). Network-level errors — httpx.ConnectError, httpx.TimeoutException, httpx.ReadTimeout, etc. — are subclasses of httpx.RequestError, which is not a subclass of httpx.HTTPError. If the GitHub raw URL is unreachable (DNS failure, timeout, firewall), the exception escapes unhandled and the user sees a raw traceback instead of the clean error message. The companion test test_initialize_agents_md_aborts_on_fetch_failure patches net.get to raise httpx.ConnectError and asserts SystemExit, but with the current catch clause that test will also fail at runtime because ConnectError is not caught.
| except httpx.HTTPError as e: | |
| console.error(f"Failed to fetch AGENTS.md from {url} due to {e}.") | |
| raise SystemExit(1) from None | |
| except (httpx.HTTPError, httpx.RequestError) as e: | |
| console.error(f"Failed to fetch AGENTS.md from {url} due to {e}.") | |
| raise SystemExit(1) from None |
Merging this PR will degrade performance by 3.37%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | test_from_event_type[lambda_event_spec] |
53.8 µs | 55.8 µs | -3.42% |
| ❌ | test_from_event_type[event_spec] |
51.9 µs | 53.7 µs | -3.31% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing aditya/init-agentsmd (9f89e0b) with main (31f785e)
Footnotes
-
8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
| - Use the [Reflex MCP server](/docs/ai-builder/integrations/mcp-overview) (`https://build.reflex.dev/mcp`) for live component/prop lookup so you don't hallucinate APIs. *(MCP access is an enterprise feature.)* | ||
| - Run `uv run reflex --version` and trust the live docs for that version over memory. | ||
|
|
||
| **Drop a rules file in the project root** (`AGENTS.md`, or `CLAUDE.md`/`.cursorrules` for your tool) so these conventions persist across your session — a starter is below. |
There was a problem hiding this comment.
did you test the efficacy of this line
| raise SystemExit(1) from None | ||
|
|
||
| console.debug(f"Creating {agents_file}") | ||
| agents_file.write_text(response.text) |
There was a problem hiding this comment.
we should have a starter marker and finish marker so one can add other things in AGENTS.md
| @click.option( | ||
| "--agents", | ||
| is_flag=True, | ||
| help="Write a sample AGENTS.md to guide AI coding agents working in the app.", | ||
| ) |
There was a problem hiding this comment.
i thought we wanted this be turned on by default?
All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
After these steps, you're ready to open a pull request.