Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

test(query): strengthen budget accounting and sync plugin guidance

Mihael Zamin Sousa481eaf6c5867
diff --git a/crates/ai-memory-mcp/src/server.rs b/crates/ai-memory-mcp/src/server.rs
index 557d0bfa..3489939c 100644
--- a/crates/ai-memory-mcp/src/server.rs
+++ b/crates/ai-memory-mcp/src/server.rs
@@ -8548,8 +8548,7 @@ mod tests {
let context = plan.context.unwrap();
assert_eq!(context.clipped, 1, "{snippet}");
assert!(
- context.estimated_input_tokens + context.reserved_output_tokens as usize
- <= exact - 1
+ context.estimated_input_tokens + (context.reserved_output_tokens as usize) < exact
);
assert!(plan.request.unwrap().messages[0].content.contains('…'));
}
@@ -8563,6 +8562,20 @@ mod tests {
assert!(plan.request.is_none());
assert!(plan.sources.is_empty());
}
+ // With the same sufficient budget and evidence, only the long question
+ // prevents admission: fixed question content is charged before snippets.
+ let short =
+ prepare_answer_request("question", &hits, &[], ReasoningTier::Minimal, Some(10_000));
+ assert!(short.request.is_some());
+ let long = prepare_answer_request(
+ &"long question ".repeat(10_000),
+ &hits,
+ &[],
+ ReasoningTier::Minimal,
+ Some(10_000),
+ );
+ assert!(long.request.is_none());
+ assert!(long.sources.is_empty());
for snippets in [&[][..], &[" "][..], &["---```---```---```---```---"][..]] {
let empty = answer_budget_hits(snippets);
assert!(
diff --git a/plugins/claude-code/skills/ai-memory-retrieval/SKILL.md b/plugins/claude-code/skills/ai-memory-retrieval/SKILL.md
index 164a6971..758d01cf 100644
--- a/plugins/claude-code/skills/ai-memory-retrieval/SKILL.md
+++ b/plugins/claude-code/skills/ai-memory-retrieval/SKILL.md
@@ -100,6 +100,12 @@ The tier only matters when the LLM path actually runs: with `answer: false` (or
no provider configured) it is inert and no LLM call is made. An unknown value is
rejected by the schema.
+If the server configures an answer context budget, `answer_context` reports
+admitted, omitted and clipped snippet counts. All retrieval hits remain
+available. Inspect those hits when the receipt reports omissions or clipping;
+a clipped snippet can lose a qualification. If no evidence fits, the server
+returns `answer_unavailable` without a model call. The default has no budget.
+
## Snippets are not full pages
Search returns snippets, not complete bodies. An empty-looking or short snippet does not prove the page is empty because the match can be outside the snippet window. Fetch the full page when the path or title looks relevant, especially for rules, procedures, decisions, and gotchas.
diff --git a/plugins/codex/skills/ai-memory-retrieval/SKILL.md b/plugins/codex/skills/ai-memory-retrieval/SKILL.md
index 164a6971..758d01cf 100644
--- a/plugins/codex/skills/ai-memory-retrieval/SKILL.md
+++ b/plugins/codex/skills/ai-memory-retrieval/SKILL.md
@@ -100,6 +100,12 @@ The tier only matters when the LLM path actually runs: with `answer: false` (or
no provider configured) it is inert and no LLM call is made. An unknown value is
rejected by the schema.
+If the server configures an answer context budget, `answer_context` reports
+admitted, omitted and clipped snippet counts. All retrieval hits remain
+available. Inspect those hits when the receipt reports omissions or clipping;
+a clipped snippet can lose a qualification. If no evidence fits, the server
+returns `answer_unavailable` without a model call. The default has no budget.
+
## Snippets are not full pages
Search returns snippets, not complete bodies. An empty-looking or short snippet does not prove the page is empty because the match can be outside the snippet window. Fetch the full page when the path or title looks relevant, especially for rules, procedures, decisions, and gotchas.