fix(schedules): make preview-session check importable in lean worker image#567
Merged
Merged
Conversation
…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]>
This was referenced Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 showsresult delivery failed → ModuleNotFoundError: No module named 'agents'.Root cause
The headless delivery path (
runner→ensure_session_metadata_exists,metadata.py:773) does callis_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 reportscompleted, but the idempotent session-row ensure + the schedule-label title override are silently skipped.Fix
is_preview_sessionis a trivialstartswith("preview-"); its weight came only from theagents/strandsimports inagents.main_agent.session.preview_session_manager. Move a dependency-free copy intoapis/shared/sessions/preview.py(exactly the patternapis.inference_api.chat.routesalready uses with its own local copy) and import it inmetadata.py. Drift-guard test keeps the literal in lockstep withPrefixes.PREVIEW_SESSION.Verification
metadataand runsis_preview_sessionwith no agents/strands present.🤖 Generated with Claude Code