Repository navigation
Description
Summary
focus_query_text (crates/jcode-base/src/memory_prompt.rs) strips tool noise by
dropping lines that start with [Tool error: / [Tool:, but tool-error
payloads are multi-line and only the first line carries that prefix. Subsequent
lines of the error message pass through into the focused query, the retrieval
context, and the LLM judge. Sandbox command-safety rejections in particular —
"This command was not run...", "cannot be confirmed", "is irreversible", "could
not be identified statically" — are lexically close to safety/governance memory
facts, so they shift the judge's votes away from the actual topic.
Impact
Verified in an ACP task (NTL-486): the agent's tool calls tripped the sandbox on
protected commands; the multi-line [Tool error: ...] blocks reached the judge,
which then injected 5 safety-related facts instead of the token-related fact the
task actually asked about. The throttle had fired and the pool was large (30/22
candidates) — the loss was caused by the noisy judge input, not by retrieval
coverage. Any host whose tasks run under restrictive tool policies (read-only
review, sandboxed containers, blocked globs/recursive deletes) hits this
constantly.
Root cause
format_content_block_for_relevance wraps an error payload in a single block:
ContentBlock::ToolResult { content, is_error, .. } => {
if is_error.unwrap_or(false) {
Some(format!(
"[Tool error: {}]",
truncate_chars(content.trim(), MEMORY_CONTEXT_MAX_BLOCK_CHARS / 4)
))
} else {
None
}
}The payload keeps its internal newlines, so focus_query_text, which iterates
line-by-line, drops only the first line:
if trimmed.is_empty()
|| trimmed.starts_with("[Tool:")
|| trimmed.starts_with("[Tool error:")
|| ...
{
continue;
}The remainder — e.g. - target contains a glob, so the exact set of affected files is not known before execution (target: /sys/...) or - targets a protected system or home path that must never be destroyed (target: a user home dir) — is treated as
session prose and kept in the focused query.
Proposed change (implemented and verified locally)
Drop command-safety block errors by content, not only by the [Tool error:
prefix:
if trimmed.is_empty()
|| trimmed.starts_with("[Tool:")
|| trimmed.starts_with("[Tool error:")
|| trimmed.starts_with("[Result:")
|| trimmed.starts_with("[Image]")
|| trimmed.starts_with("[OpenAI native compaction]")
// Multi-line error payloads only carry the prefix on the first line; drop the
// sandbox-block markers wherever they appear so safety wording cannot steer
// retrieval or the judge toward safety facts.
|| trimmed.contains("This command was not run")
|| trimmed.contains("cannot be confirmed")
|| trimmed.contains("is irreversible")
|| trimmed.contains("could not be identified statically")
|| trimmed.contains("could not be identified")
{
continue;
}A more general fix would track "inside a [Tool error: block" state across lines
(like the existing <system-reminder> handling) instead of a marker list; the
marker list above is the minimal, backward-compatible version.
Environment
- jcode v0.68.0, Linux x86_64, DeepSeek provider, local all-MiniLM-L6-v2 embeddings.
- ACP protocolVersion 1, host: Multica daemon; 2-vote consensus judge
(memory_rerank_votes = 2). - Verified locally: with the content filter, the judge no longer sees sandbox
wording and votes on the actual topic.
Activity
1jehuang commentedon Aug 8, 2026
Fixed on
agent/triage-2026-08-07in commit9d75bf606. Tool-error blocks are structurally normalized so multiline payloads cannot leak into focused memory queries, while later user prose remains intact. All 45 focused memory tests pass.--- — Jcode agent (automated triage), on behalf of @1jehuang
1jehuang commentedon Aug 8, 2026
The validated fix is now available for review in #841 on a clean branch based on the public default branch.
--- — Jcode agent (automated triage), on behalf of @1jehuang
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
chore: sync fork with upstream jcode (fresh merge onto current master) (
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)