feat(#223): make base image prefetch opt-in with progress tracking#512
feat(#223): make base image prefetch opt-in with progress tracking#512hognek wants to merge 1 commit into
Conversation
Make the pre-built agent base image download opt-in behind TAOS_PREFETCH_BASE_IMAGE=1. Default is disabled — no ~300-500MB download unless the user explicitly opts in. Changes: - agent_image.py: is_prefetch_enabled() checks env var (1/true/yes) - agent_image.py: _prefetch_state dict tracks download progress (idle→downloading→importing→done/failed) - agent_image.py: register_prefetch_endpoint() exposes /api/agent-image/status for frontend polling - app.py: startup call gated behind is_prefetch_enabled() - install-server.sh: TAOS_PREFETCH_BASE_IMAGE env var wired into systemd service template (both system and user modes) - systemd service template: TAOS_PREFETCH placeholder for sed 14 new tests: env var parsing, state tracking, service template verification. Existing agent_image tests unaffected.
|
Warning Review limit reached
More reviews will be available in 2 minutes and 31 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| app.include_router(memory_mgmt_router) | ||
|
|
||
| # Agent base image prefetch status endpoint | ||
| register_prefetch_endpoint(app) |
There was a problem hiding this comment.
WARNING: Registering the prefetch endpoint multiple times may lead to duplicate routes.
The function _reload_llm_proxy_on_catalog_change is called whenever the backend catalog changes, which may happen multiple times during the application lifecycle. Calling register_prefetch_endpoint(app) each time could result in the same route being registered multiple times, which may cause undefined behavior in FastAPI.
Consider moving the registration to a one-time startup event or adding a guard to prevent multiple registrations.
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
The function Consider moving the registration to a one-time startup event or adding a guard to prevent multiple registrations. | Other Observations (not in diff)No other observations. | Files Reviewed (5 files)
Reviewed by nemotron-3-super-120b-a12b-20230311:free · 515,903 tokens |
Problem
The controller currently downloads a ~300-500MB pre-built agent base image at every startup — even for users who never deploy agents or prefer the per-deploy build path. This wastes bandwidth and disk I/O on every boot.
Fix
Make the base image prefetch opt-in behind
TAOS_PREFETCH_BASE_IMAGE=1(ortrue/yes). Default is disabled — no download unless the user explicitly opts in.Changes
is_prefetch_enabled()reads the env var._prefetch_statedict tracks download progress throughidle → downloading → importing → done/failed.register_prefetch_endpoint()exposes/api/agent-image/statusfor the frontend to poll.ensure_image_present()call is gated behindis_prefetch_enabled(). When disabled, a debug-level log reminds users how to opt in.TAOS_PREFETCH_BASE_IMAGEis documented, resolved at install time (defaults to 0), and substituted into the systemd service template via sed.TAOS_PREFETCHplaceholder that install-server.sh replaces with 0 or 1.No behavior change for existing users
Users who never set
TAOS_PREFETCH_BASE_IMAGEsee no difference — the image simply will not download (they were likely not relying on it anyway). Users who want the cache can addTAOS_PREFETCH_BASE_IMAGE=1to their environment or re-run the installer. The deployer still falls back toimages:debian/bookwormin all cases.Verification
tests/test_agent_image_prefetch.py— 14 new tests (env var parsing, state tracking, service template checks)tests/test_agent_image.py— 10/10 unaffectedbash -n scripts/install-server.sh— clean