Skip to content

fix(schedules): make preview-session check importable in lean worker image#567

Merged
philmerrell merged 1 commit into
developfrom
fix/scheduled-runs-preview-session-leaf
Jul 6, 2026
Merged

fix(schedules): make preview-session check importable in lean worker image#567
philmerrell merged 1 commit into
developfrom
fix/scheduled-runs-preview-session-leaf

Conversation

@philmerrell

Copy link
Copy Markdown
Contributor

What

Follow-up to #566. Dogfooding the deployed worker surfaced a second, deferred failure. The scheduled run now reaches the runtime and completes (run … completed (session headless-…)), but the worker log shows result delivery failed → ModuleNotFoundError: No module named 'agents'.

Root cause

The headless delivery path (runnerensure_session_metadata_exists, metadata.py:773) does call is_preview_session. #566's lazy-import wrapper only moved the crash from INIT to run time — the two functions I thought didn't call it, do (my earlier awk range check was a false negative). The runtime materializes the session during the turn, so the run still reports completed, but the idempotent session-row ensure + the schedule-label title override are silently skipped.

Fix

is_preview_session is a trivial startswith("preview-"); its weight came only from the agents/strands imports in agents.main_agent.session.preview_session_manager. Move a dependency-free copy into apis/shared/sessions/preview.py (exactly the pattern apis.inference_api.chat.routes already uses with its own local copy) and import it in metadata.py. Drift-guard test keeps the literal in lockstep with Prefixes.PREVIEW_SESSION.

Verification

  • Lean-image simulation now imports metadata and runs is_preview_session with no agents/strands present.
  • 77 targeted tests pass (drift guard, sessions_metadata, worker, import boundaries).

🤖 Generated with Claude Code

…image

Follow-up to the worker-image import fix (#566). Dogfooding the deployed
worker surfaced a second, deferred failure: the headless delivery path
(runner -> ensure_session_metadata_exists, metadata.py:773) DOES call
is_preview_session, so the previous lazy-import wrapper only moved the
ModuleNotFoundError: No module named 'agents' from INIT to run time. The
run still 'completed' (the runtime materializes the session during the
turn), but the idempotent session-row ensure + title override were
skipped ('result delivery failed' in the worker log).

is_preview_session is a trivial startswith('preview-') check; its weight
came only from agents/strands imports in
agents.main_agent.session.preview_session_manager. Move a dependency-free
copy into apis.shared.sessions.preview (mirroring what
apis.inference_api.chat.routes already does with its own local copy) and
import it in metadata.py. A drift-guard test keeps the literal in lockstep
with agents...Prefixes.PREVIEW_SESSION.

Verified: lean-image simulation now imports metadata + runs
is_preview_session with no agents/strands; 77 targeted tests pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@philmerrell philmerrell merged commit 9f0afeb into develop Jul 6, 2026
4 checks passed
@philmerrell philmerrell deleted the fix/scheduled-runs-preview-session-leaf branch July 6, 2026 06:14
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