Repository navigation
Description
Overview
LocalAgentService::get_status now reports the loaded model's id and granted context window (PR #1778, needed by the agent-eval preflight gate). Doing so calls model_spec(), which reaches LlamaChatEngine::model_info() — and that takes a std::sync::Mutex that generate_blocking holds for the entire duration of inference.
get_status (async)
→ service.read().await [held across the call below]
→ LocalAgentService::model_spec()
→ agent_loop.engine().model_info()
→ LlamaChatEngine::model_info() packages/nlp-engine/src/chat/mod.rs:1120
→ self.state.lock() std::sync::Mutex
generate_blocking (packages/nlp-engine/src/chat/mod.rs:343) holds that same mutex while generating. So a previously-cheap status RPC can now block for 60–180s during a turn, and it blocks a tokio worker thread doing it (synchronous lock inside an async fn), while also holding the service read lock.
Why this isn't urgent today
GetStatusis currently called only bynodespace model status(the CLI path added for the eval preflight gate), which runs before a model is generating.- The frontend does not poll it.
service.read()is a read lock, so it does not block other readers.- Lock ordering is safe — every site touching
serviceandactive_model_idacquiresservicefirst and releases beforeactive_model_id; there is no reverse-order site and no deadlock.
Why it should still be fixed
It is a latent trap. The moment a status poller is added to the UI — which is a natural thing to add — it will hang during streaming, and the cause will be several layers away from the symptom.
Suggested fix
Cache the spec at load time alongside active_model_id. It only changes on engine swap, and replace_engine is the single choke point, so a cached (model_id, granted_n_ctx) pair updated there would make get_status allocation-free and non-blocking.
Alternative: document the blocking behavior on model_spec() so the next caller is warned. That is strictly weaker — it relies on the next person reading it.
Source
Raised as 🟡 Important #4 in the code review of PR #1778 and deliberately deferred there: the fix is a daemon-internal refactor, and the PR's scope was the eval harness.
Activity
Address review: fail closed on the destructive check, abort on mid-ru…
Address review: fail closed on the destructive check, abort on mid-ru…
Shared eval runner with a preflight gate: stop scoring scenarios when…
malibio commentedon Jul 28, 2026
Baseline (issue-1779-cached-model-spec, from 461bab1): Frontend: 170 test files passed, 4104 tests passed.