Replies: 5 comments 7 replies
-
|
I tested "start the astro dev server" in OpenCode and in Claude Code. In OpenCode it did as you said, started it up and timed out eventually. With Claude Code it started it in the background, and there's a little feature to bring it up and see the running dev server. With OpenCode it would start it in the background if you tell it to, but in this case it can't see the logs. You can again tell it to start in the background and pipe the logs to a file so it can read it there. So this seems to be a missing feature of OpenCode. Ok to add a feature to Astro to workaround limitations of tools, I think. But should do it carefully. For example, with Claude Code if you kill the process then the child process of astro is also killed. I would guess that with Maybe this means we need custom instructions depending on the agent. |
Beta Was this translation helpful? Give feedback.
-
Just to clarify it reduced time spent working with Another underrated point is that if the agent is struggling to deal with server management, I've found it can get frustated or confused and lose focus trying to fix the issue in increasingly desperate/extreme ways. You can see a bit ofthat in the report below for the control (no bgproc) case. Click to expand details# bgproc Impact on CI Triage RunsCompared two CI triage runs on the same issue — one before bgproc, one after.
Time spent on server management
81% reduction in server management time. Most of the savings came from eliminating the debugging spiral — in the old run, Token wasteThe old run spent ~13 tool calls on wasted server debugging (failed starts, Reliability
Caveats
|
Beta Was this translation helpful? Give feedback.
-
|
@ascorbic @ematipico @florian-lefebvre Requesting that this be moved to stage 2. |
Beta Was this translation helpful? Give feedback.
-
|
Why is |
Beta Was this translation helpful? Give feedback.
-
|
Now in stage 2, thanks everyone. #1358 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
Summary
Add built-in background process management to
astro dev, enabling AI coding agents to reliably start, monitor, query and stop the dev server.Background & Motivation
AI coding agents are increasingly the primary interface developers use to build Astro sites. These agents need to interact with the dev server constantly: starting it, checking if edits succeeded, reading errors and stopping it when done.
Today, this is painful. The dev server is designed for humans watching a terminal. Agents struggle with:
curl, sleeping for arbitrary durations, or parsing ANSI-coloured output for strings like "Local:".My
bgprocproject demonstrates that a thin process management layer with JSON output dramatically improves the agent experience with dev servers. Experiments by @FredKSchott demonstrated that bgproc reduced the time takes by an agent to triage an issue usingastro devby 81%, saved 13 tool calls and thousands of tokens. However, as a generic external wrapper, tools like bgproc are less discoverable and cannot provide framework-specific signals like HMR status, typed error codes or build state, and it relies upon heuristics to find ports that have been opened. Building this capability directly into Astro unlocks a significantly better experience.Goals
astro devexperience.Non-Goals
Example
Starting the dev server (background, agent workflow)
If the dev server is already running for this project, this is a no-op that returns the existing instance's details:
$ astro dev --background {"pid": 12345, "url": "http://localhost:4321", "networkUrl": "http://192.168.1.5:4321", "existing": true}Force restart with
--force:If the server fails to start within the timeout (default 30s):
$ astro dev --background {"error": "timeout", "message": "Dev server failed to start within 30s", "logs": "..."} # Exit code 1. Process is killed. No zombie left behind.Checking status
$ astro dev status {"running": true, "pid": 12345, "url": "http://localhost:4321", "uptime": 3600, "errors": [], "lastHmrEvent": {"type": "update", "file": "src/pages/index.astro", "at": "2026-02-18T10:23:01Z", "duration": 42}}When nothing is running:
$ astro dev status {"running": false} # Exit code 0 — "not running" is information, not an error.When the process has died:
$ astro dev status {"running": false, "lastExit": {"code": 1, "signal": null, "at": "2026-02-18T10:20:00Z"}} # Stale state is cleaned up automatically.Reading logs
Stopping the server
$ astro dev stop {"stopped": true, "pid": 12345}Idempotent — stopping when not running succeeds:
$ astro dev stop {"stopped": false, "reason": "not_running"} # Exit code 0.Health endpoint
All running dev server instances (foreground and background) expose a status endpoint:
$ curl -s http://localhost:4321/_astro/status {"ok": true, "errors": [], "lastHmrUpdate": {"file": "src/pages/index.astro", "at": "...", "duration": 42}, "routes": ["/", "/about", "/blog/[...slug]"]}This is the primary mechanism for agents to query a foreground dev server from another shell session.
astro dev statususes this endpoint when the server is running but was started in foreground mode.Beta Was this translation helpful? Give feedback.
All reactions