Repository navigation
Description
Split out of #1917 (checkpoints 8-9) — genuinely separate scope from the 8a/8c/8e retrieval-merge work also in that issue: distinct mechanism, distinct call path, needs its own fix-and-verify cycle.
What happens
Agent-matrix scenario 6 ("The 2400 one came back — set it to returned", following schema + instance creation in the same chat) fails deterministically: the model asks the user for a literal node ID instead of calling resolve_query, e.g.:
"I need the ID of the laser cutter you are referring to in order to update its status. Could you please provide it?"
resolve_query IS offered as a tool (confirmed via agent_loop's own tool_names= log line), but its required parameter (node_type) has nothing to resolve against: the RELEVANT ENTITY TYPES block never appears anywhere in the prompt for this turn.
Root cause, confirmed directly (not inferred)
Traced through every step of the pipeline with direct log instrumentation, ruling out three hypotheses before finding the real one:
- NOT a history-blending gap.
context_ops::build_retrieval_query's 2-turn blend produces the correct query, containing "equipment" implicitly via the surrounding turns. - NOT a retrieval failure. Directly captured
context_ops.rs's own debug log:One schema (the just-createdworkspace_context: semantic schema retrieval count=1 query="Log a laser cutter checked out on the 12th, replacement cost 2400\nYou have logged a laser cutter with a replacement cost of 2400.\nThe 2400 one came back — set it to returned"equipmenttype) IS retrieved. - NOT a formatting bug. Read
WorkspaceContext::format_for_prompt(context_ops.rs:380) end to end — renders the header wheneverrelevant_schemasis non-empty, well under its 4000-char budget for one schema. No bug found on inspection. - NOT an ordering/race issue between
set_session_contextand the read.local_agent_service.rs'srun_ai_chat_turncomputesctx, awaitscreate_session, then awaitsset_session_contextwith the same returnedsession_id, sequentially, beforesend_messageis called. No race.
Added a temporary diagnostic log at the actual read point (agent_loop.rs:775, where tools_with_available_guidance consumes session.dynamic_context) and confirmed directly:
dynamic_ctx_len=0
So: retrieval succeeds (count=1), formatting should produce a non-empty string, but session.dynamic_context is empty at the point the guidance gate reads it, in the same turn. Every individual link in the chain looks correct on inspection; the break is somewhere in composition, not in any single function traced so far. (Diagnostic log has been reverted — not left in the codebase.)
Reproduction
turn 1: "I want to keep a record of the equipment my team checks out, whether it's been returned, and what each item costs to replace" -> create_schema
turn 2: "Log a laser cutter checked out on the 12th, replacement cost 2400" -> create_node
turn 3: "The 2400 one came back — set it to returned" -> FAILS: asks for a literal ID instead of calling resolve_query
Fails 0/3 in every arm measured in #1917 (main, concat, dual, append-only) — untouched by any of that issue's retrieval-merge changes, confirming this is a wholly separate mechanism.
Suggested next step
The next concrete, untested link: verify whether ctx (the Result<String, ()> computed in local_agent_service.rs::run_ai_chat_turn) is actually Ok with non-empty content at the point if let Ok(ctx_str) = ctx { service.set_session_context(...) } runs — i.e. confirm the value going INTO set_session_context, not just the formatting logic in isolation. If that is also non-empty, the gap is inside set_session_context/AgentSession storage itself (an Arc/lock/session-id mismatch) rather than upstream.
Acceptance criteria
- Root cause identified with certainty (not just narrowed)
- Fix verified against a direct reproduction (not just the matrix, though the matrix should also be re-run)
- Full matrix run (3+ reps) before merge per Autonomous goal: drive local-agent matrix reliability to 10/12+ without turn-by-turn relay #1917's standing rule — this touches the workspace-context plumbing every turn relies on, not just scenario 6
- Scenario 6 passes reliably across multiple runs
Reference
- Autonomous goal: drive local-agent matrix reliability to 10/12+ without turn-by-turn relay #1917 checkpoints 8-9 — the investigation this was split from, full trace evidence
- ADR-064 rule 4 (tool results own facts) and rule 3 (skill descriptions own retrieval) are NOT implicated here — this is neither; it is the workspace-context injection path, a fourth mechanism not covered by either doctrine rule directly.
Activity
malibio commentedon Aug 2, 2026
Correction and tightening of the root-cause finding, with a self-caught measurement error along the way
Continued investigating after filing. One important correction to how I verify this kind of finding going forward, plus a materially tighter confirmed defect.
A measurement error I caught and want on record
Re-ran the diagnostic with the write-side (
local_agent_service.rs, right beforeset_session_context) and read-side (agent_loop.rs:775) instrumented simultaneously. First pass appeared to showctx_len=163at write anddynamic_ctx_len2=163at read — i.e. looked like the bug didn't reproduce. That was wrong: I was matching log lines positionally, and a stale line from an earlier turn in the same reused daemon log file got attributed to the wrong turn. Re-checked by matching onsession_idexplicitly (added it to both diagnostic lines) rather than trusting occurrence order, and got the real answer.Confirmed, with
session_idmatched precisely across both diagnostic points in one clean runThis is tighter than the original finding. It is not "the context is empty" in general — turns 1 and 2 both round-trip correctly (write and implied read consistent). It is specifically: on the turn scenario 6 exercises,
set_session_contextis called with 163 non-empty chars for sessiond58c2745, and the SAME session_id reads back empty moments later in the same turn. Write succeeds, read of the identical id in the identical turn does not see it.What I ruled out this pass, with evidence
Arccloning issue.AgentService = Arc<LocalAgentService<...>>—get_service().clone()clones theArc, not the underlyingsessions: RwLock<HashMap>. Same shared state throughout.run_ai_chat_turnitself runs inside onetokio::spawn(its caller), but within that task,ctxcompute →create_session→set_session_context→send_messageare all sequentially.awaited with no nested spawn in between.set_session_context's own body (sessions.write().await; get_mut(session_id)) is trivially correct if the id matches — and I've now confirmed the id DOES match between write and read.Where this leaves it
I do not have a confirmed mechanism for how the same
session_id's write is invisible to a same-turn read a few hundred milliseconds later, only turns 1/2/3's session-scoped behavior working differently despite structurally identical code paths. My best remaining unverified guess: something aboutsend_message'ssessions.remove(session_id)/ re-insertpattern (agent_loop.rs"Take session out for mutation, put it back after") interacting with a second concurrent turn or a retry for the same node — I have not checked whether scenario 6 legitimately runs as a singlerun_ai_chat_turninvocation or whether something (a duplicate trigger, a retried send) creates two. That's the next concrete thing to check, and I did not get to it.All diagnostic instrumentation added this pass has been reverted; tree is clean; no fix attempted. This updates the issue's evidence with a more precise, correctly-attributed reproduction, and flags the risk of session-log misattribution for whoever continues — match on
session_id, not log-line order, when correlating write/read diagnostics in this codebase, especially across a reused daemon process serving multiple turns.malibio commentedon Aug 2, 2026
Final correction: the plumbing is NOT broken. Both prior findings (checkpoints on #1917, and my first comment here) were measurement artifacts. This is a prompt-following failure, not a data-loss bug.
Ran the write-side and read-side diagnostics together, in one build, correlated by
session_id, closing the gap the previous two attempts each left open (the first mismatched log lines from a reused daemon file; the second still hadn't run write+read in the same build).Result: write and read agree, every turn, including scenario 6's
Same value, same session, correctly propagated. The
RELEVANT ENTITY TYPESblock — 163 chars, the equipment schema — reachessession.dynamic_contextand is present exactly wheretools_with_available_guidancereads it.resolve_query's reachability gate is satisfied correctly. This directly contradicts my two earlierlen=0findings on this issue, both now understood as self-inflicted measurement error (the first: stale log-line misattribution across turns in a reused daemon process; not fully isolated the second time either, since I hadn't yet run both diagnostics in the same build/session simultaneously).And the model still asked for a literal ID anyway. Same failure, same reproduction, but now with confirmed-correct inputs.
What this actually is
Not a context-plumbing bug.
resolve_queryis offered, itsnode_typeparameter is answerable (a real entity type is listed), the tool description already covers this exact case ("" — a bare value, no field named — is its own lead example), and Graph Editing's skill instructions already say to call it for this shape of request. The model has everything it needs and doesn't use it. This is a genuine model-behavior / prompt-following gap (ADR-064 rule 2 territory — tool selection), not a rule-4 or rule-3 problem, and not a data bug at all.Retracting the fix direction this issue originally suggested
The "verify
ctx's value going intoset_session_context" step from the original filing is now answered: it's correct, and always was on the turns that matter. Recommend closing the "reachability gate" framing of this issue and re-scoping to: why does the model, given a correctly-populated entity-types block and an on-point tool description, still default to asking the user for an ID instead of callingresolve_query? That is closer to the guidance-ordering hypothesis I tried first (checkpoint on #1917) and abandoned after one inconclusive rep — worth a properly repeated (3+) trial rather than the single rep I gave it, now that the "maybe it's actually a plumbing bug" distraction is closed out.All diagnostic instrumentation reverted across every attempt on this issue. Tree clean. No fix implemented;
mainunmodified.malibio commentedon Aug 2, 2026
Guidance-ordering hypothesis properly refuted: 3/3 reps, deterministic failure, reverted
Followed through on the recommendation from my previous comment — ran the guidance reorder (INDIRECT TARGET moved first, explicit "never ask the user for an ID" clause added) as a real 3-rep trial this time, not the single inconclusive rep from the earlier attempt on #1917.
3/3, deterministic. Guidance ordering is not the mechanism. Reverted; tree confirmed clean;
mainunmodified.Where this leaves scenario 6
Two structural fixes now properly ruled out with real evidence:
The tool is offered, correctly described, backed by correct context, and instructed to be used for exactly this phrasing — and the model still doesn't call it. This has moved from "looks like a plumbing bug" to "looks like a genuine model-capability/attention limit on this locked model" (gemma-4-e4b-q4km), which is a different class of problem than anything else fixed in this cluster so far (#1846-#1904's fixes were all either plumbing bugs or retrieval/description issues, not "the model ignores correct, present instructions").
Consistent with #1917's own explicit out-of-scope note: fine-tuning is deferred until remaining failures are shown to be judgment/comprehension failures rather than delivery/architecture failures. This may be the first scenario in the whole cluster where that condition is actually met — worth flagging explicitly rather than continuing to chase prompt-level fixes for it.
malibio commentedon Aug 2, 2026
Fresh angle: scenario 6 is TWO defects, not one. Found and fixed a real code bug; sharpened the remaining model-behavior failure to a single reproducible variable (conversation history), which no prompt-channel fix moved across 12 reps.
Dispatched to find a new angle before accepting "model-capability boundary". Result: the capability conclusion is partly wrong — the model is more capable here than this issue has been assuming — and there is a genuine, deterministic, code-level bug in the path it takes. Fixed and verified 3/3. The prompt-following half remains unfixed but is now characterized far more tightly than "the model ignores correct instructions".
All runs: isolated daemon,
NODESPACE_HOME=/tmp/nodespaced-test,served_db_pathverified inside the temp dir before every run, release build rebuilt after every source change, gemma-4-e4b-q4km, granted_n_ctx=32768.The observation that reframes this issue
I dumped the full verbatim turn-6 prompt (temporary
NS_PROMPT_DUMP_DIRhook innlp-engine/src/chat/mod.rs, since the existing debug line truncates at 200 chars — instrumentation has been reverted) and then ran the same user message with history varied.Identical user message, identical DB, identical tool surface, identical guidance:
With no history the model does act on "The 2400 one came back — set it to returned". It correctly infers that "2400" means
replacement_costand emits:{"filters":[{"operator":"equals","property":"replacement_cost","value":2400}],"node_type":"equipment_item"}That is a semantically perfect resolution of the indirect reference. So "the model cannot resolve 'the 2400 one'" is refuted — it resolves it correctly and unprompted. It picks
search_nodesrather thanresolve_query, but it acts.Defect 1 (FIXED, verified 3/3): that perfect filter was rejected by our own deserializer
AgentFilterItem::filter_type(packages/core/src/ops/query_ops.rs) was a requiredString. The model had done all the hard work — which property, which operator, which value, which node_type — and the call was thrown away for omitting the boilerplate discriminator"type":"property", which is fully derivable from the fields already present.Made
typeoptional and inferred (relationship_type/node_id→ relationship;property→ property; nothing to infer from → still errors, socontentvsmetadatais never guessed). Explicittypealways wins.Verified end-to-end, 3 independent reps, each on a freshly purged database:
Before the fix that same probe was
search_nodes [ERROR]→ "I'm sorry, I couldn't find the equipment item…" 3/3. The turn goes from a hard failure to a correct, completed update. 4 new unit tests;cargo test -p nodespace-core --lib1118 passed,-p nodespace-agent --lib425 passed.This is worth having regardless of scenario 6 — it silently breaks any turn where the model omits a derivable discriminator, and the failure surfaces to the user as "I couldn't find it" rather than as a malformed call.
Defect 2 (NOT fixed): with history present, the model stops acting. Four prompt-channel fixes, 12 reps, zero movement.
The filter fix does not rescue the full scenario 6 chain — still 3/3 asking for an ID. I attempted four distinct interventions, each a proper 3-rep trial, each reverted after failing:
Fix A — competing skill imperative. Node Creation's guidance opens with
⚡ IMMEDIATE ACTION REQUIRED: Call create_node NOW … your response to receiving these instructions must be the create_node tool callandYou received this instruction because this skill was matched to the request. Your NEXT action MUST be create_node. Node Creation is routed as candidate 3 on turn 6 (an update turn), so this asserts a false premise and directly contradicts the wrapper's "Use whichever applies and IGNORE the rest". Two candidates issuing mutually-exclusive absolute imperatives is a real prompt defect. Made it conditional ("APPLIES WHEN: the user is adding a record that does not exist yet… if they are referring to a record already stored, this does NOT apply"). 3/3 fail. Reverted.Fix B — the node id is already in the prompt and the model still asks for it. The rebuilt history injects:
The exact id is verbatim in context, and the model answers "I need the ID". The framing is purely negative (a receipt for work not to repeat), so I reframed it to also present the ids as usable handles: "Each id below is a node that exists now: if the user's next message refers to one of these records, you already have its id — use it, do not ask the user for one." 3/3 fail — still asks for an id that is directly in front of it, explicitly labelled as usable. Reverted.
Fix C — tool-description carve-out (hypothesis 2 from the brief, from the other side).
search_nodesclaims to be "the single tool for querying the graph" and "the right tool whenever the user wants to see or act on typed data" — which directly contradictsresolve_query's carve-out. Added an explicit NOT-for-this exclusion tosearch_nodespointing atresolve_query, plus a clause onresolve_querycovering the referred-from-earlier-conversation shape including "never ask the user to supply a node id, and never answer that you need one". 3/3 fail. Reverted. (Worded to teach the shape, not the literal — quoting "the 2400 one" would have trippedguidance_is_not_contaminated_by_eval_promptsand been exactly the memorized-example degenerate solution that guard exists to prevent.)Fix D — turn-5 zero-result priming. Turn 5 ends with the model asserting "I couldn't find any equipment items currently logged in the system", and Graph Editing's AMBIGUITY rule says 0 results → ask a clarifying question. Plausible that turn 5 primes the refusal. Removed turn 5 entirely: 3/3 fail. Refuted.
Narrowing the remaining defect: ONE prior turn is enough
A single prior turn flips acting → refusing, 3/3. So it is not accumulation, not turn 5, and not the write-record wording.
One tempting sub-hypothesis, tested and refuted. Reps 2/3 above blame a missing status field — and indeed turn 3's
create_schemastores onlyreplacement_cost:so "set it to returned" genuinely has no target property, despite the fixture's comment requiring "checked-out vs returned" to be implied by turn 3. I re-ran the chain with a turn-3 prompt that forces the field ("Each item needs a status that is either checked_out or returned…"), confirmed
create_schema [fields=2], and turn 6 still failed 3/3. The status-field complaint is post-hoc rationalization in the model's prose, not the mechanism. Worth noting separately though: the schema-underspecification is real and makes scenario 6 partly unwinnable-by-construction on its own terms.Regression spot-check (required by the brief) — and a caution about reading it
Ran s3 / 8a / 8b / 8c / 8e on my build and on stock
main, both from a purged DB. They are identical, including the failures:No regression from my change — these are pre-existing standing failures, consistent with the corrected ~6-7/12 baseline rather than 10/12. Flagging explicitly because someone reading only the post-change run would mis-attribute s8a/s8e to this diff.
Where I land on "is this a model-capability boundary?"
Not in the way this issue currently frames it, and the framing should be corrected before it hardens into doctrine.
So: a capability/attention limit is a defensible reading of Defect 2 specifically, but it should be recorded as "adding instructions does not move this, and the prompt is ~8k tokens of mostly-boilerplate" rather than "the model cannot do this" — because the isolated probe shows it can.
Tree state
Uncommitted, not committed per the brief. Only the verified filter-inference fix remains; every failed experiment and all diagnostic instrumentation reverted.
Gate on a full matrix run before committing, as the standing rule requires. Suggest also re-scoping this issue's title/body — "entity-types block never reaches the prompt" was retracted two comments ago and the remaining defect is neither that nor purely a capability limit.
malibio commentedon Aug 2, 2026
Main session: subagent's filter_type fix verified against real source + full matrix gate — real bug, zero regressions, does not move THIS scenario's matrix score
Verified the subagent's report (rule 2 — checked claims against source, not taken at face value):
git diff --stat: exactly the 2 files claimed (tools.rs1 line,query_ops.rs+99/-5)filter_typewith inference fromproperty/relationship_type/node_idpresence, explicit type still wins, genuinely-unspecified filters still correctly error)cargo test -p nodespace-core --lib query_ops: 16/16 pass, including the 4 new testsFull 3-rep matrix gate run (purged DB, daemon rebuilt,
served_db_pathverified each run, e4b/32768/17.2GB — same conditions as every other gate this session):Byte-identical per-scenario results, including scenario 6 itself (0/3 both). Zero regressions — this confirms the subagent's own regression spot-check (8a/8e failing identically on stock
main) at full-matrix rigor, not just their 1-2 rep sanity check.Why scenario 6 doesn't move: checked
toolsCalleddirectly — all 3 filter_type-arm runs showtools: []for scenario 6, same asmain. The model never callsresolve_queryin this specific matrix conversation chain, so the filter_type deserialization fix — which only matters afterresolve_queryruns — never gets exercised here. This is exactly consistent with the subagent's own finding: Defect 2 (something about this conversation's prior turns flips the model from acting to refusing) gates upstream of where Defect 1 would help. Fixing defect 1 alone was never going to move this exact reproduction, and the subagent said so themselves.Decision: keeping the fix, it's correct independent of the matrix
This is a real, verified deserialization bug on the
resolve_querydecomposition path (the same tool family as #1908/#1910/#1915) — a model that gets every hard part of a filter right (property, operator, value) was having the whole call rejected over a discriminator token it had no reason to restate. That's worth having regardless of whether it moves this particular 12-scenario matrix. Zero regressions, real tests, real unit-level fix. Leaving it in place, uncommitted, as this session continues — will fold into whatever eventually gets committed together with the actual scenario-6-moving fix if one is found, or committed on its own if a good stopping point comes first.Defect 2 remains open — this comment does not close #1922; it closes out verification of the filter_type half of the subagent's report.
malibio commentedon Aug 2, 2026
Golden prompt confirmed 3/3 — scenario 6's blocker is history SIZE/SHAPE, not a capability boundary. Concrete fix direction identified.
Per the new methodology on #1917 (hand-author a golden prompt directly against llama.cpp, independent of any NodeSpace assembly code, before targeting the real pipeline at it): built
packages/agent/tests/golden_scenario6_handauthored.rs, entirely fresh strings — notSTAGE1_SYSTEM_PROMPT, notskill_pipeline.rs's Graph Editing guidance, not any production constant.The experiment
The prior subagent investigation on this issue established: the model resolves "the 2400 one" correctly with zero history (3/3), and fails with the full real scenario-6 history (~8,322 tokens of turn-by-turn reconstruction — tool-call records, write-receipts, routing candidate blocks) across 5 independent 3-rep trials on 4 different prompt channels. Open question: is the defect "any history at all" (unfixable, a real capability boundary) or "history above some size/shape" (fixable by compacting what's carried forward)?
Tested a compact hand-written summary — ~120 words, not the full reconstruction — carrying the same underlying facts (an
equipmenttype exists with areplacement_costfield; one item was logged at cost 2400):Result: 3/3, byte-identical
Every rep, exact same call. Correct tool, correct
node_type(better than the zero-history control, which had to guess a generic"Product"— the compact history actively helped here). Direct llama.cpp calls only, no daemon, no NodeSpace prompt assembly, ~4 min/rep of actual model time (vs the ~15-25 min a single full-matrix rep costs).What this settles
Refutes "any history breaks it." Confirms the size/shape hypothesis instead: a small amount of the RIGHT facts preserves correct behavior; it's the volume/shape of the full reconstruction that breaks it, consistent with this project's own resident-prompt dilution finding (10,493 chars scored 50% vs 445 chars at 73% on cases targeting the same prompt's own rules). This softens "model capability boundary" back toward "delivery/architecture problem" — which matters directly for #1917's explicit scope note that fine-tuning is only warranted once failures are shown to be judgment/comprehension rather than delivery/architecture.
This is now the golden prompt — target for the deterministic snapshot test
Per the agreed sequencing: this hand-authored, llama.cpp-validated prompt is the FIXED target, not a snapshot of current pipeline output. Next step is the deterministic (zero-model-call) test asserting whether the REAL assembly pipeline (
context_ops::build_workspace_context, prior-write injection, routing candidate rendering — whatever composes the acting turn's context) can be made to produce something that converges toward this compact shape, rather than the verbose full-reconstruction it produces today. That is a different fix direction than the 5 prior attempts (all prose/instruction tuning on the existing verbose assembly) — this targets what gets INCLUDED, not what's said about it.malibio commentedon Aug 2, 2026
Before scoping a compaction fix — need the actual prompt breakdown, not a guess
Started tracing where scenario 6's ~8,322 real tokens actually come from, to scope the compaction fix the golden-prompt result points toward. Found
node_history_from_messages(local_agent_service.rs:1805) andcompleted_writes_message(line 1746) — the functions that reconstruct prior turns and inject write-records into history.Caught myself before guessing wrong. My first instinct was to assume these are the bulk of the token cost and redesign them to summarize instead of reconstruct verbatim. But estimating the actual content: turn 3's schema-creation narration and turn 4's instance-creation narration are each a few sentences — nowhere near enough, even summed, to account for 8,322 tokens. The write-record injection (
completed_writes_message) is already compact by design (a few lines per write, explicitly built to avoid boilerplate per its own doc comment). The bulk of the token cost is very likely NOT in conversation-history reconstruction — it's probably the resident system prompt, skill guidance text, routing candidate blocks, or workspace context, which are independent of how many turns preceded this one.That matters a lot for scoping: compacting history reconstruction would be the wrong fix if history isn't actually where the size is. I don't want to redesign shared multi-turn conversation plumbing based on an assumption I haven't verified.
Not implementing anything yet. Next concrete step: capture the REAL assembled prompt for scenario 6's actual turn 6 (via the daemon, with full debug logging, one clean run) and get an honest section-by-section breakdown of where the 8,322 tokens actually go — resident prompt vs. skill guidance vs. routing candidates vs. workspace context vs. conversation history — before proposing any specific compaction design. This is the deterministic-snapshot-test infrastructure's actual first job: make that breakdown inspectable without a live model call every time.
Flagging this as the next unit of work rather than guessing at an architecture change to shared history-handling code that touches every multi-turn conversation in the product, not just scenario 6.
malibio commentedon Aug 2, 2026
Real prompt-size breakdown captured — the dominant cost is the RESIDENT prompt, not conversation history. This overlaps existing tracked work (#1813).
Reproduced scenario 6 end-to-end with
RUST_LOG=debugand captured everyChat prompt (N chars)log line across the full turn sequence (fresh purged DB):The finding
Turn 1's acting prompt is already 20,071 chars with NO conversation history at all. That is the resident system prompt + tool schemas + first-turn workspace context, alone — roughly 60% of the eventual peak (33,761). History growth from turn 1 to turn 2 is real (~13K chars) but it is added ON TOP OF an already-large base, not the dominant term.
This changes the fix-scoping conclusion from my last comment. Compacting conversation-history reconstruction (
node_history_from_messages,completed_writes_message) would cap the achievable reduction at roughly 30-40% of total prompt size — real, worth doing, but not the primary lever. The bigger lever is the same one ADR-064 already names and #1802's spike already measured directionally (the 10,493-char vs 445-char resident-prompt ablation, 73% vs 50% on cases targeting the prompt's own rules) — reducing the ~20K-char RESIDENT base itself.This overlaps #1813 ("reduce the resident prompt"), already filed and unblocked
#1802's spike closing comment lists #1813 — reduce the resident prompt — wave B, blocked by ADR-064 ✅. ADR-064 has since been adopted (this whole cluster is downstream of it). #1813 may already be unblocked and simply not yet worked. Worth checking its current state before either duplicating it here or treating scenario 6's fix as requiring a NEW compaction mechanism, when the existing filed issue may already be the right vehicle — possibly for both problems at once, since a smaller resident base benefits every turn, not just history-heavy ones like scenario 6.
Not implementing a fix this comment
This is now clearly the larger architectural question #1917 itself flagged as escalate-worthy (a genuine architecture tradeoff, not a bug fix scoped to one file) — reducing the resident prompt is cross-cutting, affects every turn in the product, and has a filed issue (#1813) that may already own this exact scope. Recommend checking #1813's status and either resuming it directly or explicitly re-scoping it to include the scenario-6 evidence gathered here, rather than a parallel compaction effort invented fresh in this issue.
malibio commentedon Aug 2, 2026
Correction: #1813 already landed and is NOT the open lever — the resident prompt is genuinely small already
Checked #1813 directly rather than assume from its title. It's closed via a real merge, not abandoned: commit
6aaae54a("Reduce agent_guidance.rs to identity and policy per ADR-064 rule 5 (closes #1813)"), part of PR #1827, landed 2026-07-30.agent_guidance.rsis genuinely small today — verified directly, not assumed: only 3 resident prompt constants exist (SCHEMA_CREATION_RULES342 chars,TOOL_STRATEGY_RULES1,529 chars,NODE_REFERENCE_FORMAT), totaling roughly ~2K chars. The file's 23KB on-disk size (which I flagged as suspicious in my last comment — a real error on my part) is Rust source structure: doc comments explaining the ADR-064 rationale, seeding logic, tests — not prompt content. #1813 did its job; my alarm about file size regrowing was measuring the wrong thing entirely, and I'm correcting it here before it misleads anyone.So the resident prompt is NOT where scenario 6's ~20K-char turn-1 baseline (measured last comment, zero conversation history) comes from.
skill_pipeline.rs(50.7KB) andtools.rs(192.9KB, all tool definitions/descriptions) are the far larger source files — tool schemas sent on every turn, and per-skill guidance rendered into Stage 2's prompt when a skill is retrieved, are the much more likely dominant contributors, not resident identity/policy prose.Where this leaves the investigation
I do not yet have the actual breakdown of what's IN that 20K-char turn-1 prompt — only that it isn't primarily
agent_guidance.rscontent. Getting that real breakdown (not another assumption) is the honest next step: capture the full turn-1 prompt text (already have the mechanism — theeprintln!diagnostic pattern used earlier this session onnlp-engine/src/chat/mod.rs) and measure section-by-section: tool schema total size, per-skill guidance size, workspace context size.Correcting course rather than compounding a wrong premise — apologies for the churn on this specific thread; two comments in a row have each needed correcting against real measurement rather than plausible-sounding inference. Getting the real number next, not another guess.
malibio commentedon Aug 2, 2026
Real section-by-section prompt breakdown captured — the dominant cost is TOOL SCHEMAS, not resident prose or history
Captured the actual full turn-1 acting prompt (20,005 chars, zero conversation history, fresh purged DB) via the same
eprintln!diagnostic technique used earlier — reverted immediately after this one capture, not left in the tree.Section breakdown
Tool schemas dominate, not resident prose. This corrects both of my last two comments' hypotheses — it was never primarily
agent_guidance.rs(already small, #1813 landed correctly) and it was never primarily conversation-history reconstruction either (that's additive on top but not the base).Per-tool breakdown (12 tools offered on this fail-open turn)
The top 4 tools (
create_schema,search_nodes,search_semantic,update_schema) account for 11,787 of 16,485 chars — 71% of all tool-schema text — and this is BEFORE Stage-2 candidate scoping narrows the surface; turn 1 here is on the fail-open path (12 tools, the near-maximum surface) because no skill had cleared the score gate yet.Why this matters for scenario 6 specifically
resolve_query's own description (read earlier this session,tools.rsdef_resolve_query) is itself fairly long — a worked "" example, three distinct outcome-handling branches (resolved/no_match/multiple_matches) spelled out in prose. Every one of these full tool descriptions is repeated in full on every turn a tool is offered, verbatim, every time — none of it is retrieved or summarized adaptively. A conversation with several tools whitelisted by multiple candidate skills pays full price for all of them, every turn.This is a genuinely new, different lever than anything tried this session
Not resident-prompt reduction (#1813, already done). Not history compaction (real but secondary, ~13K chars added across turns vs. ~17K in tool schemas already present at turn 1). Not a retrieval-merge or guidance-reorder — this is tool description length itself as prompt-mass, sent in full regardless of relevance, which is exactly the "volume harms" mechanism ADR-064's Evidence section already measured for resident prose (dilution, not misunderstanding) — just not yet measured for tool schemas specifically.
Not implementing anything yet — this needs a design decision, not a unilateral cut
Trimming tool descriptions is real surgery on shared, load-bearing text (per ADR-064 rule 1, tool schemas own argument shape — they're not decorative prose to casually shorten) across every tool in the registry, and #1813's own acceptance criteria required a repaired measurement harness and a non-adversarial case set before touching resident prose; the same discipline should apply here before cutting tool-schema prose. Flagging as a real, measured, actionable finding rather than acting on it without that groundwork — this is squarely the kind of infrastructure-first step the deterministic-snapshot-test deliverable exists to support: a size-per-section assertion could catch tool-schema bloat automatically going forward, once written.
malibio commentedon Aug 2, 2026
Actual root cause found: this is a Stage-1 query-reformulation content bug, not a workspace-context plumbing bug
Re-investigated from scratch against the daemon.log behind #1917's 9.0/12 matrix result (the most recent full run, post-compaction-fix). This supersedes this issue's own "suggested next step" (verify
ctxgoing intoset_session_context) — that thread turned out to be a dead end, not because the code there is broken, but because the actual failure happens one step earlier, beforedynamic_ctxis ever computed.The real mechanism, traced with exact log lines
Scenario 6's turn 3 prompt is "The 2400 one came back — set it to returned", following turns 1-2 (schema + instance creation for equipment). Stage-1 routing for this turn:
Stage-1's reformulated query is "equipment items on the books" — it drops "2400", "returned", and any update/state-change framing entirely, and produces something that reads like a re-statement of scenario 5's list query ("What equipment is on the books?"), not an update request.
Graph Editing(the skill that whitelistsupdate_node/resolve_query, perskill_pipeline.rs:354-367) is never among the routed candidates as a direct consequence — it's either never retrieved against this generic query, or retrieved below its 0.30 mutating-skill score bar (MUTATING_SKILL_SCORE_BAR,routing.rs:65). Either way,resolve_querynever clearstools_with_available_guidanceand gets stripped from the tool list before the acting turn even starts — matching the observedtoolsOfferedexactly (search_nodes, search_semantic, get_node, create_node, create_schema, update_schema, create_relationship— noresolve_query).This is confirmed as the actual mechanism, not the
dynamic_ctx/workspace-context injection path this issue originally chased.dynamic_ctx_len=0(this issue's prior finding) is real but is a downstream symptom of the same root cause working through a second path (the resident workspace-context block, which is scoped by a separate schema-retrieval query, also not preserving "the 2400 one... returned" as update-shaped) — not an independent bug in session storage or the formatting/ordering code all previously ruled out. No fix is needed inset_session_context/AgentSession— that code is correct.Why this happens: a real gap in
route_query's tool descriptionroute_query's current description (routing.rs:118-123, tuned byfdc1a256for #1912's "preserve literal subject nouns" finding):This instruction is entirely about preserving the subject noun ("equipment", "albums", "venues") — it says nothing about preserving the action/intent (update vs. read vs. create) that actually determines which skill category (and score bar) applies. For scenario 6, the model correctly kept "equipment" per this instruction, but had no equivalent instruction telling it that "the 2400 one... set it to returned" is the part that determines the query needs to describe an UPDATE, not a listing. The result reads exactly like scenario 5's query with the discriminating value and verb dropped.
Scope note
This is the same class of defect
fdc1a256already fixed once for 8a (Stage-1 query reformulation losing signal) — but a different instance of it (losing the action/intent, not the subject noun), on the same tool description that fix already tuned. Given #1912's own history (aroute_query-adjacent change previously traded 8a against 8b/3), any fix here needs the same full-matrix discipline before merging, not just validation against scenario 6.Suggested fix direction (not yet implemented)
Extend
route_query's tool/parameter description to also instruct preserving the action verb or intent signal (e.g. "keep both the subject noun AND the specific action or distinguishing detail — a status word, a value, an update/creation/deletion verb — rather than generalizing to a category-level description"). This is a description-only change (ADR-064 rule 2: tool descriptions own tool/query-shape guidance) — no code path change needed beyond the string itself, but it's shared surface every turn's routing depends on, so full 3-rep matrix gate before merge, same asfdc1a256itself required.malibio commentedon Aug 2, 2026
Stage-1 fix confirmed working live; found a SECOND, distinct root cause one layer downstream
Implemented and committed the Stage-1 fix proposed in the prior comment (
route_query's tool/parameter descriptions now instruct preserving the action/intent alongside the subject noun — commit83bdabed,packages/agent/src/local_agent/routing.rs). Verified two ways before concluding:stage1_reformulation_for_scenario_6_update,live_stage1_golden_prompts.rs): pre-fix reliably reproducedroute_query("equipment items on the books"); post-fix producesroute_query("set laser cutter to returned with replacement cost 2400")— exactly the intended change. Regression-checked against the 3 existing golden cases (8a, 8b control, scenario 4) single-threaded — all unchanged.NODESPACE_HOMEpurged,served_db_pathverified): confirms the fix reaches the real pipeline. Stage-1's actual reformulated query for scenario 6's turn 3 in this run:But scenario 6 still fails — because
Graph Editingloses the retrieval competition, not because of a bad queryEven with a well-formed, correctly-intent-preserving query,
Graph Editing(the skill whitelistingresolve_query/update_node) is not among the top-3 routed skills. Checked why: compared skill descriptions directly (skill_pipeline.rs):Schema Creation's description (line 345) literally contains the word "equipment" as a worked example: "...equipment, bookings, subscriptions, contacts, or any recurring category of item..."Graph Editing's description (line 359) is generic with zero domain vocabulary: "Modify existing nodes in the knowledge graph - update content, properties, titles, and metadata. For tasks, use update_task_status to change status."Against "set equipment record worth 2400 to returned status,"
Schema Creation's embedding wins the retrieval race largely because it happens to share the literal word "equipment" — even though the actual request is an update, squarelyGraph Editing's domain, not schema definition. This is a skill-description retrieval competition problem, a second, separable link in the chain from the Stage-1 query-reformulation bug just fixed.Scope decision
Not fixing this inline — per #1912's own history, skill-description tuning has previously traded scenarios against each other (8a fixed, 8b/3 broken), so any change here needs the same live-model golden-prompt validation + full matrix gate discipline as the Stage-1 fix, not a quick edit. Filing as a proper next step rather than folding it into this issue's already-landed fix.
Matrix result on this run (informational — NOT decision-grade, single rep, and confounded)
9/12 → 7/12 on the debug-logging run (new failures on 3 and 4 relative to the earlier 9.0/12 baseline). Per #1862's noise-band lesson this alone isn't conclusive, but flagging honestly: this run also had
RUST_LOG=debugenabled (the original 9.0/12 baseline did not), which changes daemon overhead/timing and is a confound I introduced to get the trace — need a clean (non-debug) 3-rep re-run to get a decision-grade number for the Stage-1 fix alone before drawing conclusions about whether it net-helps.Next steps, in order: (1) clean 3-rep matrix gate (no debug logging) on commit
83bdabedto get a real number for the Stage-1 fix alone, (2) if net-positive with no new regressions, keep it; if not, investigate before merging further, (3) separately, design + validate aGraph Editingdescription fix (add domain-anchoring vocabulary — item, record, status, update — without stealing retrieval mass from Schema Creation the waydbb21c36did in the opposite direction per #1912's history) as its own golden-prompt-validated change.Preserve action/intent alongside subject noun in Stage-1 routing
malibio commentedon Aug 2, 2026
Third layer investigated: Graph Editing description fix gets resolve_query fully available and instructed — model still doesn't call it. Likely a model-judgment limit, not a fixable prompt-assembly bug. Not merging this attempt.
Followed the "next step" from the prior comment: designed a
Graph Editingdescription fix adding domain-anchoring vocabulary and intent examples (item/record/status/value language, e.g. "mark it returned", "set it to done", explicitly contrasted against creation/schema-definition intent). Tested live against a fresh isolated daemon before matrix-gating, per standing practice.Result: real, measurable retrieval improvement — but does not flip scenario 6's outcome
With the new description, scenario 6's Stage-1 query (already correctly reformulated by the prior fix —
83bdabed) now retrievesGraph Editinginto the top-3 candidates for the first time all session:And critically, the acting turn's tool list now includes
resolve_query:Confirmed
render_candidates_for_promptincludes every eligible candidate's full instructions (not just the top-ranked one), soGraph Editing's INDIRECT TARGET guidance — which explicitly covers "a bare value without naming its field (an amount, a code)," the exact shape of "the 2400 one" — was present in this turn's prompt alongsideresolve_query's own tool description (also a strong match: its own worked example is"Mark the $500 invoice as paid", structurally identical to scenario 6).The model still didn't call it. Actual output for this turn:
tool_calls=0, reply "I need the ID of the equipment item you are referring to. Could you provide it?" — same refusal shape as the availability-gap era, but now with every piece of guidance and tooling correctly in place.Read on this
This moves the open question from "is
resolve_queryreachable" (now: yes, confirmed) to "does the model choose to use it when it's reachable and correctly instructed" (now: no, at least not reliably in this configuration). That's a materially different, harder class of gap — instruction-following/selection-under-competing-candidates, not a prompt-assembly or retrieval defect fixable by more description tuning. Consistent with this cluster's prior honest negative results (#1924's tool-schema dead end, the four rejected retrieval-merge variants in #1917 checkpoints 4-6) — not every gap in this matrix is a plumbing bug.Not merged
Single-run check (not yet 3-rep gated) also showed 8e regressing to a fail in this same run — noise-band territory per #1862, not confirmed, but not worth spending a 3-rep gate on a change that doesn't move scenario 6's actual pass/fail outcome. Discarded the code change (
packages/agent/src/skill_pipeline.rs,Graph Editing's description) rather than commit a change with real regression risk and zero net score benefit. Recording the finding here since it's real evidence, even though the specific fix attempt didn't pan out.Where this leaves scenario 6
Two of three root-cause layers are now fixed and verified (Stage-1 intent preservation — merged,
83bdabed;Graph Editingretrieval visibility — proven fixable, not merged since it doesn't change the outcome on its own). The remaining layer looks like it needs either: (a) stronger/differently-framed guidance specifically for this trigger phrase shape ("came back", "the X one" as an indirect reference) — a genuinely new hypothesis, not yet tried; or (b) acceptance that this is a real model-capability ceiling for the current locked model (Gemma 4 E4B) on this specific instruction-following pattern, which would make scenario 6 a documented, accepted gap rather than a bug to keep chasing. Not deciding between these unilaterally — flagging as the next real fork for #1917.malibio commentedon Aug 3, 2026
Idiom-probe result (option b): negative — no behavior change, confirms model-capability ceiling
Ran the bounded check per the fork decision: reworded
Graph Editing's INDIRECT TARGET guidance inskill_pipeline.rsto add literal demonstrative-phrase examples ("the one with the red label", "that item", "it") instead of only abstract field/value language, plus an explicit "do not ask the user for the ID resolve_query already found" line. Passed theguidance_is_not_contaminated_by_eval_promptstest (generic examples, not eval prompt text).Rebased the worktree onto current
main(2002fa82— includes PR #1928 androute_multi), reapplied the change cleanly, confirmed it still builds. Drove scenario 6's real 3-turn sequence (schema creation → instance creation → list → update) through the actual isolated daemon viaaichat.ts, not a hand-authored harness — this change lives in the skill-description/retrieval layer, which none of the existing golden-prompt tests (they use hand-authored tool text) actually exercise.Result on turn 4 (scenario 6's exact prompt, "The 2400 one came back — set it to returned"):
Graph Editingis correctly retrieved andresolve_queryis in the offered tool surface (layer 1 and layer 2 fixes both still working as designed) — but the model still declines to call it and asks for a literal ID, identical failure shape to the pre-idiom-probe baseline. The reworded guidance, including literal idiom examples matching this scenario's exact phrasing pattern ("the X one"), did not change the outcome.Per the fork decision's own bound: this is sufficient evidence. Calling it — scenario 6's remaining gap is a documented model-capability limit of the locked model (Gemma 4 E4B) on this specific instruction-following pattern (indirect demonstrative reference + state-change verb), not a prompt-assembly or retrieval defect. Not chasing further hypotheses on this specific angle.
Action taken: discarded the uncommitted change (
git checkout -- packages/agent/src/skill_pipeline.rs) rather than merge a fix with no measured effect. Worktree left rebased on current main; no other changes to preserve there.Proceeding to #1926 next, per the standing priority order.
malibio commentedon Aug 3, 2026
Closing as a documented model-capability limit, not a completed fix.
What was actually resolved: the original plumbing defect this issue was filed for (
dynamic_ctx_len=0— the entity-types block never reaching the prompt despite successful schema retrieval) is fixed and verified. Two further layers were also found and fixed along the way: Stage-1 query reformulation dropping the update-intent signal (merged,83bdabed), andGraph Editing's missing domain vocabulary preventing it from being retrieved as a routing candidate (fix designed and proven, though not merged since it didn't change the outcome on its own).What was NOT resolved, and this issue's actual acceptance criterion: "scenario 6 passes reliably across multiple runs" — not met. With every plumbing layer now confirmed correct (resolve_query reachable, correctly instructed, entity-types block present), the model still declines to call it and asks for a literal node ID instead. A dedicated probe reframing the guidance around the literal idiom ("the one with the red label," "that item") — the last untried angle — also came back negative under the same conditions.
Conclusion: this is a real instruction-following limit of the locked model (Gemma 4 E4B) on this specific pattern (an indirect reference phrased as "the X one" combined with a state-change verb), not a fixable prompt-assembly or retrieval defect. Closing as an accepted, documented limitation rather than an open bug — reopen if a future model change or fine-tuning effort makes this worth re-testing, or if a genuinely new, untried hypothesis emerges.
Preserve route_clarify's structured question/options through to the UI (