Skip to content

Remove parentId and collectionId from node wire response - #1322

Merged
malibio merged 3 commits into
mainfrom
worktree-issue-1318-remove-parentid-collectionid-wire
Jun 4, 2026
Merged

malibio merged 3 commits into
mainfrom
worktree-issue-1318-remove-parentid-collectionid-wire

Conversation

@malibio

@malibio malibio commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Closes #1318

- Drop optional string parent_id = 4 and string collection_id = 10 from
  NodeData proto message; reserve field numbers 4 and 10 for safety
- Remove parent_id and collection_id from NodeResponse proto message
- Simplify node_to_proto() to take only Node (no projection args)
- Update all callers in node_service.rs and embeddings_service.rs
- Update CLI output.rs to drop parent/collection fields from human and
  JSON output (hierarchy is relationship-derived via GetChildren)
- Update tests to verify collection membership via GetNodeCollections
  instead of reading the removed NodeResponse.collection_id field
- Document wire contract in data-layer.md serialization section

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

malibio commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review — PR #1322: Remove parentId and collectionId from node wire response

Overall Assessment: This is a clean, well-scoped removal. The architectural motivation is sound — relationship-derived projections have no business living on the node wire representation. The diff is consistently executed across all call sites and the test strategy (verifying membership via the dedicated collection API rather than the removed field) is the right approach. Recommend approval with one minor cleanup nit — no blockers.


Acceptance Criteria Verification

Criterion Status
NodeData proto no longer includes parent_id / collection_id fields Met — both removed; field numbers 4 and 10 reserved in both NodeData and NodeResponse
node_to_proto() no longer fetches or injects parent/collection Met — signature simplified to fn node_to_proto(node: Node) -> NodeData; all ~15 call sites updated to point-free map(node_to_proto) style
All clients continue to work correctly Met — Tauri commands never read these fields from responses (they use node_id return values and dedicated APIs); no frontend TS code reads node.parentId / node.collectionId from fetched nodes
data-layer.md serialization contract updated Met — committed separately in nodespace-docs (57f4d49); line 108 now explicitly documents the wire field list and states these two fields are absent

Findings

Suggested Improvements

packages/daemon/src/services/node_service.rs, line 93–107 — Redundant .clone()

parent_id_opt.clone() was originally necessary because parent_id_opt was consumed twice: once into CreateNodeInput and once into the NodeResponse field. The NodeResponse consumer is now gone, so the .clone() is dead weight. The field can be moved directly:

// Before
let parent_id_opt = req.parent_id;
...
parent_id: parent_id_opt.clone(),

// After
parent_id: req.parent_id,

Removing the intermediate variable and the clone simplifies the code and eliminates a unnecessary heap allocation, per YAGNI. Rust's borrow checker will surface this if the project ever enables the clippy::redundant_clone lint.


Nitpicks

packages/daemon/src/services/node_service.rs, line 1549 — Mixed assertion styles in parity test

The test verifies ops_output.collection_id.is_some() (the ops-layer output struct, not the wire response), which is correct and appropriate — this is testing the ops layer's own return contract, not the wire format. However, the comment above (// Both nodes should be in a collection and have lifecycle_status=archived) could be slightly tighter: the RPC-path assertion now goes through CollectionService while the ops-path assertion uses the output struct directly. The asymmetry is fine functionally, but a one-line comment acknowledging it would help the next reader.

packages/proto/proto/node_service.proto, line 207–210 — NodeListResponse.collection_id is retained (correct but worth a comment)

NodeListResponse.collection_id is a response-level filter echo (which collection was queried), not a per-node membership field — it is legitimately kept. This is architecturally distinct from the per-node NodeData.collection_id that was removed. The existing comment // empty string when not filtered by collection documents this adequately, but it could explicitly state "this echoes the collection filter from the request, not per-node membership" to prevent future confusion with the removed fields.


What Is Correct and Noteworthy

  • reserved statements are correct. Both number and name reservations are present on both NodeData (fields 4, 10) and NodeResponse (fields 3, 4). This is the right proto hygiene for a project that serializes to disk or crosses process boundaries, even in greenfield development.

  • Test strategy is correct. Replacing assert!(!rpc_resp.collection_id.is_empty()) with coll_svc.get_node_collections() is the principled approach — it tests the actual invariant (membership is stored in the relationship layer) rather than a projection artifact.

  • No frontend regression. The grep confirms the Svelte frontend already managed hierarchy through ReactiveStructureTree (populated from relationship events) and never read node.parentId/node.collectionId from fetched node objects. The collectionId?: string field remaining in CollectionPathSegment (node.ts:353) is unrelated — it's a local UI parse-assist field, not a wire type.

  • NodeListResponse.collection_id correctly retained. The list-level field echoes the collection filter applied to a search/member query; it is response metadata, not per-node data. Keeping it is correct.

  • lib.rs formatting change (the resolve_db_path formatting) is a drive-by cargo fmt cleanup, not functional — acceptable in this PR.

@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 complete — see inline comment above. No blockers found; one nit on the redundant .clone() in create_node.

Michael Libio and others added 2 commits June 4, 2026 13:46
The intermediate variable and clone were only needed when
NodeResponse.parent_id still existed. Move req.parent_id directly.

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

- Proto: expand NodeListResponse.collection_id comment to make clear it
  echoes the collection filter from the request (response-level metadata),
  not per-node membership data — distinct from the removed NodeData fields
- Test: add comment on ops_output.collection_id assertion to distinguish
  it from the wire-level assertion above (ops layer vs. wire response)

Co-Authored-By: Claude <[email protected]>
@malibio
malibio merged commit 5e03d14 into main Jun 4, 2026
@malibio
malibio deleted the worktree-issue-1318-remove-parentid-collectionid-wire branch June 4, 2026 14:24
malibio added a commit that referenced this pull request Jun 5, 2026
…une prompts (#1331)

* WIP: ai-chat agent quality — embedding/tool-call fixes + CLI test harness

## Completed in This Session
- [x] Fix release-build compile error on main: node_to_proto(node.clone(), None, None)
      → 1-arg call in packages/daemon/src/services/node_service.rs (leftover from #1322).
- [x] Fix embedding_service:None production bug: GraphToolExecutor in
      local_agent_service.rs replace_engine was built with embedding_service:None,
      so search_semantic ALWAYS errored and skill-based select_tools routing was
      bypassed (full 13-tool list always sent). Now reads inner.embedding_service.
      Durable fix tracked in #1328.
- [x] Add tool_calls to ChatMessage (agent_types.rs) + ChatMessageInput
      (nlp-engine/chat/types.rs, new ToolCallInput), populate in agent_loop when
      the assistant issues tool calls, plumb into apply_chat_template's messages
      JSON so the assistant turn emits OpenAI-format tool_calls (was dropping them
      → orphan tool result in re-prompt history). Added ChatMessage constructors
      (text / assistant_with_tool_calls / tool_result).
- [x] New CLI subcommand `nodespace model {list|load|recommended}` (cli/commands/model.rs)
      — the CLI had no way to load a model; required for headless prompt testing.
- [x] New bun harness `bun run chat {new|send <id> <msg>|ask <msg>|show <id>}`
      (scripts/aichat.ts) — drives an ai-chat node end-to-end via the CLI, no UI,
      against a throwaway test daemon (/tmp/nodespaced-test).
- [x] Filed 4 parallel tech-debt issues: #1325 (unify ChatMessage/ChatMessageInput),
      #1326 (single tool registry), #1327 (delete duplicated fallback prompt),
      #1328 (embedding service wired by construction).

## Root Cause Found (NOT yet fixed) — the hang/runaway
On a greeting ("Hi there"), Gemma-4-E4B emits chatty prose AND a needless
search_semantic call in the SAME turn. On re-prompt, Gemma's chat template
collapses tool_call + tool_response + the greeting into ONE malformed `model`
turn, then opens a fresh empty `model` turn. With nothing to say and no token
cap, the model runs away to max_tokens=16384 (multi-minute hang → "no reply").
Verified by logging the full templated prompt (temp logging since removed).

## Remaining Work (user wants ALL three)
1. max_tokens safety cap: agent_loop.rs has max_tokens: Some(16384) at two
   InferenceRequest sites — lower to ~2048 so any runaway is bounded to seconds.
2. Prompt/skill tuning (live in DB, then backport to seed_prompt_nodes() in
   prompt_assembler.rs + skill seeds in skill_pipeline.rs): conversational turns
   skip tools; empty tool result → answer directly, never retry; less verbosity;
   "create an invoice tracking database" → create_schema. Build a fuller scenario
   matrix (create several custom node types via NL + CRUD against them).
3. Turn-structure fix: stop sending chatty assistant prose alongside tool calls
   so the template stops collapsing the turn. Deeper agent_loop surgery.

## Current State
- Files modified: agent_types.rs, agent_loop.rs, inference.rs, ollama_integration.rs,
  local_agent_service.rs, node_service.rs, nlp-engine chat/{mod,types}.rs + lib.rs,
  cli lib.rs/commands/{mod,model}.rs, package.json, scripts/aichat.ts.
- Builds: cargo check + release build of daemon/cli pass. NOT yet run: test:all, quality:fix (clippy).
- Tests status: not yet run (WIP checkpoint).
- The embedding + tool_calls fixes are verified working at runtime (search_semantic
  now succeeds, find_skills runs); the runaway is the open problem.

## Context for Next Session
Resume the test loop per memory note project-aichat-prompting-session-handoff (how
to start a fresh test daemon on /tmp/nodespaced-test, load gemma-4-e4b-q4km via the
new `model` CLI command, and drive `bun run chat`). Do the 3 remaining items, then
run test:all + quality:fix, and open the PR. Eval-system + model-capability-guardrails
issues still to be filed (see memory).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Fix ai-chat runaway/hang + tool-call template leaks; tune agent prompts

Removes the infrastructure-level failure modes in the local ai-chat agent
loop that were independent of model size, and tunes the seeded prompts/skills.

Loop & sampling:
- Cap any single inference round at MAX_RESPONSE_TOKENS=2048 (was 16384), so a
  runaway is bounded to seconds instead of a multi-minute hang.
- Add a repetition penalty to the sampler chain
  (LlamaSampler::penalties(256, 1.3, 0, 0) before temp) — kills the degenerate
  loops small models fall into at near-greedy temperature (e.g. repeating a
  closing phrase until max_tokens).
- Persist assistant tool-call turns with empty content (drop chatty prose) so
  the Gemma chat template stops collapsing prose+call+result into one
  malformed turn.

Chat template (fixes ffi error -3 turn abort introduced by the empty-content
change above):
- Emit content:null (not "") for assistant tool-call turns — the shape the
  OAI-compat path expects.
- Normalize non-object tool-call arguments to "{}" so a malformed/empty tool
  call never feeds invalid JSON into the Jinja template.

Response normalization (all tested):
- Strip leaked Gemma tool-call/response prose (call:foo{...}response:foo{...},
  nested braces handled).
- Strip Gemma channel/thought reasoning blocks (<|channel>...<channel|>, plus
  dangling-opener and stray-marker variants). Reasoning capture/display is
  tracked separately in #1330.
- Add <|channel>/<channel|> to strip_gemma_special_tokens for defense in depth.

Prompt/skill tuning (seeds re-seed a fresh DB, equivalent to live-editing):
- agent_guidance.rs: add "DATABASE = SCHEMA" routing rule (so
  "create an invoice tracking database" → create_schema) and a loud
  "conversational turns use NO tools" rule; byte-lock tests updated.
- prompt_assembler.rs Response Rules: 1-2 sentences; empty/error tool result →
  state and stop, no retry, no compensating tool.
- skill_pipeline.rs Schema Creation: "ONE SCHEMA PER REQUEST" — no proactive
  related-type creation.

Remaining capability-bound behavior (E4B calls tools on conversational turns,
keeps iterating after a complete answer, emits unmarked bare-"thought"
narration) is tracked for the 12B A/B in #1329.

Tests: agent 232, nlp-engine 61, core 890, frontend 3841, skill 17 — all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Address review: protect tool-turn pairing in summarization; capture stranded DB prompt edit

Code review (PR #1331) findings:

🟡 maybe_summarize_history could split an assistant tool-call turn from its
   tool results — the naive "keep last 3" drain can leave the kept window
   starting with an orphan Tool message, the exact malformed sequence that
   re-triggers the runaway this PR fixes. Walk the split point back past any
   leading Tool message so every tool result stays paired with its assistant
   turn. New test: summarization_never_orphans_a_tool_result.

🟡 Empty-content tool-call turns summarized to a bare "Assistant:", losing the
   signal of what the agent did. Render a synthetic "called tools: …" line from
   tool_calls when content is empty.

🟡 Documented why the summarization max_tokens (4096) intentionally differs from
   the chat-turn cap (MAX_RESPONSE_TOKENS=2048) so a future cleanup doesn't
   wrongly unify them; noted MAX_RESPONSE_TOKENS also bounds a single tool
   call's generated arguments and is sized for the largest realistic blob.

🟢 Extracted the OAI message-shaping into a pure, model-independent
   chat_message_to_oai_value() and added a direct test block covering
   empty-content→null and non-object-arguments→"{}" (the two shapings whose
   regression reintroduces the turn-aborting ffi error -3).

🟢 Corrected the tool-call-prose regex comment (two nested levels, not one;
   noted the truncated-blob fallthrough and the DFA/no-ReDoS property).

Also backports a prompt edit that was made live in the real DB and never
captured in code: the "Research & Search" skill's SEARCH FIRST guidance now
includes "Skip search for conversational messages or capability questions"
(found by diffing ~/.nodespace prompt/skill node content against the seeds).

Skipped (with reasons): the repetition-penalty A/B note is already tracked in
#1329; the content/tool_calls invariant the reviewer flagged needs no action
(the null-content branch only fires when tool_calls is non-empty).

Tests: agent 233, nlp-engine 66 — all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* chore: rustfmt events.rs (pre-existing drift)

`cargo fmt --all` (via quality:fix) repeatedly flagged a non-canonical
multi-line struct variant in db/events.rs that predates this branch. Apply the
canonical single-line form so the workspace is rustfmt-clean and a future
`cargo fmt --check` in CI won't fail on it. Formatting-only; no logic change.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Address re-review: make orphan-summarization test actually exercise the fix

Re-review (PR #1331) found the new summarization_never_orphans_a_tool_result
test was a tautology — its 3-message tail put the naive split on the assistant
tool-call turn, so the back-off loop never fired and the test passed even with
the fix removed.

- Rework the fixture: tail is now [assistant tool-call, tool, user, user] so the
  "keep last 3" window STARTS on the orphan tool result, forcing the back-off to
  run. Verified the test FAILS when the back-off loop is disabled and passes when
  present — it now genuinely guards the fix.
- Add an explicit assertion that the assistant tool-call turn was RETAINED (not
  drained), proving the back-off pulled it into the kept window.

Also addresses the two re-review nits:
- Short-circuit summarization when the back-off consumes the whole prefix
  (split_point == 0) — no model call on empty input.
- Cap each tool-call argument blob to 120 chars in the summary input (a call can
  emit up to the generation token cap of JSON; the summary only needs the gist).

Tests: agent 233 — all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
malibio added a commit that referenced this pull request Jun 22, 2026
* Remove parentId and collectionId from node wire response (closes #1318)

- Drop optional string parent_id = 4 and string collection_id = 10 from
  NodeData proto message; reserve field numbers 4 and 10 for safety
- Remove parent_id and collection_id from NodeResponse proto message
- Simplify node_to_proto() to take only Node (no projection args)
- Update all callers in node_service.rs and embeddings_service.rs
- Update CLI output.rs to drop parent/collection fields from human and
  JSON output (hierarchy is relationship-derived via GetChildren)
- Update tests to verify collection membership via GetNodeCollections
  instead of reading the removed NodeResponse.collection_id field
- Document wire contract in data-layer.md serialization section

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

* Remove dead parent_id_opt variable in create_node handler

The intermediate variable and clone were only needed when
NodeResponse.parent_id still existed. Move req.parent_id directly.

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

* Address review nits: clarify NodeListResponse.collection_id and test comment

- Proto: expand NodeListResponse.collection_id comment to make clear it
  echoes the collection filter from the request (response-level metadata),
  not per-node membership data — distinct from the removed NodeData fields
- Test: add comment on ops_output.collection_id assertion to distinguish
  it from the wire-level assertion above (ops layer vs. wire response)

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

---------

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Jun 22, 2026
…une prompts (#1331)

* WIP: ai-chat agent quality — embedding/tool-call fixes + CLI test harness

## Completed in This Session
- [x] Fix release-build compile error on main: node_to_proto(node.clone(), None, None)
      → 1-arg call in packages/daemon/src/services/node_service.rs (leftover from #1322).
- [x] Fix embedding_service:None production bug: GraphToolExecutor in
      local_agent_service.rs replace_engine was built with embedding_service:None,
      so search_semantic ALWAYS errored and skill-based select_tools routing was
      bypassed (full 13-tool list always sent). Now reads inner.embedding_service.
      Durable fix tracked in #1328.
- [x] Add tool_calls to ChatMessage (agent_types.rs) + ChatMessageInput
      (nlp-engine/chat/types.rs, new ToolCallInput), populate in agent_loop when
      the assistant issues tool calls, plumb into apply_chat_template's messages
      JSON so the assistant turn emits OpenAI-format tool_calls (was dropping them
      → orphan tool result in re-prompt history). Added ChatMessage constructors
      (text / assistant_with_tool_calls / tool_result).
- [x] New CLI subcommand `nodespace model {list|load|recommended}` (cli/commands/model.rs)
      — the CLI had no way to load a model; required for headless prompt testing.
- [x] New bun harness `bun run chat {new|send <id> <msg>|ask <msg>|show <id>}`
      (scripts/aichat.ts) — drives an ai-chat node end-to-end via the CLI, no UI,
      against a throwaway test daemon (/tmp/nodespaced-test).
- [x] Filed 4 parallel tech-debt issues: #1325 (unify ChatMessage/ChatMessageInput),
      #1326 (single tool registry), #1327 (delete duplicated fallback prompt),
      #1328 (embedding service wired by construction).

## Root Cause Found (NOT yet fixed) — the hang/runaway
On a greeting ("Hi there"), Gemma-4-E4B emits chatty prose AND a needless
search_semantic call in the SAME turn. On re-prompt, Gemma's chat template
collapses tool_call + tool_response + the greeting into ONE malformed `model`
turn, then opens a fresh empty `model` turn. With nothing to say and no token
cap, the model runs away to max_tokens=16384 (multi-minute hang → "no reply").
Verified by logging the full templated prompt (temp logging since removed).

## Remaining Work (user wants ALL three)
1. max_tokens safety cap: agent_loop.rs has max_tokens: Some(16384) at two
   InferenceRequest sites — lower to ~2048 so any runaway is bounded to seconds.
2. Prompt/skill tuning (live in DB, then backport to seed_prompt_nodes() in
   prompt_assembler.rs + skill seeds in skill_pipeline.rs): conversational turns
   skip tools; empty tool result → answer directly, never retry; less verbosity;
   "create an invoice tracking database" → create_schema. Build a fuller scenario
   matrix (create several custom node types via NL + CRUD against them).
3. Turn-structure fix: stop sending chatty assistant prose alongside tool calls
   so the template stops collapsing the turn. Deeper agent_loop surgery.

## Current State
- Files modified: agent_types.rs, agent_loop.rs, inference.rs, ollama_integration.rs,
  local_agent_service.rs, node_service.rs, nlp-engine chat/{mod,types}.rs + lib.rs,
  cli lib.rs/commands/{mod,model}.rs, package.json, scripts/aichat.ts.
- Builds: cargo check + release build of daemon/cli pass. NOT yet run: test:all, quality:fix (clippy).
- Tests status: not yet run (WIP checkpoint).
- The embedding + tool_calls fixes are verified working at runtime (search_semantic
  now succeeds, find_skills runs); the runaway is the open problem.

## Context for Next Session
Resume the test loop per memory note project-aichat-prompting-session-handoff (how
to start a fresh test daemon on /tmp/nodespaced-test, load gemma-4-e4b-q4km via the
new `model` CLI command, and drive `bun run chat`). Do the 3 remaining items, then
run test:all + quality:fix, and open the PR. Eval-system + model-capability-guardrails
issues still to be filed (see memory).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Fix ai-chat runaway/hang + tool-call template leaks; tune agent prompts

Removes the infrastructure-level failure modes in the local ai-chat agent
loop that were independent of model size, and tunes the seeded prompts/skills.

Loop & sampling:
- Cap any single inference round at MAX_RESPONSE_TOKENS=2048 (was 16384), so a
  runaway is bounded to seconds instead of a multi-minute hang.
- Add a repetition penalty to the sampler chain
  (LlamaSampler::penalties(256, 1.3, 0, 0) before temp) — kills the degenerate
  loops small models fall into at near-greedy temperature (e.g. repeating a
  closing phrase until max_tokens).
- Persist assistant tool-call turns with empty content (drop chatty prose) so
  the Gemma chat template stops collapsing prose+call+result into one
  malformed turn.

Chat template (fixes ffi error -3 turn abort introduced by the empty-content
change above):
- Emit content:null (not "") for assistant tool-call turns — the shape the
  OAI-compat path expects.
- Normalize non-object tool-call arguments to "{}" so a malformed/empty tool
  call never feeds invalid JSON into the Jinja template.

Response normalization (all tested):
- Strip leaked Gemma tool-call/response prose (call:foo{...}response:foo{...},
  nested braces handled).
- Strip Gemma channel/thought reasoning blocks (<|channel>...<channel|>, plus
  dangling-opener and stray-marker variants). Reasoning capture/display is
  tracked separately in #1330.
- Add <|channel>/<channel|> to strip_gemma_special_tokens for defense in depth.

Prompt/skill tuning (seeds re-seed a fresh DB, equivalent to live-editing):
- agent_guidance.rs: add "DATABASE = SCHEMA" routing rule (so
  "create an invoice tracking database" → create_schema) and a loud
  "conversational turns use NO tools" rule; byte-lock tests updated.
- prompt_assembler.rs Response Rules: 1-2 sentences; empty/error tool result →
  state and stop, no retry, no compensating tool.
- skill_pipeline.rs Schema Creation: "ONE SCHEMA PER REQUEST" — no proactive
  related-type creation.

Remaining capability-bound behavior (E4B calls tools on conversational turns,
keeps iterating after a complete answer, emits unmarked bare-"thought"
narration) is tracked for the 12B A/B in #1329.

Tests: agent 232, nlp-engine 61, core 890, frontend 3841, skill 17 — all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Address review: protect tool-turn pairing in summarization; capture stranded DB prompt edit

Code review (PR #1331) findings:

🟡 maybe_summarize_history could split an assistant tool-call turn from its
   tool results — the naive "keep last 3" drain can leave the kept window
   starting with an orphan Tool message, the exact malformed sequence that
   re-triggers the runaway this PR fixes. Walk the split point back past any
   leading Tool message so every tool result stays paired with its assistant
   turn. New test: summarization_never_orphans_a_tool_result.

🟡 Empty-content tool-call turns summarized to a bare "Assistant:", losing the
   signal of what the agent did. Render a synthetic "called tools: …" line from
   tool_calls when content is empty.

🟡 Documented why the summarization max_tokens (4096) intentionally differs from
   the chat-turn cap (MAX_RESPONSE_TOKENS=2048) so a future cleanup doesn't
   wrongly unify them; noted MAX_RESPONSE_TOKENS also bounds a single tool
   call's generated arguments and is sized for the largest realistic blob.

🟢 Extracted the OAI message-shaping into a pure, model-independent
   chat_message_to_oai_value() and added a direct test block covering
   empty-content→null and non-object-arguments→"{}" (the two shapings whose
   regression reintroduces the turn-aborting ffi error -3).

🟢 Corrected the tool-call-prose regex comment (two nested levels, not one;
   noted the truncated-blob fallthrough and the DFA/no-ReDoS property).

Also backports a prompt edit that was made live in the real DB and never
captured in code: the "Research & Search" skill's SEARCH FIRST guidance now
includes "Skip search for conversational messages or capability questions"
(found by diffing ~/.nodespace prompt/skill node content against the seeds).

Skipped (with reasons): the repetition-penalty A/B note is already tracked in
#1329; the content/tool_calls invariant the reviewer flagged needs no action
(the null-content branch only fires when tool_calls is non-empty).

Tests: agent 233, nlp-engine 66 — all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* chore: rustfmt events.rs (pre-existing drift)

`cargo fmt --all` (via quality:fix) repeatedly flagged a non-canonical
multi-line struct variant in db/events.rs that predates this branch. Apply the
canonical single-line form so the workspace is rustfmt-clean and a future
`cargo fmt --check` in CI won't fail on it. Formatting-only; no logic change.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Address re-review: make orphan-summarization test actually exercise the fix

Re-review (PR #1331) found the new summarization_never_orphans_a_tool_result
test was a tautology — its 3-message tail put the naive split on the assistant
tool-call turn, so the back-off loop never fired and the test passed even with
the fix removed.

- Rework the fixture: tail is now [assistant tool-call, tool, user, user] so the
  "keep last 3" window STARTS on the orphan tool result, forcing the back-off to
  run. Verified the test FAILS when the back-off loop is disabled and passes when
  present — it now genuinely guards the fix.
- Add an explicit assertion that the assistant tool-call turn was RETAINED (not
  drained), proving the back-off pulled it into the kept window.

Also addresses the two re-review nits:
- Short-circuit summarization when the back-off consumes the whole prefix
  (split_point == 0) — no model call on empty input.
- Cap each tool-call argument blob to 120 chars in the summary input (a call can
  emit up to the generation token cap of JSON; the summary only needs the gist).

Tests: agent 233 — all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[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.

Remove parentId and collectionId from node wire response

1 participant