Repository navigation
feat(router): add durable automatic model selection - #892
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of 14dbe40: one correctness issue in the production child-inheritance wiring needs fixing. Auto admission and primary reauthorization support Genesis through ModelService, but the new dynamic-agent and forked-skill inheritance closures bypass that service and use the database-only resolver, so valid Genesis Auto runs cannot start these children.
Reviewed HTTP admission, shared-loop selection timing, semantic admission, durable decision/model updates, replay and contract checks, child execution, and SDK serialization. Five targeted source-executed SDK serialization/validation cases and git diff --check passed. Rust/Cargo and a MatrixOne test instance are unavailable in this environment, so I did not rerun the Rust or database suites. The inline finding is based on the concrete production call chain.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review of aa6dab5.
The previous Genesis/UC inheritance finding is fixed. Both dynamic-agent runtime-context resolution and forked-skill inheritance now use the injected ModelService, retaining the existing contract-digest check. The new regressions exercise those production resolver paths with a service-backed Offering and verify that revoked access is rejected.
I rechecked HTTP Auto admission, selection timing and semantic Work admission, candidate compatibility and billing identity, the atomic decision/model transaction, replay and contract revalidation, dynamic-agent/forked-skill/delegation inheritance, and SDK serialization. I found no additional actionable correctness issue.
Validation: local git diff --check passed. I inspected this head's CI logs: all 6,194 runtime tests passed, including both new Genesis inheritance tests and all eight model-routing tests; static checks and the turn-core/services/plan job also passed. Rust/Cargo and a MatrixOne instance are unavailable locally, so I did not rerun those suites here.
CI is not fully green: the online integration job reported 276 passed, one failure because partial-batch bootstrap exceeded its 10-second setup budget, and one session-artifact test timeout at 30 seconds. The logs do not establish a causal link to this PR. This code approval does not resolve those outstanding integration failures; they still need investigation or a successful rerun before merge.
Merge Queue Status
This pull request spent 21 minutes 29 seconds in the queue, including 20 minutes 57 seconds running CI. Required conditions to merge
|
Summary
Add opt-in automatic model selection for Server-catalog chat turns. A confidently easy, read-only task can use an operator-qualified economy Offering; difficult, uncertain, unsupported, or incompatible cases retain the strong Offering. This gives API and SDK users a conservative way to reduce inference cost without changing explicit model selection.
The shared runtime persists the selected model and its semantic admission before primary inference, reauthorizes execution, and propagates the choice to child runs. Auto selection starts or awaits the bounded assessment under the default auxiliary policy, so it does not silently pin every request to strong. Learned routing and mid-turn escalation are outside this PR.
Related issue
No linked issue. Follows the next-turn assessment work in #888.
Change type
User and compatibility impact
[model_routing]in the Server runtime configuration. Routing is disabled by default; this PR does not establish measured savings or qualify model pairs automatically.execution_policy.model_routing = "auto"and omitmodel_selection. The TypeScript SDK acceptsmodelSelection: "auto".boundary_only, andalways. Disabled or unusable assessments retain strong. Ordinary non-Auto turns keep their existing admission timing.Architecture and complexity delta
astra-turn-core; typed routing configuration inastra-turn-types; existing Offering admission and shared agent loop in runtime; generation-fenced run-event transaction in services.The immutable routing event records policy and algorithm versions, input reference, assessment, selected Offering/model, contract digest, and semantic Work decision. The transaction updates the effective run model alongside that event. Persistence failure, stale execution ownership, revoked access, or changed model contracts prevent dispatch. Credentials and endpoints are not stored in the routing decision.
Verification
cargo test --locked --offline -p astra-runtime --lib --no-default-features model_routing -q— 8 passed. The entrypoint test covers default, explicit capacity-aware, boundary-only, always, disabled, and malformed-assessment cases, including no duplicate assessment on later preparation.cargo test --locked --offline -p astra-runtime --lib --no-default-features ordinary_primary_turn_defers_work_admission_without_a_boundary -q— 1 passed.cargo test --locked --offline -p astra-runtime --lib --no-default-features post_response_work_admission_is_projected_into_the_typed_graph -q— 1 passed.cargo test --locked --offline -p astra-services --test runs_db_batch_it auto_model_routing_memory_commit_is_atomic_and_fenced -q— 1 passed.packages/sdk:npm test -- src/__tests__/client.test.ts— 85 passed.cargo clippy --locked --offline -p astra-runtime --lib --tests -- -D warnings— passed on the final code.make format-checkandgit diff --check— passed.make check— passed on the rebased implementation before the final default-policy fix; that fix was subsequently verified by the targeted tests, Clippy, and formatting checks above.cargo test --locked --offline -p astra-services --test runs_db_batch_it -- --skip auto_model_routing_database_commit_is_atomic_and_fenced— 2 passed: shared database-isolation contract and in-memory routing transaction; 21 database tests ignored.MATRIXONE_HOST=127.0.0.1,MATRIXONE_PORT=6001, local development credentials,ASTRA_DATABASE=ASTRA_TEST_DATABASE=astra_runtime_test_router_pr892_20260927_runtime_ignored(both variables set separately),ASTRA_DATABASE_PREFIX="",ASTRA_AUTO_CREATE_DATABASE=1, andASTRA_TEST_DB_IT=1:cargo test --locked --offline -p astra-services --test runs_db_batch_it auto_model_routing_database_commit_is_atomic_and_fenced -- --ignored --exact --test-threads=1— 1 passed against real MatrixOne in 0.90s.prepare_turn_iterationandexecute_turnagainst a local mock provider; SDK request serialization. No live HTTP deployment or paid provider was exercised.Final checklist