Skip to content

Delete the duplicated fallback system prompt once PromptAssembler is the only prompt path - #1334

Merged
malibio merged 1 commit into
mainfrom
worktree-issue-1327-delete-fallback-prompt
Jun 5, 2026
Merged

malibio merged 1 commit into
mainfrom
worktree-issue-1327-delete-fallback-prompt

Conversation

@malibio

@malibio malibio commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #1327

… prompt path (closes #1327)

Production inference always wires a `PromptAssembler` (daemon `replace_engine`
→ `new_with_assembler`). The only `None`-assembler path is the daemon's no-op/idle
service, whose `NoOpInferenceEngine` returns `NoModelLoaded` before any inference
runs — so the inline `fallback_system_prompt()` was dead-but-drifting duplication
of the graph-seeded TOOL STRATEGY / RESPONSE RULES.

- Delete `fallback_system_prompt()` and its inline rule duplication from
  `prompt_templates.rs`, plus the three tests asserting on it.
- Make `EMERGENCY_FALLBACK_PROMPT` (`prompt_assembler.rs`) `pub(crate)` and use it
  for the agent loop's non-assembler branch — the genuine safety net, not a
  duplicate of the seeded rules.
- Update doc comments referencing the removed function.

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

malibio commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review — PR #1334

Review Type: Initial Review

Requirements Check (Issue #1327)

  • ✅ Verified production inference always uses PromptAssembler — local_agent_service.rs:140-166 (replace_engine) constructs every live engine via new_with_assembler(...) with a real PromptAssembler::new(node_service). The only None-assembler constructor is build_noop_service (:125-134), which pairs LocalAgentService::new(...) with NoOpInferenceEngine whose generate() returns Err(InferenceError::NoModelLoaded) before any inference runs (:52-58). The None branch in agent_loop.rs:185-186 therefore cannot reach live inference.
  • ✅ fallback_system_prompt() and its inline TOOL STRATEGY / RESPONSE RULES duplication deleted — prompt_templates.rs. grep -rn "fallback_system_prompt" packages/ --include="*.rs" returns nothing.
  • ✅ Minimal EMERGENCY_FALLBACK_PROMPT retained — prompt_assembler.rs:52, still serving the corrupted/empty-DB safety net at :93.
  • ✅ Tests asserting on fallback_system_prompt removed — the three tests deleted; remaining prompt_templates/prompt_assembler tests pass (13 passed, 0 failed).
  • ✅ bun run quality:fix — cargo build -p nodespace-agent clean, no warnings.
  • ✅ Tests pass — cargo test -p nodespace-agent prompt: 13 passed, 0 failed.

📝 All six acceptance criteria met.

Code Review Findings

No critical, important, or blocking issues.

Architecture & correctness — The change correctly collapses a known, documented duplication. The selection order (test override → assembler → emergency) is preserved; only the final arm changed from a content-duplicating function to the canonical EMERGENCY_FALLBACK_PROMPT. This eliminates the drift risk the issue identified: TOOL STRATEGY / RESPONSE RULES now live in exactly one place (graph-seeded prompt nodes), satisfying DRY and Single Source of Truth. Greenfield project standards (no users, delete-don't-deprecate) make outright deletion the correct call — no shims, no #[deprecated], no #[allow(dead_code)] introduced.

Visibility choice — 🟢 EMERGENCY_FALLBACK_PROMPT promoted from private const to pub(crate) (prompt_assembler.rs:52). Appropriate: the sole new consumer (agent_loop.rs) is in the same agent crate, so pub(crate) is the minimal sufficient exposure — correctly avoids over-exposing as pub. Least-privilege respected.

Behavioral note (non-blocking) — 🟢 The emergency arm now drops dynamic_ctx (workspace context) from the prompt, whereas the deleted fallback_system_prompt(dynamic_ctx) interpolated it. This is correct and intentional: the only caller of this arm is the NoOp/idle service, where generate() errors before the prompt is consumed, so the content is inert. Worth keeping in mind only if a future non-NoOp engine were ever paired with a None assembler — but that combination doesn't exist in the codebase and would be the wrong wiring regardless.

Documentation — 🟢 Doc comments updated consistently across all three files (module doc in prompt_templates.rs, the const doc in prompt_assembler.rs:48-51, and the two inline/method comments in agent_loop.rs:173-177 and :828-831). The new comments accurately describe the post-change reality and explain why the arm exists (the no-op path) rather than just what it does. No stale references to the removed function remain.

Nitpicks

  • 🟢 Nit: prompt_assembler.rs:48-51 — the const doc now carries two distinct rationales ("corrupted/empty databases" and "agent loop when no PromptAssembler is wired"). Reads fine as-is; if it grows further, a two-bullet form would scan slightly better. Optional.

Recommendation: APPROVE

Net-positive, atomic change that removes acknowledged technical debt with zero behavioral risk to live inference. The correctness-critical claim (the None arm never reaches real inference) is verified end-to-end through the daemon wiring. Tests and build are green.

🤖 Generated with Claude Code

@malibio
malibio merged commit c578a93 into main Jun 5, 2026
@malibio
malibio deleted the worktree-issue-1327-delete-fallback-prompt branch June 5, 2026 14:54
malibio added a commit that referenced this pull request Jun 22, 2026
… prompt path (closes #1327) (#1334)

Production inference always wires a `PromptAssembler` (daemon `replace_engine`
→ `new_with_assembler`). The only `None`-assembler path is the daemon's no-op/idle
service, whose `NoOpInferenceEngine` returns `NoModelLoaded` before any inference
runs — so the inline `fallback_system_prompt()` was dead-but-drifting duplication
of the graph-seeded TOOL STRATEGY / RESPONSE RULES.

- Delete `fallback_system_prompt()` and its inline rule duplication from
  `prompt_templates.rs`, plus the three tests asserting on it.
- Make `EMERGENCY_FALLBACK_PROMPT` (`prompt_assembler.rs`) `pub(crate)` and use it
  for the agent loop's non-assembler branch — the genuine safety net, not a
  duplicate of the seeded rules.
- Update doc comments referencing the removed function.

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.

Delete the duplicated fallback system prompt once PromptAssembler is the only prompt path

1 participant