mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
spawn_agent ran the full _prepare_agent_spawn (writes blueprint/settings/ briefing/MCP files, ensures the image, registers a STARTING instance) every dispatcher tick only to bail at the after-prepare parked-provider check — wasting all that file I/O while the provider stayed parked and leaving a STARTING instance registered then downgraded to OFFLINE. Move the parked check before _prepare_agent_spawn: resolve the route cheaply via _resolve_agent_route (only provider_type is needed) and bail with a minimal unregistered OFFLINE instance. The existing-running check stays first (inside the lock) so a live agent is never replaced; a TOCTOU re-check guards the unlocked window before prepare; the after-prepare check is kept as a rare-race defense (a park landing during prepare).