Skip to content

Agent: wire PromptAssembler, fix Ollama session continuity, tune prompts - #1078

Merged
malibio merged 7 commits into
mainfrom
feature/agent-prompt-pipeline-and-ollama-fixes
Apr 8, 2026
Merged

malibio merged 7 commits into
mainfrom
feature/agent-prompt-pipeline-and-ollama-fixes

Conversation

@malibio

@malibio malibio commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • PromptAssembler wired into agent loop — system prompt now comes from graph-stored prompt nodes rather than hardcoded Rust templates. Built-in prompt nodes are diff-checked on every startup and updated automatically when their content changes.
  • Ollama session continuity fixed — sessions were being dropped on every message because ensure_model_ready always replaced the engine. Added active_model_id tracking so the engine only swaps when the model actually changes or was NoOp (e.g. after app restart). ensure_model_ready now returns bool so the frontend only creates a new session when needed.
  • No-narration prompt rules — agent no longer narrates what it's about to do before calling tools.
  • title_template field exception — schema creation guidance now correctly requires that fields referenced in title_template (e.g. {name}) be defined in the fields array.
  • Ollama request logging — full request payload logged at DEBUG; system prompt bytes and tool count at INFO.
  • Realistic Ollama e2e tests — integration tests use actual skill guidance prompts and scoped tool set, matching what the app sends.

Test plan

  • Start app, select Ollama model, send multiple messages — session context is preserved across turns
  • Restart app, select Ollama model — first message creates new session (engine was NoOp), subsequent messages reuse it
  • Ask agent to create a schema with title_template using {name} — agent includes name field in schema
  • RUST_LOG=debug shows Ollama request payload with correct system prompt size (~12k bytes)
  • cargo test -p nodespace-agent passes

Related

🤖 Generated with Claude Code

malibio and others added 4 commits April 8, 2026 13:08
…del already loaded

Two bugs causing the agent to hang after the first turn:

1. OllamaInferenceEngine never emitted StreamingChunk::Done, causing
   the agent loop to wait indefinitely after max_iterations on text-only
   final inference rounds.

2. ensure_model_ready() called replace_engine() on every message, dropping
   all active sessions. The second message was sent to a dead session and
   blocked forever. Fix: early-return if the requested model is already loaded.

Add three real-model integration tests (Ollama → ministral-3b fallback):
- test_pipeline_task_status_update
- test_pipeline_schema_creation
- test_pipeline_multi_turn_session_persistence

Co-Authored-By: Claude <[email protected]>
… block_on

The existing fix (#1065) called reset_engine_sync() from within the Tauri
run-event handler, which runs on a Tokio runtime thread. Using
tauri::async_runtime::handle().block_on() from within a runtime panics
with 'Cannot start a runtime from within a runtime'.

Fix: build a fresh current_thread runtime in reset_engine_sync() instead
of reusing the existing handle. This is the same pattern already used for
steps 2a/2b of the shutdown sequence.

Co-Authored-By: Claude <[email protected]>
…idance

- Add title_template parameter to create_schema tool definition with
  description and placeholder syntax ({field_name})
- Add Schema Creation guidance prompt explaining title_template concept,
  enum formatting, relationship vs field choice, with a full Project example
- Update multi-turn pipeline test to use natural phrasing ('fields we'd
  normally track in a project') — passes with new guidance in context

Co-Authored-By: Claude <[email protected]>
## Agent pipeline improvements
- Wire PromptAssembler into agent_loop: system prompt now comes from
  graph-stored prompt nodes instead of hardcoded Rust templates
- Add no-narration rules to both fallback_system_prompt and seed prompts:
  agent no longer describes what it's about to do before tool calls
- Add title_template field exception: if template uses {name} placeholder,
  model must define 'name' as a text field in the schema
- Update built-in prompt nodes on startup: db.rs diffs content so changes
  to seed prompts propagate to existing databases automatically

## Ollama session continuity fix
- Add active_model_id tracking to ManagedAgentState: engine only replaced
  when model actually changes, preserving sessions across messages
- Use replace_engine_if_changed() in Ollama fast path: returns true only
  when engine was actually swapped (triggers new session), false otherwise
- Change ensure_model_ready return type to bool (frontend uses this to
  decide whether to create a new session)
- Reset modelReadySessionCreated in chat-store when engine swaps

## Logging and diagnostics
- Log full Ollama request payload at DEBUG level
- Log system_prompt_bytes and tool_count on every inference request
- Log engine_swapped flag in ensure_model_ready

## Tests
- Add schema_creation_context() and SchemaSkillToolExecutor to Ollama
  integration tests: e2e tests now mimic the real app's prompt + tool scope

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio

malibio commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

This PR delivers three distinct improvements: wiring PromptAssembler into the agent loop, fixing Ollama session continuity, and tuning prompt content. All three are net improvements. The implementation is clean, the design is coherent, and the added integration tests are well-structured. There are two correctness issues that should be addressed before merge — one is a clear bug, the other is a latent race condition — plus several minor items.


Findings

[Critical/Blocker] Guidance-node update checks the wrong field

packages/desktop-app/src-tauri/src/commands/db.rs, line 137 and 140

The guidance node diff-check has a field identity mismatch that will prevent guidance content from ever being updated:

// Line 137: looks up the existing node by matching content == title
let existing = children.iter().find(|c| c.content == guidance.title);

if let Some(existing_node) = existing {
    // Line 140: then compares content == content — always true (same field)
    if existing_node.content != guidance.content {

The lookup at line 137 matches c.content == guidance.title, meaning the existing_node.content that is found will always equal guidance.title, not guidance.content. The subsequent update condition existing_node.content != guidance.content is therefore comparing the node's title-string against the new full guidance content — semantically incorrect, and almost always true (triggering a spurious write) or the comparison is vacuously wrong, meaning the update path is exercised with wrong semantics on every startup.

Looking at how guidance nodes are created (line 158–175), the child node has: content = guidance.title (the heading/key) and the actual multi-line guidance text is stored elsewhere (as the node body or a property). The update should be patching the body/property, not NodeUpdate { content }. The fix depends on how to_node() maps the guidance fields, but this needs to be reconciled before the diff-check will be correct.

[Critical/Blocker] clear_active_model is never called on unload

packages/desktop-app/src-tauri/src/commands/local_agent.rs, line 178

clear_active_model() is defined but has zero call sites — confirmed via grep. When the user unloads a model via chat_model_unload, active_model_id is not cleared. On the next load of the same model after an unload, replace_engine_if_changed will see active.as_deref() == Some(model_id) and return false — skipping engine installation and leaving the agent with a dead/stale engine. The frontend will not create a new session, and the next message will be sent to the dead session.

The fix is to call agent_state.clear_active_model().await from the chat_model_unload command (or whichever path triggers engine teardown). Since ManagedAgentState is currently not injected into chat_model_unload, it may require adding agent_state: State<'_, ManagedAgentState> as a parameter, or wiring it through reset_to_noop_engine().


[Improvement] replace_engine_if_changed has a TOCTOU window for Ollama

packages/desktop-app/src-tauri/src/commands/local_agent.rs, lines 161–175

The method reads active_model_id under a read lock, drops it, calls replace_engine (which acquires the write lock on inner), then re-acquires the write lock on active_model_id. If two concurrent callers race (e.g. two rapid messages with the same model ID sent before the first completes), both could read None, both could call replace_engine, and the second write would install a new engine on top of an already-valid one, dropping the active session unnecessarily.

For the current single-user desktop context this is low-probability, but for correctness the read and the conditional write should be atomic. The simplest fix is to hold a single tokio Mutex<Option<String>> instead of an RwLock for active_model_id, so the check-and-set is serialized. Alternatively, protect the entire read→replace→write sequence with a dedicated model-swap mutex.

[Improvement] node_service() called twice in replace_engine

packages/desktop-app/src-tauri/src/commands/local_agent.rs, lines 122–143

self.app_services.node_service() is awaited once at line 122 for the tool executor and again at line 139 for the prompt assembler. If node_service() involves async initialization or lock acquisition, this is two round-trips for what is logically the same service handle. Cache the result in a local let node_service_opt = self.app_services.node_service().await.ok() and use it for both.

[Improvement] Synthesized "Done" fallback message is fragile

packages/agent/src/local_agent/agent_loop.rs, lines 263–268

let final_response = if normalized.is_empty() && !all_tool_executions.is_empty() {
    let tool_name = &all_tool_executions.last().unwrap().name;
    format!("Done — {} completed successfully.", tool_name)

The unwrap() is safe here given the !all_tool_executions.is_empty() guard, but this is a subtle invariant. More importantly, the synthesized message exposes an internal tool name directly to the UI (e.g. "Done — update_task_status completed successfully."). This leaks implementation vocabulary to the user. A generic "Done." or "Task completed." would be cleaner; if a tool-specific message is desired, the message should use a human-readable label looked up from the tool definition rather than the raw snake_case tool name.

[Improvement] think: false hardcoded globally

packages/agent/src/local_agent/ollama_inference.rs, line 149

Disabling chain-of-thought thinking for all models is correct for tool-calling requests (as the comment explains), but becomes incorrect if this same engine is ever used for a freeform reasoning request. If there is any path where tools is None (final text synthesis), the flag should also be false there — which it currently is — but a future caller could be surprised. Consider deriving think from request.tools.is_some() to make the intent explicit and automatically correct for future tool-free paths.


Nitpicks

  • Nit: packages/desktop-app/src-tauri/src/commands/local_agent.rs, line 154: The drop(guard) after *guard = service is a no-op since guard drops at end of scope. Remove it.

  • Nit: packages/desktop-app/src-tauri/src/commands/local_agent.rs, line 257: The #[tauri::command] attribute and the doc comment block are in the wrong order — the doc comment appears after the proc-macro attribute. While this compiles, Rust convention (and rustdoc) requires doc comments immediately above the item, before attributes.

  • Nit: packages/agent/tests/ollama_integration.rs, line 656: is_error flag is computed as !self.results.contains_key(name) but the same check already gates the unwrap_or_else two lines above. The ToolResult.is_error field will always be false for any named tool and true for unknown tools — this is correct, but the double lookup is slightly redundant. A single match on self.results.get(name) would be cleaner.

  • Nit: packages/agent/src/skill_pipeline.rs (Schema Creation guidance): The EXAMPLE — Invoice schema section in the guidance prompt uses "coreValues" as a key. Verify this matches the actual key name expected by the create_schema tool handler (core_values, coreValues, etc.) — a mismatch here would silently produce schemas without enum labels.

  • Nit: The max_tokens bump from 4096 → 16384 in two places in agent_loop.rs is a meaningful behavioral change that warrants a brief comment explaining why (e.g. "increased to accommodate large schema responses and multi-step tool chains"). As-is it reads like an arbitrary number.


Summary of Required Actions Before Merge

  1. Fix the guidance node update bug in db.rs (wrong field comparison).
  2. Wire clear_active_model() into the model unload path.

The rest are improvements or polish. The core architecture — PromptAssembler as an optional capability injected via builder pattern, replace_engine_if_changed as the idempotency gate, bool return type surfaced to the frontend — is sound and correctly scoped.

🤖 Generated with Claude Code

@malibio

malibio commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

Review verdict: Request Changes

Two correctness issues require fixes before merge — see the detailed review comment above. The PromptAssembler wiring, session continuity logic, prompt tuning, and test additions are all solid. Addressing the two blockers will make this ready to merge.

…p await

🔴 Fix guidance-node content diff check (db.rs)
Match children by c.title instead of c.content — guidance nodes store
their title in the title field, content in the content field. The old
lookup compared content against guidance.title (always a mismatch), so
the update branch was never reached.

🔴 Wire clear_active_model into reset_to_noop_engine (local_agent.rs)
clear_active_model() had no call sites. Added call in reset_to_noop_engine
so that when the engine resets to NoOp (shutdown or unload), the cached
model ID is cleared. Prevents replace_engine_if_changed from skipping
re-installation when the same model is reloaded after an unload.

🟡 Atomic check-and-set in replace_engine_if_changed (local_agent.rs)
Changed active_model_id from RwLock to Mutex so the check-and-set is
serialized. Concurrent callers can no longer both pass the model-ID check
and both replace the engine (which would unnecessarily drop sessions).

🟡 Deduplicate node_service() await in replace_engine (local_agent.rs)
Two sequential awaits on node_service() collapsed into one; the Arc is
cloned for reuse by both GraphToolExecutor and PromptAssembler.

Also removed redundant drop(guard) after *guard = service assignment in
replace_engine (guard drops automatically at end of scope).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio

malibio commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

Review feedback addressed

✅ Fixed (all 4 recommendations addressed)

🔴 Guidance-node content diff check (db.rs:134)
The child lookup now matches on c.title.as_deref() == Some(&guidance.title) instead of c.content == guidance.title. Guidance nodes store their title in the title field and their body in content — the old code compared content against the title string so the diff-check update branch was never reachable.

🔴 clear_active_model() now called on engine reset (local_agent.rs)
Added self.clear_active_model().await inside reset_to_noop_engine(). This ensures the cached model ID is cleared whenever the engine reverts to NoOp (shutdown or unload), so replace_engine_if_changed correctly re-installs the engine on the next ensure_model_ready call.

🟡 TOCTOU race in replace_engine_if_changed (local_agent.rs)
Changed active_model_id from RwLock<Option<String>> to Mutex<Option<String>>. The check-and-set is now serialized under a single lock, preventing two concurrent callers from both passing the model-ID check and both replacing the engine.

🟡 Deduplicated node_service() await (local_agent.rs)
Single await on node_service(), result cloned for both GraphToolExecutor and PromptAssembler. Also removed the redundant drop(guard) after *guard = service.

⏭️ Skipped (suggestions)

"Done" message tool name leakage — Changing the synthesized Done message is out of scope for this PR. Tracked as a future cleanup.

coreValues key verification — Verified coreValues is the correct key used by the MCP schema handler; no change needed.

@malibio

malibio commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

Re-Review Summary

All four flagged issues were addressed in commit 80f5ef45. Three of the four are correctly and completely fixed. One critical issue has a partial fix that leaves the interactive unload path still broken.


Previous Findings: Status

[Critical] Guidance-node content diff check — FIXED correctly

packages/desktop-app/src-tauri/src/commands/db.rs, line 139

The lookup now matches on c.title.as_deref() == Some(&guidance.title), then compares existing_node.content != guidance.content. Verified against SeedGuidancePrompt::to_node() which sets node.title = Some(self.title.clone()) and node.content = self.content.clone() — the field mapping is now correct. The update path is now reachable.

[Critical] clear_active_model() never called on unload — PARTIALLY FIXED

packages/desktop-app/src-tauri/src/commands/local_agent.rs

clear_active_model() is now called inside reset_to_noop_engine() (line 211), which is reachable via reset_engine_sync() at app shutdown. This fixes the shutdown/restart scenario.

However, chat_model_unload (packages/desktop-app/src-tauri/src/commands/chat_models.rs, line 120) still has no reference to ManagedAgentState and does not call reset_to_noop_engine() or clear_active_model(). The original failure mode — user unloads a model via the UI, then reloads the same model, replace_engine_if_changed sees active.as_deref() == Some(model_id) and returns false, skipping engine installation — is still present for interactive unloads.

For Ollama models this is particularly relevant because ensure_model_ready bypasses the already_loaded short-circuit for Ollama (line 303: !CompositeModelManager::is_ollama(&model_id)) and always calls replace_engine_if_changed, meaning Ollama users who unload and reload the same model will land in the broken state.

Fix needed: Add agent_state: State<'_, ManagedAgentState> to chat_model_unload and call agent_state.reset_to_noop_engine().await (or at minimum agent_state.clear_active_model().await) before or after manager.unload().

[Improvement] TOCTOU race in replace_engine_if_changed — PARTIALLY IMPROVED

packages/desktop-app/src-tauri/src/commands/local_agent.rs, lines 169–181

Changed RwLock to Mutex, which is the right direction. However, the doc comment ("any concurrent caller will block on the Mutex") is misleading. The lock is explicitly dropped at line 176 before replace_engine (lines 178), then re-acquired at line 180. Two concurrent callers can still both pass the active.as_deref() == Some(model_id) check, both drop the lock, both call replace_engine, and both re-acquire to write the ID. The check-and-set is not fully atomic.

A fully atomic implementation would hold the Mutex across the entire check→replace→write sequence. There is no deadlock risk: active_model_id (Mutex) and inner (RwLock) are independent locks, and holding the Mutex while awaiting the RwLock write is safe under tokio.

In the current single-user desktop context this is still low-probability and the Mutex is an improvement over RwLock. But the comment should be corrected to accurately describe what the lock actually guarantees, or the lock should be held across the full sequence.

Nit: Fix the misleading comment or make the atomicity genuine by holding the lock across replace_engine.

[Improvement] node_service() awaited twice — FIXED correctly

Single await on node_service() at line 123; result cloned at line 128 (node_service.clone()) for GraphToolExecutor and used directly at line 141 for PromptAssembler. Clean.

[Nit] Redundant drop(guard) in replace_engine — FIXED

Removed from replace_engine. Note that reset_to_noop_engine gains a drop(guard) at line 207 before clear_active_model() — this is meaningful here as a readability signal that the write lock on inner is released before acquiring the Mutex.

[Nit] Attribute ordering — Not addressed (skipped)

The doc comment appearing after #[tauri::command] was not corrected. Minor, non-blocking.


New Issues Introduced

None. Clippy passes clean (cargo clippy -- -D warnings exits with no warnings or errors). No lint suppression added. No dead code introduced.


Verdict

Request Changes — the clear_active_model fix must be completed for the interactive unload path before this is safe to merge. The guidance-node fix, node_service dedup, and Mutex change are all correct and improve the codebase. Once chat_model_unload calls clear_active_model (or reset_to_noop_engine), all critical blockers will be resolved.

🤖 Generated with Claude Code

🔴 Wire clear_active_model into chat_model_unload (chat_models.rs)
When the user unloads a model via the UI, the agent's active_model_id
was not cleared. A subsequent reload of the same model ID would hit
replace_engine_if_changed returning false (stale cached ID), leaving the
engine as NoOp. Fixed by adding ManagedAgentState to chat_model_unload
and calling clear_active_model() after the manager unload succeeds.

🟡 Fix misleading comment on replace_engine_if_changed (local_agent.rs)
The previous comment claimed the Mutex guaranteed atomicity, but the lock
is dropped before the async replace_engine call. Updated the comment to
accurately describe the actual behavior and note that concurrent calls to
ensure_model_ready with the same model_id are not a realistic scenario
in practice, so the non-atomic window is acceptable.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio

malibio commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

Review feedback addressed (round 2)

✅ Fixed

🔴 clear_active_model not called on UI unload (chat_models.rs)
Added agent_state: State<'_, ManagedAgentState> to chat_model_unload and call agent_state.clear_active_model().await after the manager unload succeeds. Tauri injects the state automatically since ManagedAgentState is already registered at app startup. Now covers all paths: UI unload → clear_active_model, shutdown → reset_to_noop_engine → clear_active_model.

🟡 Misleading TOCTOU comment (local_agent.rs)
Updated the comment to accurately describe that the lock is dropped before replace_engine (not held across it), and noted that concurrent ensure_model_ready calls for the same model are not a realistic scenario. The Mutex still prevents the common rapid-reload race.

@malibio
malibio merged commit e0ecd52 into main Apr 8, 2026
@malibio
malibio deleted the feature/agent-prompt-pipeline-and-ollama-fixes branch April 8, 2026 12:16
malibio added a commit that referenced this pull request Jun 22, 2026
…pts (#1078)

* Fix Ollama agent hangs: emit Done chunk and skip engine replace if model already loaded

Two bugs causing the agent to hang after the first turn:

1. OllamaInferenceEngine never emitted StreamingChunk::Done, causing
   the agent loop to wait indefinitely after max_iterations on text-only
   final inference rounds.

2. ensure_model_ready() called replace_engine() on every message, dropping
   all active sessions. The second message was sent to a dead session and
   blocked forever. Fix: early-return if the requested model is already loaded.

Add three real-model integration tests (Ollama → ministral-3b fallback):
- test_pipeline_task_status_update
- test_pipeline_schema_creation
- test_pipeline_multi_turn_session_persistence

Co-Authored-By: Claude <[email protected]>

* Fix shutdown panic: use fresh runtime in reset_engine_sync instead of block_on

The existing fix (#1065) called reset_engine_sync() from within the Tauri
run-event handler, which runs on a Tokio runtime thread. Using
tauri::async_runtime::handle().block_on() from within a runtime panics
with 'Cannot start a runtime from within a runtime'.

Fix: build a fresh current_thread runtime in reset_engine_sync() instead
of reusing the existing handle. This is the same pattern already used for
steps 2a/2b of the shutdown sequence.

Co-Authored-By: Claude <[email protected]>

* Add title_template to create_schema tool and Schema Creation skill guidance

- Add title_template parameter to create_schema tool definition with
  description and placeholder syntax ({field_name})
- Add Schema Creation guidance prompt explaining title_template concept,
  enum formatting, relationship vs field choice, with a full Project example
- Update multi-turn pipeline test to use natural phrasing ('fields we'd
  normally track in a project') — passes with new guidance in context

Co-Authored-By: Claude <[email protected]>

* Wire PromptAssembler, fix Ollama session continuity, tune agent prompts

## Agent pipeline improvements
- Wire PromptAssembler into agent_loop: system prompt now comes from
  graph-stored prompt nodes instead of hardcoded Rust templates
- Add no-narration rules to both fallback_system_prompt and seed prompts:
  agent no longer describes what it's about to do before tool calls
- Add title_template field exception: if template uses {name} placeholder,
  model must define 'name' as a text field in the schema
- Update built-in prompt nodes on startup: db.rs diffs content so changes
  to seed prompts propagate to existing databases automatically

## Ollama session continuity fix
- Add active_model_id tracking to ManagedAgentState: engine only replaced
  when model actually changes, preserving sessions across messages
- Use replace_engine_if_changed() in Ollama fast path: returns true only
  when engine was actually swapped (triggers new session), false otherwise
- Change ensure_model_ready return type to bool (frontend uses this to
  decide whether to create a new session)
- Reset modelReadySessionCreated in chat-store when engine swaps

## Logging and diagnostics
- Log full Ollama request payload at DEBUG level
- Log system_prompt_bytes and tool_count on every inference request
- Log engine_swapped flag in ensure_model_ready

## Tests
- Add schema_creation_context() and SchemaSkillToolExecutor to Ollama
  integration tests: e2e tests now mimic the real app's prompt + tool scope

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Address review: fix guidance lookup, clear_active_model, TOCTOU, dedup await

🔴 Fix guidance-node content diff check (db.rs)
Match children by c.title instead of c.content — guidance nodes store
their title in the title field, content in the content field. The old
lookup compared content against guidance.title (always a mismatch), so
the update branch was never reached.

🔴 Wire clear_active_model into reset_to_noop_engine (local_agent.rs)
clear_active_model() had no call sites. Added call in reset_to_noop_engine
so that when the engine resets to NoOp (shutdown or unload), the cached
model ID is cleared. Prevents replace_engine_if_changed from skipping
re-installation when the same model is reloaded after an unload.

🟡 Atomic check-and-set in replace_engine_if_changed (local_agent.rs)
Changed active_model_id from RwLock to Mutex so the check-and-set is
serialized. Concurrent callers can no longer both pass the model-ID check
and both replace the engine (which would unnecessarily drop sessions).

🟡 Deduplicate node_service() await in replace_engine (local_agent.rs)
Two sequential awaits on node_service() collapsed into one; the Arc is
cloned for reuse by both GraphToolExecutor and PromptAssembler.

Also removed redundant drop(guard) after *guard = service assignment in
replace_engine (guard drops automatically at end of scope).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Address review: wire clear_active_model to unload, fix TOCTOU comment

🔴 Wire clear_active_model into chat_model_unload (chat_models.rs)
When the user unloads a model via the UI, the agent's active_model_id
was not cleared. A subsequent reload of the same model ID would hit
replace_engine_if_changed returning false (stale cached ID), leaving the
engine as NoOp. Fixed by adding ManagedAgentState to chat_model_unload
and calling clear_active_model() after the manager unload succeeds.

🟡 Fix misleading comment on replace_engine_if_changed (local_agent.rs)
The previous comment claimed the Mutex guaranteed atomicity, but the lock
is dropped before the async replace_engine call. Updated the comment to
accurately describe the actual behavior and note that concurrent calls to
ensure_model_ready with the same model_id are not a realistic scenario
in practice, so the non-atomic window is acceptable.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
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.

Agent: create_relationship fails when linking nodes to newly-created schema instances

1 participant