Skip to content

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

Rust

fix(wiki): embed pages applied by an auto-improvement approval (#1258)

João Carlos Magalhães de Castrod9e291b96bc7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index efbd8bbc..812add3f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,16 @@ and [0.x](docs/changelog/0.x.md).
## [Unreleased]
+### Fixed
+
+- Fixed pages written by an auto-improvement approval getting no embedding.
+ An approval through `pending-writes approve`, the `memory_auto_improve`
+ tool, `POST /admin/auto-improve` or the scheduler wrote and indexed the
+ page but never embedded it, so it stayed out of the vector stream of
+ hybrid search until an embedding backfill ran, which by default is only at
+ the next server start. The approval now embeds the applied page the same
+ way `memory_write_page` does (#1258).
+
## [2.6.7] - 2026-10-13
### Deprecated
diff --git a/crates/ai-memory-wiki/src/wiki.rs b/crates/ai-memory-wiki/src/wiki.rs
index 5ce3a2fe..50cc5305 100644
--- a/crates/ai-memory-wiki/src/wiki.rs
+++ b/crates/ai-memory-wiki/src/wiki.rs
@@ -1836,6 +1836,17 @@ impl Wiki {
}
};
+ // Embed the applied version like `write_page` does, after the
+ // mutation guard is released (the provider call may block). Without
+ // this, approved pages stayed vectorless until a backfill ran: the
+ // watcher's reindex of the file we just wrote hits the store's
+ // unchanged-content short-circuit, so it never embeds them either.
+ if let ApproveAutoImproveProposalResult::Approved { page_id } = &result {
+ let abstract_text = frontmatter_abstract(&markdown.frontmatter);
+ self.embed_page_version(*page_id, &markdown.body, abstract_text)
+ .await?;
+ }
+
if let (Some(chain), Some(ctx)) = (&self.admission_chain, &resolved_ctx) {
chain.dispatch_async(
Some(path.as_str()),
@@ -4831,6 +4842,36 @@ mod tests {
);
}
+ /// An approved auto-improvement page is embedded on approval, like every
+ /// `write_page` version. Before, nothing on the write path embedded it:
+ /// the page stayed out of the vector stream until an embedding backfill
+ /// (startup, scheduled or `ai-memory embed`) found it.
+ #[tokio::test]
+ async fn auto_improve_approval_embeds_the_applied_page() {
+ let tmp = TempDir::new().unwrap();
+ let (store, wiki, ws, proj) = scoped(&tmp).await;
+ let embedder: Arc<dyn ai_memory_llm::Embedder> =
+ Arc::new(ai_memory_llm::SyntheticEmbedder::new(32));
+ let wiki = wiki.with_embedder(embedder);
+ let id = stage_one(&store, ws, proj, "notes/embedded.md", "approved body").await;
+ let result = wiki
+ .approve_auto_improve_proposal(ws, proj, id, ActorContext::default(), None, None)
+ .await
+ .unwrap();
+ let ApproveAutoImproveProposalResult::Approved { page_id } = result else {
+ panic!("expected approval, got {result:?}");
+ };
+ let embedded = store
+ .reader
+ .embedded_page_ids(ws, proj, "synthetic".into(), "bag-of-words-v1".into(), 32)
+ .await
+ .unwrap();
+ assert!(
+ embedded.contains(&page_id),
+ "the approved page version must be embedded by the approval itself"
+ );
+ }
+
#[tokio::test]
async fn auto_improve_approval_admission_mutation_is_persisted_and_scrubbed() {
use axum::http::StatusCode;