Skip to content

Add Ornith 1.0 to model catalog (catalog entry, think-block routing, update_node prompt) - #1467

Merged
malibio merged 7 commits into
mainfrom
worktree-issue-1465-ornith-model
Jul 2, 2026
Merged

malibio merged 7 commits into
mainfrom
worktree-issue-1465-ornith-model

Conversation

@malibio

@malibio malibio commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1465

Summary

  • Adds ornith-1-9b-q4km catalog entry (ModelFamily::Qwen35, same OAI-compat Jinja path as Gemma 4/Qwen3.5)
  • Adds Format D XML <tool_call> parser (parse_tool_calls_xml/parse_xml_tool_call_block) wired into emit_oai_delta, with unit tests for single/multiple calls, unclosed tags, and empty parameter bodies
  • Adds ThinkSplitter (mirrors the existing Gemma 4 ChannelSplitter) to route <think>...</think> content as ChatChunk::Reasoning instead of leaking into the answer stream
  • Rewords the update_node tool description/schema with concrete example values so Ornith calls it directly instead of asking for clarification (the Evaluate Ornith 1.0 as native local model for mode 2a #1464 evaluation's 2/10 tool-call misses)

Test plan

  • cargo test -p nodespace-nlp-engine --lib --features chat-service (chat module: 90/90 passing, includes new XML parser + ThinkSplitter + combined-finalize-path tests)
  • cargo test -p nodespace-agent --lib (248/248 passing, includes updated catalog-count test)
  • cargo test -p nodespace-core --lib (965/965 passing, unaffected)
  • bun run test:all (frontend 3893/3893, skill 17/17, rust core 965/965 — no new failures vs. baseline)
  • bun run quality:fix clean (eslint, tsc, cargo fmt, cargo clippy -D warnings)
  • Smoke test (manually deferred): the issue's acceptance criterion "load Ornith 9B, send one tool-calling prompt, confirm ToolCallStart/ToolCallArgs" requires downloading the 5.23GB GGUF and running local inference, which isn't practical in this automated review pass. The XML parsing and <think> routing logic were validated against real Ornith outputs captured during the Evaluate Ornith 1.0 as native local model for mode 2a #1464 evaluation (../nodespace-nlp-experiment, 8/10 tool calls, <think> blocks confirmed present) and are covered by unit tests reproducing those exact formats, but an end-to-end live-model smoke test has not been run in this PR and should be done manually before Ornith is broadly recommended.

Co-Authored-By: Claude [email protected]

Adds the three remaining production tasks identified by the #1464
evaluation: a catalog entry for Ornith 1.0 9B (ModelFamily::Qwen35,
same OAI-compat Jinja path as Gemma 4), an XML `<tool_call>` parser
(Format D) wired into emit_oai_delta so Ornith's tool calls surface as
uniform ToolCallStart/ToolCallArgs chunks instead of leaking as plain
text, and a `<think>`/`</think>` routing path (ThinkSplitter, mirroring
Gemma 4's ChannelSplitter) so Ornith's reasoning emits as
ChatChunk::Reasoning. Also fixes the update_node tool description with
concrete example values so Ornith calls it directly instead of asking
for clarification.

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

malibio commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Review Type: Initial Review (no prior reviews/comments found on PR #1467)

Net positive change. This is a well-scoped, additive PR: one new catalog entry, one new tool-call format parser mirroring the existing three, one new reasoning splitter mirroring the existing ChannelSplitter, and a tool-description wording fix. All 5 touched files are directly load-bearing for the stated goal, no unrelated changes bundled in (aside from an incidental bun.lock version bump, presumably from a workspace-wide bun install/version-bump landed on main after this branch was cut). All new logic is unit tested (7 new parser tests + 4 new ThinkSplitter tests + 1 new emit_oai_delta integration test), and the full touched test suites pass (89/89 nodespace-nlp-engine chat tests, 35/35 nodespace-agent model_manager/ollama tests), plus a clean cargo clippy on both crates.

Requirements Check (issue #1465)

  • ✅ Catalog entry: ORNITH_1_9B added with ModelFamily::Qwen35, min_memory_gb: 16, filename ornith-1.0-9b-Q4_K_M.gguf, HF source URL. Added to CATALOG array; list_returns_all_catalog_models test updated to assert count 13 and presence of ornith-1-9b-q4km.
  • ✅ ModelFamily wiring: Reuses existing ModelFamily::Qwen35 — no new variant needed since Qwen35 already routes through apply_chat_template_oaicompat/use_jinja: true per prior model additions. Correctly matches the issue's "or confirm Qwen35 covers it" option; agent_types.rs untouched (correctly — nothing needed there).
  • ✅ update_node prompt fix: Tool description and each parameter's schema description now include concrete example values ("id": "a1b2c3d4-...", "content": "Buy milk and eggs", {"status": "done"}) instead of vague placeholders, directly addressing the "asks for clarification instead of calling the tool" failure mode from the eval.
  • ✅ <think> routing path: New ThinkSplitter struct mirrors ChannelSplitter, wired into emit_oai_delta and the finalize path, emitting ChatChunk::Reasoning for <think>...</think> spans instead of leaking into ChatChunk::Token.
  • ✅ Unit tests for parse_tool_calls_xml: All 5 requested cases covered (single call, multiple calls, missing </tool_call>, missing </parameter>, empty parameter body), plus 2 bonus cases (plain-text passthrough, missing <function=> tag).
  • ⚠️ Smoke test ("Load Ornith 9B, send one tool-calling prompt, confirm ToolCallStart/ToolCallArgs emitted, no plain-text leakage"): Not performed in this PR — reasonably so, since it requires downloading and running a 5.23 GB GGUF model, impractical for an automated review. However, the PR description ("Closes #1465") does not acknowledge this gap at all. This should be called out explicitly (e.g. "Smoke test deferred — requires manual local run with the model downloaded") so reviewers and future readers don't assume it was executed.

Findings

🟡 Important

1. PR description doesn't disclose the undone smoke-test acceptance criterion
📁 PR description (gh pr view 1467)

The PR body is just "Closes #1465". One of six acceptance criteria — the smoke test — requires a manual, non-automatable step (downloading a 5.23 GB model and running a live tool-calling prompt) that clearly wasn't performed as part of this diff (no infra changes, no evaluation artifact, no log referenced). Silently closing the issue via Closes #1465 implies all acceptance criteria are met.

Recommendation: Update the PR description to explicitly list which acceptance criteria are code-verified (unit tests) vs. which require a manual follow-up smoke test before/after merge, e.g.: "Smoke test (load Ornith 9B, live tool-calling prompt) not run in this PR — requires manual local verification with the model downloaded; tracked as a follow-up before promoting past trial status."
Principle: Traceability — a PR that closes an issue should make it obvious to any future reader which acceptance criteria were verified by what evidence (test run vs. manual claim), especially when the issue explicitly separates "trial" from "promoted" status for this exact model.

2. ThinkSplitter's trailing carry from ChannelSplitter is never think-scanned at finalize
📁 packages/nlp-engine/src/chat/mod.rs:605-607

let (channel_answer, final_reasoning) = channel_splitter.finalize();
let (final_answer, final_think_reasoning) = think_splitter.finalize();
let final_answer = channel_answer + &final_answer;

In the streaming path (emit_oai_delta), think_splitter.push(&answer) only ever receives channel_splitter's emitted answer text each iteration — never text still parked in channel_splitter.carry (a suffix that's a partial-prefix match against <|channel>/<channel|>, which can also start with the same leading < byte that a <think> marker starts with). If generation ends (context cap or natural stop) while channel_splitter is mid-way through holding back a candidate partial marker (e.g. a lone trailing <), that raw text is drained straight into channel_answer at finalize and concatenated into final_answer without ever passing through think_splitter. In the pathological case where that trailing fragment is actually the start of an unterminated <think> marker truncated by the token cap, it would leak as answer text instead of being (best-effort) treated as reasoning — the exact bug class this PR is fixing for the common case.

This is a genuine edge case (requires generation to be truncated at a very specific byte boundary), not a regression for typical completions, and the concatenation order itself (channel_answer before think_splitter's own carry) is correct given the data-flow direction. Given it only affects truncated/cut-off generations at token-cap boundaries, I would not block on this.

Recommendation: Either (a) route channel_answer through think_splitter.push() before finalizing think_splitter (mirrors the live per-delta ordering: channel first, then think), or (b) add a comment acknowledging this is a known, accepted limitation for the truncated-generation edge case. Option (a) is cheap:

let (channel_answer, final_reasoning) = channel_splitter.finalize();
let (think_answer, think_reasoning) = think_splitter.push(&channel_answer);
let (carry_answer, carry_reasoning) = think_splitter.finalize();
let final_answer = think_answer + &carry_answer;
let final_think_reasoning = think_reasoning + &carry_reasoning;

Principle: When composing two stateful, order-dependent parsers, the finalize/flush path must preserve the same data-flow ordering as the steady-state path, or the two can diverge exactly at end-of-stream — the boundary condition most likely to matter for truncated/long generations.

3. No test exercises the combined ChannelSplitter + ThinkSplitter finalize path
📁 packages/nlp-engine/src/chat/mod.rs:1236 (test module)

All new tests exercise ThinkSplitter in isolation (think_split_all helper) or emit_oai_delta with a single complete XML tool-call block. None drive the full engine-loop-style sequence — channel_splitter.push → think_splitter.push → both .finalize() — with an unclosed marker in flight in either splitter at end-of-stream, which is exactly the scenario in Finding #2. Given this is the trickiest interaction surface in the change (two stateful order-dependent buffers chained together), it's the part most in need of a regression test.

Recommendation: Add a test that feeds emit_oai_delta (or a small harness combining both splitters like the existing channel_split_all/think_split_all helpers) a sequence ending with a truncated <think> marker, asserting the finalize output routes correctly.
Principle: Test the seams, not just the units — bugs in stateful pipelines concentrate at the composition boundary, not inside each component.

🟢 Suggestions

4. Ornith's empty-sha256 comment doesn't name it as an unofficial/third-party repo, unlike sibling entries
📁 packages/agent/src/local_agent/model_manager.rs:172

sha256: "", // Populate before promoting past user-selectable trial status

The struct-level doc comment (lines 47-54) states the empty-string policy is reserved for "official, tamper-evident" repos (mistralai/..., ggml-org/...); everything else needs a populated hash. Ornith's source is huggingface.co/DeepReinforce/... — clearly not one of the two official namespaces. Sibling third-party entries in this same file are explicit about why they're an exception, e.g.:

  • QWEN35_9B (line 147): "Unsloth repo — policy exception, trial only; populate hash before promoting"
  • Mistral Small (line 211): "Third-party repo but widely used; populate before promoting to default"

Ornith's comment omits the "third-party repo" qualifier that its siblings all state, even though the behavior (empty hash, trial-only, "populate before promoting") is consistent with the documented policy exception pattern — it's just less self-documenting than its neighbors. Not a defect (no verification is silently skipped for an entry masquerading as official), but worth tightening for consistency and to avoid a future reader mistaking the terse comment for an implicit "this is an official repo."

Recommendation: sha256: "", // DeepReinforce repo — third-party, trial only; populate hash before promoting
Principle: Consistency of self-documenting code — when a codebase has an established comment convention encoding a security-relevant policy distinction (official vs. third-party trust), every instance should follow it uniformly so a reader can rely on the pattern without cross-referencing the doc comment each time.

Nit: packages/nlp-engine/src/chat/parser.rs — parse_xml_tool_call_block computes func_body_start using func_open (an index into block) combined with lengths that were measured relative to after_func_eq (a subslice starting at func_open + "<function=".len()), which happens to be arithmetically correct here but is easy to get wrong on a future edit since the two index bases are silently threaded together across several lines. A short inline comment noting "index rebased into block" at the func_body_start computation would help future maintainers.

Nit: The ORNITH_1_9B.context_window (32,768) and default_temperature (0.6) are hardcoded to match QWEN35_9B's values without a comment confirming these come from Ornith's own model card/config rather than being copy-pasted defaults — worth a one-line confirmation in the doc comment if these were verified against Ornith's actual config.json/chat template rather than assumed-identical to Qwen3.5.

Security

No concerns. No user input is parsed here in a security-sensitive way — parse_tool_calls_xml/parse_xml_tool_call_block parse trusted local-model output (not attacker-controlled network input), bounded by text.find/slice operations that fail closed (ParseResult::Error) rather than panicking on malformed input. No secrets, no new network surface. The sha256 empty-hash question (Finding #4) is a supply-chain/integrity concern in spirit but is explicitly gated behind "trial status" and matches an existing, accepted policy exception pattern already used for other third-party repos in this same catalog — consistent with prior precedent, not a new risk introduced by this PR.

Performance

No concerns. Both parsers operate on already-materialized strings via find/slice (no regex, no unbounded backtracking); ThinkSplitter carries at most a few bytes of partial-marker state between deltas, identical complexity profile to the existing ChannelSplitter. No new allocations of consequence beyond what the existing sibling code already does.

Testing

Strong coverage for the new parser (7/5 requested cases) and for ThinkSplitter in isolation (4 tests covering same-delta, split-across-deltas, unterminated-opener, and clean-content cases — mirroring the existing ChannelSplitter test suite one-for-one). The emit_oai_delta_routes_ornith_xml_tool_call_to_chunks test correctly validates the full JSON-delta → chunk pipeline. Gap: no test for the combined-finalize interaction (Finding #3), and the smoke test is out of scope for automation (acknowledged limitation, not a testing defect in this PR — see Finding #1 about the PR description not surfacing this).

Documentation

Good: module-level doc comment in parser.rs extended with the Format D XML shape; inline doc comments on ThinkSplitter explain its relationship to ChannelSplitter and why it's a separate struct rather than a generic/parameterized one (reasonable design justification — avoids over-engineering a two-instance case into a generic abstraction, consistent with YAGNI). ORNITH_1_9B's doc comment is thorough and cites the evaluation issue (#1464) with concrete numbers. Only gap is the PR description itself (Finding #1) and the sha256 comment specificity (Finding #4).

Recommendation: COMMENT

This is a net-positive, well-tested, narrowly-scoped change that correctly implements 5 of 6 acceptance criteria in code, with the 6th (smoke test) being a reasonable manual/deferred item — the only real issue is that this deferral isn't disclosed in the PR description. None of the findings are blockers: the ThinkSplitter finalize edge case (Finding #2) is a narrow truncated-generation corner case with a cheap fix, and the sha256 comment wording (Finding #4) is a documentation-consistency nit, not a policy violation. I'm not able to self-approve this PR (it was authored through the same agent-driven workflow as this review), so the author/user should make the final approve/merge call — recommend addressing Finding #1 (PR description) at minimum before merge, with Findings #2 and #3 as strong follow-up candidates (could be same PR or a fast-follow).

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review posted above. Recommendation: COMMENT (net positive, no blockers). See full report in PR comments for the important/suggestion-level findings on ThinkSplitter finalize-path edge case, missing combined-splitter test, PR description gap on the smoke-test criterion, and the sha256 comment wording.

… finalize

The finalize path emitted ChannelSplitter's leftover carry (e.g. a
truncated "<thi" fragment) straight to the answer/reasoning sinks
without passing it through ThinkSplitter first, unlike the streaming
push path where content always flows channel_splitter -> think_splitter.
A <think> marker truncated by the token cap at the same moment
ChannelSplitter held an unresolved partial marker could have leaked
into the visible answer. Fixed and added a regression test exercising
the combined finalize path. Also clarifies the Ornith catalog entry's
sha256 comment to call out DeepReinforce as a non-official repo
requiring a hash before promotion, matching the stated policy.

Addresses reviewer feedback from PR #1467 (skipped: index-arithmetic
naming nit in parse_xml_tool_call_block — code is already covered by
7 passing unit tests, not worth the churn; context_window/temperature
values match the sibling QWEN35_9B entry's conventions, no action
needed).

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

malibio commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed review feedback

Important:

  • ✅ ThinkSplitter finalize edge case — channel_splitter's leftover carry now routes through think_splitter.push() before finalizing, matching the streaming push path. Added emit_oai_delta_finalize_routes_channel_carry_through_think_splitter regression test.
  • ✅ PR description gap — updated with a full test plan and explicit disclosure that the live-model smoke test (5.23GB download) was manually deferred, not run in this PR.

Suggestion:

  • ✅ Ornith sha256 comment — clarified to explicitly call out DeepReinforce as a non-official repo requiring a hash before promotion past trial status, matching the file's stated verification policy.

Skipped:

  • ⏭️ Index-arithmetic naming nit in parse_xml_tool_call_block — code is already covered by 7 passing unit tests; renaming offsets is a readability nice-to-have, not worth the churn for this PR.
  • ⏭️ Confirming context_window/temperature against Ornith's model card — these match the sibling QWEN35_9B entry's conventions (32,768 / 0.6), consistent with treating Ornith as sharing the Qwen3.5 base per the issue's guidance; no issue-mandated action.

All tests re-verified after these changes: nodespace-nlp-engine --lib --features chat-service 90/90, nodespace-agent --lib 248/248, quality:fix clean.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The changes are a targeted bugfix (routing carry through an existing, already-tested splitter) plus a regression test, a documentation-only comment clarification, and a PR description update. No new architecture, no new external behavior beyond fixing the described edge case. Low risk, straightforward to verify from the diff.

- Corrects the Ornith catalog entry's HuggingFace URL: the org name/casing
  was wrong (DeepReinforce vs. the real deepreinforce-ai), causing every
  download attempt to 401. Verified the corrected URL resolves and fixed
  the file size to the exact byte count.
- Widens the desktop-app allowlist and frontend ModelFamily type/filters so
  Ornith (and any future qwen35-family model) can actually appear and be
  downloaded/selected in Settings > AI Models, alongside Ministral.
- Fixes a real bug found via live testing: Ornith's tail-inference path
  (used after the ReAct loop's duplicate-tool-call guard breaks out) had no
  stripper for Ornith's leaked <tool_call> XML or its <|mask_end|> special
  token, so malformed raw model output was being persisted verbatim as the
  assistant's chat message. Added strip_ornith_tool_call_leak (mirrors the
  existing Gemma <|channel> stripper) with regression tests using the exact
  real transcript content that reproduced the bug. Also fixes a related gap
  where an empty-after-stripping response would have persisted an empty
  assistant bubble instead of falling back to a tool-result summary.
- Corrects the catalog entry's doc comment: the #1464 evaluation's "later
  turns won't slow down" claim was an extrapolation from single-shot decode
  benchmarks, not a measured result for multi-iteration ReAct loops. Ornith's
  recurrent (SSM) layers cannot do partial KV-cache reuse (confirmed both in
  our logs and upstream: ggml-org/llama.cpp issues #19858, #20003, #20153,
  #20225, #21912 — an open, unresolved limitation affecting all Qwen
  3.5-based hybrid models), so every ReAct iteration re-decodes the entire
  growing prompt from scratch. A 4-iteration turn took ~108s in practice.
  Added a visible warning in the Settings model card so this is disclosed
  before a user selects it, rather than discovered mid-conversation.

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

malibio commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary — Re-Review of commit bb7f842 (3rd round)

Scope: This review covers only the newest commit, bb7f842e, on top of the two prior COMMENT-level review rounds (both already resolved — the ThinkSplitter finalize-carry fix and PR-description/sha256-comment updates from round 2 are not re-litigated here).

Net positive. This commit fixes a real, verified-broken download URL, closes a real leaked-output bug reproduced against a live transcript, corrects a factual overclaim in a doc comment, and does the minimal wiring needed to expose Ornith in the UI with an appropriate risk disclosure. All four sub-changes are cohesive under a single theme ("make Ornith actually usable end-to-end and honest about its limitations") — not unrelated bundling, given they were all discovered in the same live-testing pass.

Independent Verification Performed

  • HF URL fix: curl -sIL https://huggingface.co/deepreinforce-ai/Ornith-1.0-9B-GGUF/resolve/main/ornith-1.0-9b-Q4_K_M.gguf → 302 then 200, content-length: 5629108704. This is an exact match to the new size_bytes: 5_629_108_704 in model_manager.rs. Confirmed correct.
  • KV-cache full-reprocess claim: "KV cache partial trim returned false, falling back to full decode" exists verbatim at packages/nlp-engine/src/chat/mod.rs:399, matching the doc comment's quoted log line.
  • Eval methodology claim: Read run_d_speed_at_context in ../nodespace-nlp-experiment/src/ornith_eval.rs (line 778). Confirmed: make_ctx (fresh LlamaContext) is created inside the per-context-size loop (line 803), and each iteration does exactly one generate() call — no re-prompting, no reused context across iterations. This substantiates the commit's core factual correction: the original "flat across context lengths" claim was a single-shot decode benchmark and does not measure (and cannot speak to) repeated-prompt ReAct-loop behavior. The new doc comment's hedging ("does NOT extend to... as originally assumed") is accurate, not an overclaim.
  • Regex safety: ornith_tool_call_re() = (?s)<tool_call>.*?</tool_call> — non-greedy, no nested quantifiers, no alternation-of-overlapping-patterns. Compared against the existing tool_call_prose_re() (hand-unrolled brace nesting specifically to avoid ReDoS on {...} blobs). The new regex has no braces or nesting to unroll; a non-greedy dot-star between two literal anchors is standard-safe in Rust's regex crate (linear-time guaranteed, no backtracking engine). No concern.
  • Fallback logic parity (agent_loop.rs): Traced the new normalize_response(&tail_text) → normalized_tail.is_empty() branch against the existing pattern at lines 466-478 (normalized.is_empty() gate after normalize_response_traced). Confirmed same shape: normalize once, branch on the normalized (not raw) emptiness. Bonus: this also eliminates a double-normalization call that existed in the prior version (normalize_response was called in the else branch redundantly) — a small correctness and efficiency win.
  • {#if m.family === 'qwen35'} scoping: Confirmed this only matches qwen35; will not render for ministral. LOCAL_FAMILIES allowlist in model-manager.svelte matches EXPOSED_GGUF_MODEL_IDS in chat_models.rs (ministral-8b-q4km, ornith-1-9b-q4km) — the two allowlists are kept in sync as the comment at line 267 requires.
  • Warning banner CSS: .mm-notice / .mm-notice--warn are pre-existing classes (already used at line 213 for the Ollama warning), not new/untested styling.
  • Test-input fidelity: Manually traced both new dangling-tag test cases through strip_ornith_tool_call_leak by hand:
    • Whole-block case → regex matches and removes it → "". ✅
    • Dangling case (<tool_call>... with no closing tag, followed by <|mask_end|>) → regex doesn't match (no closer) → falls through to .find("<tool_call>") → truncates to result[..0] = "" → mask_end replace is a no-op on empty string → "". ✅ Order of operations (regex-strip whole blocks first, then truncate-at-dangling-opener, then strip stray token) is correct and doesn't double-count.
    • Surrounding-text case correctly preserves prefix text before the tag. ✅

Test & Lint Results (run independently, not trusted from the diff)

  • cargo test -p nodespace-agent --lib response_processing: 31/31 passed, including all 3 new tests (strips_ornith_tool_call_leak_whole_response, strips_ornith_dangling_tool_call_and_mask_end_token, strips_ornith_tool_call_leak_keeping_surrounding_text).
  • cargo test -p nodespace-agent --lib: 251/251 passed, no regressions.
  • cargo clippy -p nodespace-agent --all-targets -- -D warnings -D clippy::unused-async: clean.
  • bun run --cwd packages/desktop-app quality:check (eslint + svelte-check): 0 errors, 0 warnings across 1702 files.

Findings

Critical Issues

None.

Suggested Improvements

1. strip_ornith_tool_call_leak truncates everything after a dangling opener, including any trailing prose the model may have emitted post-truncation
📁 packages/agent/src/local_agent/response_processing.rs:319-323

If a response were "Sure, here's the plan.<tool_call>\n<function=partial (truncated mid-generation, e.g. by the token cap) followed by, hypothetically, more legitimate prose after the truncation point in some other failure mode, that trailing content would also be silently discarded since result[..idx] drops everything from the dangling <tool_call> onward. In practice this is very unlikely (a truncated tag is definitionally at the end of a token-capped generation, so there's nothing meaningful after it), and the three tests correctly cover the realistic shapes. Not a blocker — just worth a one-line comment noting the assumption ("dangling tags are always trailing, since truncation happens at generation's end") so a future reader doesn't need to re-derive it.

2. Live-model verification is explicitly deferred, not yet done
📁 Whole commit

Per the task instructions, this fix has only been validated against captured/replayed transcript text in unit tests, not against a live Ornith inference run reproducing the original leak end-to-end. This is a reasonable and disclosed sequencing choice (unit tests against exact repro text give high confidence), but it should remain an open item until confirmed live — flagging per the author's own stated plan to do this next, not as something blocking this commit's quality.

Nitpicks

  • Nit: packages/agent/src/local_agent/model_manager.rs doc comment — the phrase "an open, unresolved limitation affecting all Qwen 3.5-based hybrid models" is a slightly stronger claim than "these five specific upstream issues, which appear to affect Qwen 3.5-based hybrid models" — the upstream issue numbers themselves weren't re-verified in this review pass (per the task's explicit instruction to trust them), so if any of the 5 have since been closed/fixed upstream, the comment would go stale silently. Not asking for a change now — just noting this comment has a shelf life and isn't self-updating if upstream resolves the issue.
  • Nit: chat_models.rs:224 — EXPOSED_GGUF_MODEL_IDS and model-manager.svelte's LOCAL_FAMILIES are two independent allowlists on two sides of the Tauri boundary that must be kept in sync by convention/comment rather than by a single shared source of truth. This is a pre-existing pattern (not introduced by this commit) and the comments on both sides now correctly cross-reference each other, which is the right mitigation given the architecture — just flagging that a future third model addition needs to remember to touch both files, as this commit did.

Security

No concerns. The <tool_call>/<|mask_end|> stripping operates on trusted local-model output (not attacker-controlled input), fails safe (falls through to a tool-summary synthesis rather than crashing or leaking raw text), and the HF URL correction was independently verified to resolve to the intended artifact via HTTP HEAD before being trusted. No secrets, no new network surface, no auth/authz surface touched.

Performance

No concerns. Regex is linear-time and non-catastrophic (verified above). The normalize_response de-duplication in agent_loop.rs is a minor net performance improvement (removes a redundant second normalization pass in the non-empty branch).

Testing

Adequate for a text-transform bugfix: 3 new unit tests cover whole-block, dangling-block+stray-token, and block-with-surrounding-text — the three realistic shapes of the leak. Verified independently (see above) that the regex/truncation/replace pipeline produces the asserted outputs by hand-tracing, not just trusting the assertions. The one acknowledged gap (live-model end-to-end verification) is explicitly called out by the author as a deferred next step, not silently skipped.

Documentation

The rewritten ORNITH_1_9B doc comment is a genuine improvement: it corrects a real factual gap (single-shot benchmark vs. multi-iteration ReAct behavior) rather than just rephrasing, cites concrete upstream issue numbers and a concrete measured number (~108s/4-iteration turn) rather than vague hand-waving, and is honest about the limitation being upstream/unfixable rather than implying it's a NodeSpace bug. The new UI warning banner text is consistent with the doc comment's technical claims (no contradiction between "gets progressively slower with each retry" in the UI copy and "every ReAct iteration re-decodes the entire growing prompt from scratch" in the Rust comment).

Recommendation: COMMENT

Net-positive, well-verified fix-up commit. All claims I could independently check (HF URL/byte count, KV-cache log string, eval methodology, regex safety, fallback-pattern parity, family-filter scoping) held up under direct verification — this is unusually well-substantiated for a commit message. No blockers. The two "Suggested Improvements" are optional polish (a defensive comment, and an explicit "verify live" follow-up already on the author's own roadmap), not required before merge. As with the prior two rounds, I'm not self-approving since this PR was authored through the same agent-driven workflow as this review — the merge call remains the user's.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of commit bb7f842 (round 3): Net positive, no blockers. Independently verified the HF URL fix (curl HEAD matches new byte count exactly), the KV-cache log string, the eval methodology claim in ornith_eval.rs, regex ReDoS-safety, and fallback-pattern parity in agent_loop.rs. All 251 nodespace-agent tests pass (incl. 3 new), clippy clean, desktop-app quality:check clean. Full findings in PR comment above. Not self-approving (same agent-driven workflow) — merge call is the user's.

- response_processing.rs: adds a one-line comment explaining why a dangling
  <tool_call> opener is safely truncated as trailing-only (truncation always
  happens at generation's end, so there's never legitimate prose after it).
- model_manager.rs: notes the ORNITH_1_9B doc comment's upstream llama.cpp
  issue citations reflect state as of 2026-07-01 and aren't self-updating —
  flags that a future reader should re-check those issues before assuming
  the KV-cache limitation still applies to a newer vendored llama.cpp.

Also live-tested the strip_ornith_tool_call_leak fix against the running
daemon: loaded Ornith via `nodespace model load`, ran two real conversation
turns through scripts/aichat.ts (a successful multi-tool turn, and a
tool-failure-recovery turn), and confirmed via `aichat.ts show` that the
persisted messages are clean — no raw <tool_call>/<|mask_end|> leakage in
either case. Neither run happened to hit the exact duplicate-tool-call-loop
tail-inference branch the fix targets (Ornith self-corrected within normal
iterations both times rather than looping), so this is strong but not
exhaustive live confirmation — combined with the 3 unit tests reproducing
the original captured leak text and the reviewer's independent hand-trace
of the strip logic, this is sufficient confidence to consider the fix
verified, but noting the caveat rather than overclaiming full coverage.

Addresses reviewer feedback from PR #1467, 3rd review round.

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

malibio commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed review feedback (3rd round)

Both suggested improvements addressed:

  • ✅ Added a one-line comment in strip_ornith_tool_call_leak explaining the dangling-tag truncation assumption (truncation always happens at generation's end, so nothing legitimate follows it).
  • ✅ Added a shelf-life note to the ORNITH_1_9B doc comment: the cited upstream llama.cpp issue numbers reflect state as of 2026-07-01 and should be re-checked before assuming the limitation still applies to a future vendored llama.cpp version.

Live verification (the explicitly-flagged open item)

Ran two real conversation turns against the running daemon with Ornith loaded (nodespace model load ornith-1-9b-q4km), via scripts/aichat.ts:

  1. A successful multi-step turn (search → update_task_status → confirm) — clean output, no leakage.
  2. A tool-failure-recovery turn (nonexistent task ID → search → clarification request) — clean output, no leakage.

Inspected persisted content directly via aichat.ts show in both cases — no raw <tool_call> XML or <|mask_end|> token in either stored message.

Caveat, stated plainly: neither run happened to trigger the exact duplicate-tool-call-loop → tail-inference branch the fix specifically targets (Ornith self-corrected within normal ReAct iterations both times rather than looping into that code path). So this is strong supporting evidence, not an exhaustive reproduction of the original failure mode. Combined with the 3 unit tests built from the exact real leaked transcript text, and the reviewer's independent hand-trace of the strip/truncate/replace logic, I'm confident in the fix — but flagging the live-repro gap rather than claiming it's fully closed.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: Both changes are documentation-only (comments), no logic changes. The live-verification work confirms (but doesn't newly risk) the already-reviewed fix.

Michael Libio and others added 3 commits July 2, 2026 11:29
Removes ornith-1-9b-q4km from EXPOSED_GGUF_MODEL_IDS. All backend plumbing
(catalog entry, download, tool-call parsing, response-leak fix) stays
merged and functional — this only controls whether it appears in the
Settings > AI Models picker. Tracked for re-enablement in #1477.

Co-Authored-By: Claude <[email protected]>
Unrelated to this branch's Ornith work — origin/main itself currently
fails `cargo clippy -D warnings` after #1469 merged (an overindented doc
comment and two clippy::trim_split_whitespace lints). Fixed here since
merging main into this branch surfaced them and blocked quality:fix.

- Doc comment: reindent wrapped continuation lines to 7 spaces (clippy's
  doc_overindented_list_items).
- Remove redundant .trim() before .split_whitespace() (the latter already
  ignores leading/trailing whitespace) in two identical exe_check closures.

No logic changes.

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

malibio commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Scope: 4th re-review, covering only the three commits since round 3 (414a71bd): 933250f4 (hide Ornith from Settings UI), 6c4f510f (merge origin/main, 6 commits incl. PR #1469), and 4b906bf4 (fix pre-existing clippy failures on main). Prior rounds (catalog entry, tool-call parsing, ThinkSplitter, HF URL fix, response-leak fix) are not re-litigated.

Net positive, no blockers. This round is entirely housekeeping around the already-approved Ornith work: a product decision to withhold the feature from users pending a known performance issue, a routine main sync, and an unrelated clippy fix picked up along the way. All three are cleanly scoped, well-explained in commit messages, and independently verified below. The highest-priority check this round — leftover conflict markers from the merge — came back clean.

Findings

Critical Issues

None found.

Suggested Improvements

None.

Nitpicks

Nit: packages/desktop-app/src/lib/components/settings/model-manager.svelte still carries LOCAL_FAMILIES = ['ministral', 'qwen35'] and a {#if m.family === 'qwen35'} slow-turn warning block, and model-store.svelte.ts still infers family: 'qwen35' for any id starting with ornith/qwen35. None of this was touched by 933250f4 (confirmed via empty diff on both files for that commit), and it's currently a harmless no-op since EXPOSED_GGUF_MODEL_IDS never returns a qwen35-family entry for the backend to surface. But it is a second, independent gate that happens to agree with the first only because nobody's touched it since round 1 — if a future PR adds a different qwen35-family model to the exposed list without reading the model-manager comment, it would inherit this dead code path (and the "multi-step tool-calling" warning copy, which is Ornith-specific in wording) without anyone intending it. The existing comment at model-manager.svelte:27-29 ("families listed here must match whatever that allowlist currently exposes") already flags this fragility for the sighted reader; a stronger option long-term would be deriving LOCAL_FAMILIES/the warning condition from the same source of truth as EXPOSED_GGUF_MODEL_IDS rather than two hand-synced lists, but this isn't new debt introduced by this PR's commits and isn't worth blocking a hide-behind-a-flag change over.

Nit: packages/desktop-app/src-tauri/src/commands/chat_models.rs's updated doc comment says "Re-add it here once #1477 is resolved" — good cross-reference. Worth noting for whoever picks up #1477 that re-adding the id alone is sufficient (the frontend filters above already accept it), so the fix there should stay purely backend-side unless the UX warning copy also needs to change.

Verification

  • Conflict markers (highest priority this round): git grep -n "^<<<<<<<\|^=======\|^>>>>>>>" across the entire worktree → zero hits. Merge is clean.
  • 933250f4 diff: EXPOSED_GGUF_MODEL_IDS now &["ministral-8b-q4km"] only; doc comment clearly explains the SSM/KV-cache-reuse rationale and references #1477 and the ORNITH_1_9B doc comment in model_manager.rs. Confirmed model-store.svelte.ts and model-manager.svelte have an empty diff for this commit — the qwen35-family frontend filters are pre-existing, not new redundant gating added here (see nitpick above for the forward-looking fragility note).
  • Merge commit 6c4f510f: pulls 6 commits from origin/main including PR Daemon lifecycle: dev worktrees, production app, and Pro/community builds collide on shared launchd service + socket #1469 (daemon lifecycle fix). Confirmed via gh pr view 1469 that Daemon lifecycle: dev worktrees, production app, and Pro/community builds collide on shared launchd service + socket #1469 has an identical title to issue Daemon lifecycle: dev worktrees, production app, and Pro/community builds collide on shared launchd service + socket #1468 and its body states "Closes Daemon lifecycle: dev worktrees, production app, and Pro/community builds collide on shared launchd service + socket #1468" — direct fix, not an overlapping/duplicate effort.
    • Ornith survival spot checks, all confirmed present post-merge:
      • strip_ornith_tool_call_leak at packages/agent/src/local_agent/response_processing.rs:314 (registered at 107-108).
      • Corrected HF URL https://huggingface.co/deepreinforce-ai/Ornith-1.0-9B-GGUF/resolve/main/ornith-1.0-9b-Q4_K_M.gguf at packages/agent/src/local_agent/model_manager.rs:188.
      • packages/agent/src/local_agent/agent_loop.rs retains the normalized_tail/normalize_response(&tail_text) empty-after-stripping fallback logic from bb7f842e (lines 871-898) — this file's Ornith-motivated change never mentions "ornith" literally in the diff (it's generic tail-inference logic), which is why the direct grep came back empty; confirmed by re-reading the original bb7f842e diff and matching it against current content.
  • 4b906bf4 diff (daemon_setup.rs, pre-existing main breakage unrelated to this PR's Ornith work):
    • .trim() removal: reasoned through and empirically verified with a standalone Rust program across representative inputs (empty string, whitespace-only, leading/trailing spaces/tabs/newlines, internal multi-whitespace) — x.split_whitespace().next() and x.trim().split_whitespace().next() produced identical results in every case. This holds generally: split_whitespace() splits on runs of whitespace and discards empty leading/trailing fragments by construction, so a preceding .trim() cannot change its output. Behavior-neutral, confirmed.
    • Doc comment reindentation: read both versions directly. Old continuation lines were indented 14 spaces (past the - macOS: marker's own content column), which is overindented relative to CommonMark/rustdoc list-continuation rules and risked breaking out of the - macOS: list item into its own indented block. New version indents continuation lines to 8 spaces, exactly aligned with where "macOS:" text begins after the - marker — correct sub-bullet continuation, stays part of the same list item. Confirmed not a regression to sibling-bullet or plain-paragraph rendering.
  • cargo clippy --all-targets -- -D warnings -D clippy::unused-async (full workspace): clean, no warnings.
  • cargo test -p nodespace-agent --lib: 251 passed, 0 failed.
  • cargo test -p nodespace-app --lib: 30 passed, 0 failed.
  • bun run --cwd packages/desktop-app quality:check: 0 errors, 0 warnings (eslint + svelte-check on 1711 files).
  • Working tree: clean (git status --short empty), HEAD confirmed at 4b906bf4.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4th re-review of commits since round 3 (933250f hide-Ornith, merge from main incl. PR #1469, 4b906bf pre-existing clippy fix). Net positive, no blockers. Verified zero leftover conflict markers workspace-wide, Ornith fixes from prior rounds survived the merge intact, the .trim()/split_whitespace and doc-comment reindent changes are behavior-neutral (reasoned + empirically checked). clippy clean, nodespace-agent 251/251, nodespace-app 30/30, quality:check clean. One forward-looking nitpick about dual-gating fragility in the frontend qwen35 filters (pre-existing, not new). Full report in PR comment above.

@malibio
malibio merged commit 462a2a1 into main Jul 2, 2026
@malibio
malibio deleted the worktree-issue-1465-ornith-model branch July 2, 2026 10:31
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.

Add Ornith 1.0 to model catalog (catalog entry, think-block routing, update_node prompt)

1 participant