feat(evolution): cached-digest provider pre-flight for cron stages, model-resolution fix (#486)#490
Merged
Conversation
…odel-resolution fix (#486) Restore the evolution cached-digest pre-flight as a tracked feature and fix the root bug that made it fail on prod with 'no model configured for pre-flight ping'. What: - cron/evolution_preflight.py: lightweight non-streaming provider ping plus most-recent on-disk digest fallback for evolution pipeline cron stages (introspection/analysis/implementation/research/funnel/integration). - cron/scheduler.py: integrate the pre-flight between runtime resolution and AIAgent construction. On ping failure, return the latest stale digest (graceful degradation) or raise if none exists. Purely additive — the #487 native model-resolution path is unchanged. Why: - When the configured provider is unreachable (e.g. Kimi timeout storms), evolution sessions burn retries/timeouts and deliver nothing. The pre-flight detects this fast and falls back to the last good digest so the pipeline keeps moving with stale-but-structured input instead of failing silently. ROOT-FIX: - preflight_provider() reads runtime['model'], but resolve_runtime_provider() never populates it — the scheduler resolves the model into a separate local 'model' variable (job.model > HERMES_MODEL > config.yaml model.default) and passes it to AIAgent(model=...) directly. On prod runtime['model'] was empty so the ping always returned 'no model configured' and the cached-digest fallback could never trigger. Fixed by syncing runtime['model'] = model (the already-resolved local) before the ping, without clobbering an ACP-resolved model. Provenance: - This feature previously existed only as untracked local code on the prod host; git stash -u hid it and upstream-merge #487 overwrote scheduler.py with the native version. Now restored into git from that stash, with the root bug fixed. Tested: - tests/cron/test_evolution_preflight.py (27 tests) pass, including a new unit test and a scheduler-level test that reproduces the prod failure (runtime returned with NO model + empty job.model + config.yaml model.default) and asserts runtime['model'] is synced to the resolved default. Verified the new test FAILS without the root-fix (captured model == None) and PASSES with it. - Adjacent suites green: test_scheduler_provider.py (29), scheduler model/runtime/run_job slice (77), test_run_one_job.py + codex paths (8).
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
3 |
invalid-assignment |
1 |
First entries
cron/evolution_preflight.py:231: [unresolved-import] unresolved-import: Cannot resolve imported module `anthropic`
tests/cron/test_evolution_preflight.py:7: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`
cron/evolution_preflight.py:204: [unresolved-import] unresolved-import: Cannot resolve imported module `openai`
✅ Fixed issues (2):
| Rule | Count |
|---|---|
unresolved-attribute |
2 |
First entries
run_agent.py:3221: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
Unchanged: 6028 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
…486) CI test shard 5 lacks the optional 'anthropic' package, so test_anthropic_success / test_anthropic_failure failed with ModuleNotFoundError instead of being skipped. Add a per-test pytest.importorskip('anthropic') guard so they SKIP when the optional dependency is missing. Applied per-test (not class-level) because the other TestPreflightProvider cases (openai, missing_api_key, missing_model, acp, root-fix unit) do not touch anthropic and must keep running.
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
Restores the evolution cached-digest provider pre-flight as a tracked, tested feature and fixes the root bug that made it fail on production with
no model configured for pre-flight ping.cron/evolution_preflight.py(new): a lightweight, non-streaming provider ping (max_tokens=1) plus a most-recent on-disk digest fallback for evolution pipeline cron stages (introspection/analysis/implementation/research/funnel/integration). Pre-flight is enabled by default and configurable viacron.preflight_enabled/cron.preflight_timeout_seconds.cron/scheduler.py: integrates the pre-flight in_run_job_impl, between runtime resolution andAIAgentconstruction. On ping failure it returns the latest stale digest as a graceful-degradation success, or raises if no digest exists. Purely additive — the sync: merge upstream/main (286 commits) — 2026-06-23 #487 native model-resolution path (job.model > HERMES_MODEL > config.yamlmodel.default) is untouched, and non-evolution jobs (stage is None) skip the block entirely.tests/cron/test_evolution_preflight.py(new): 27 tests covering stage detection, config, digest fallback, the ping per api_mode, and scheduler-level integration.Why
When the configured provider is unreachable (e.g. Kimi timeout storms), evolution sessions burn retries/timeouts and deliver nothing. The pre-flight detects this quickly and falls back to the last good digest, so the pipeline keeps moving with stale-but-structured input instead of failing silently. This is graceful degradation, not a retry mechanism.
ROOT-FIX (this is why it failed on prod)
preflight_provider(runtime)readsruntime.get("model"), butresolve_runtime_provider()never populates amodelkey — the scheduler resolves the model into a separate localmodelvariable and passes it toAIAgent(model=...)directly. On prod,runtime["model"]was therefore always empty, so the ping short-circuited withno model configured for pre-flight pingand the cached-digest fallback could never trigger.Fix: before the ping, hand
preflight_providera runtime that carries the already-resolved model:A shallow copy (not in-place mutation) keeps the ping side-effect-free, and the guard never clobbers a model the runtime may already carry (e.g. ACP-resolved). The local
modelis guaranteed non-empty at this point —_run_job_implraises earlier if no model resolves.Provenance
This feature previously existed only as untracked local code on the prod host; a
git stash -uduring a deploy hid it, and upstream-merge #487 overwrotescheduler.pywith the native version without it. This PR restores it into git from that stash, with the root bug fixed.Tested
tests/cron/test_evolution_preflight.py— 27 passed. Includes a new unit test (test_resolved_model_does_not_bail_no_model) and a scheduler-level test (test_root_fix_runtime_model_synced_from_config_default) that reproduces the exact prod condition:resolve_runtime_provider()returns a runtime with nomodel, the job pins no model, andconfig.yamlsuppliesmodel.default. It asserts the runtime handed to the ping carries the resolved default.captured['model'] == None) and passes with it — so it genuinely exercises the bug.test_scheduler_provider.py(29),test_scheduler.pymodel/runtime/run_job slice (77),test_run_one_job.py+test_codex_execution_paths.py(8).ast.parseclean on all three files.Closes #486.