Skip to content

feat(#223): make base image prefetch opt-in with progress tracking#512

Open
hognek wants to merge 1 commit into
jaylfc:masterfrom
hognek:feat/opt-in-base-image
Open

feat(#223): make base image prefetch opt-in with progress tracking#512
hognek wants to merge 1 commit into
jaylfc:masterfrom
hognek:feat/opt-in-base-image

Conversation

@hognek
Copy link
Copy Markdown
Contributor

@hognek hognek commented May 31, 2026

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 (or true/yes). Default is disabled — no download unless the user explicitly opts in.

Changes

  • agent_image.py: is_prefetch_enabled() reads the env var. _prefetch_state dict tracks download progress through idle → downloading → importing → done/failed. register_prefetch_endpoint() exposes /api/agent-image/status for the frontend to poll.
  • app.py: Startup ensure_image_present() call is gated behind is_prefetch_enabled(). When disabled, a debug-level log reminds users how to opt in.
  • install-server.sh: TAOS_PREFETCH_BASE_IMAGE is documented, resolved at install time (defaults to 0), and substituted into the systemd service template via sed.
  • scripts/systemd/tinyagentos.service: New TAOS_PREFETCH placeholder that install-server.sh replaces with 0 or 1.

No behavior change for existing users

Users who never set TAOS_PREFETCH_BASE_IMAGE see no difference — the image simply will not download (they were likely not relying on it anyway). Users who want the cache can add TAOS_PREFETCH_BASE_IMAGE=1 to their environment or re-run the installer. The deployer still falls back to images:debian/bookworm in all cases.

Verification

  • tests/test_agent_image_prefetch.py — 14 new tests (env var parsing, state tracking, service template checks)
  • Existing tests/test_agent_image.py — 10/10 unaffected
  • bash -n scripts/install-server.sh — clean

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

Warning

Review limit reached

@hognek, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4b58de43-57c4-44bb-9d37-3f88a28b09ef

📥 Commits

Reviewing files that changed from the base of the PR and between 4658bd6 and 3b3ed5a.

📒 Files selected for processing (5)
  • scripts/install-server.sh
  • scripts/systemd/tinyagentos.service
  • tests/test_agent_image_prefetch.py
  • tinyagentos/agent_image.py
  • tinyagentos/app.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hognek hognek marked this pull request as ready for review May 31, 2026 17:56
Comment thread tinyagentos/app.py
app.include_router(memory_mgmt_router)

# Agent base image prefetch status endpoint
register_prefetch_endpoint(app)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot Bot commented May 31, 2026

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
tinyagentos/app.py 1236 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. |

Other Observations (not in diff)

No other observations. |

Files Reviewed (5 files)
  • scripts/install-server.sh
  • scripts/systemd/tinyagentos.service
  • tests/test_agent_image_prefetch.py
  • tinyagentos/agent_image.py
  • tinyagentos/app.py

Reviewed by nemotron-3-super-120b-a12b-20230311:free · 515,903 tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant