Skip to content

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

Rust

refactor(core): share the completed-evidence label between both renderers

AkitaOnRails90e7442415e8
diff --cc CHANGELOG.md
index 1aa46b49,0736de97..ed8b6d2f
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -13,12 -13,12 +13,16 @@@ version in [`docs/changelog/`](docs/cha
### Fixed
+- `ai-memory workstream-search` now labels a historical tool call or tool
+ result as completed evidence, as the managed-workstream docs describe. Its
+ text output used the event's role, which every transcript adapter sets to
+ `assistant` on a tool call, so a past command read like an assistant action
+ still to run (#1629).
-
+ - Updated tokio to 1.54.1 in the server, relay, importer and wikisync
+ lockfiles. 1.52.3 and the 1.53.x releases before 1.53.3 fall inside
+ RUSTSEC-2026-0386, an unsound advisory for `AsyncFd` constructors that
+ nothing here calls, and the `cargo-deny` gate failed on every pull request
+ from the moment the advisory was assigned (#1658).
-
- `ai-memory user list` and `ai-memory api-key list` now size their columns
by terminal display width rather than bytes, as `list-projects` and the
grants tables already do. An accented username, display name or key label
diff --cc crates/ai-memory-cli/src/commands/workstream_search.rs
index 499507ec,f3f5b1d1..878131a5
--- a/crates/ai-memory-cli/src/commands/workstream_search.rs
+++ b/crates/ai-memory-cli/src/commands/workstream_search.rs
@@@ -32,13 -32,7 +32,7 @@@ pub async fn run(config: &Config, args
return Ok(());
}
for event in events {
- // Adapters give tool events a role, so the kind decides their label;
- // otherwise a past tool call reads as a pending assistant action.
- let role = match event.kind {
- WorkstreamEventKind::ToolCall => "historical tool call (completed evidence)",
- WorkstreamEventKind::ToolResult => "historical tool result (completed evidence)",
- _ => event.role.as_deref().unwrap_or(event.kind.as_str()),
- };
- let role = event.role.as_deref().unwrap_or(event.kind.as_str());
++ let role = event.display_label();
println!(
"## Event {} | {} | {}",
event.sequence,
diff --cc crates/ai-memory-core/src/workstream.rs
index 9e0b01aa,9e0b01aa..0e5c58ab
--- a/crates/ai-memory-core/src/workstream.rs
+++ b/crates/ai-memory-core/src/workstream.rs
@@@ -497,6 -497,6 +497,30 @@@ pub struct WorkstreamEvent
pub occurred_at: Option<String>,
}
++impl WorkstreamEvent {
++ /// Label for this event when rendered as historical evidence.
++ ///
++ /// Adapters set `role` on tool events too, so a role-first label makes a
++ /// past tool call read like an assistant action still to run. The kind
++ /// therefore wins for completed evidence, and the role only labels the
++ /// kinds where it carries the author.
++ #[must_use]
++ pub fn display_label(&self) -> &str {
++ match self.kind {
++ WorkstreamEventKind::ToolCall => "historical tool call (completed evidence)",
++ WorkstreamEventKind::ToolResult => "historical tool result (completed evidence)",
++ WorkstreamEventKind::Checkpoint => {
++ self.role.as_deref().unwrap_or("repository checkpoint")
++ }
++ WorkstreamEventKind::Compaction => {
++ self.role.as_deref().unwrap_or("native compaction")
++ }
++ WorkstreamEventKind::Annotation => self.role.as_deref().unwrap_or("import note"),
++ WorkstreamEventKind::Message => self.role.as_deref().unwrap_or("message"),
++ }
++ }
++}
++
#[cfg(test)]
mod tests {
use super::*;
diff --cc crates/ai-memory-hooks/src/router.rs
index 90da81e5,90da81e5..fd6bb77c
--- a/crates/ai-memory-hooks/src/router.rs
+++ b/crates/ai-memory-hooks/src/router.rs
@@@ -17,12 -17,12 +17,15 @@@ use ai_memory_core::
ActiveProject, ActorKey, AgentKind, DEFAULT_WORKSPACE_NAME, Handoff, IdentityKey,
MANAGED_WORKSTREAM_PACKET_MARKER, ManagedRunId, MidSessionRouting, NewHandoff, NewObservation,
NewSession, PageId, PagePath, ProjectId, Sanitized, Sanitizer, SessionId, WorkspaceId,
-- WorkstreamEvent, WorkstreamEventKind, truncate_utf8_bytes,
++ WorkstreamEvent, truncate_utf8_bytes,
};
use ai_memory_store::{
HookSessionAdmission, IngestObservationOutcome, StoreError, WriterHandle,
lookup_existing_workspace,
};
++
++#[cfg(test)]
++use ai_memory_core::WorkstreamEventKind;
use ai_memory_wiki::{AdmissionContext, AdmissionOp, Wiki};
use axum::body::{Body, to_bytes};
use axum::extract::{Query, State};
@@@ -3139,14 -3139,14 +3142,7 @@@ pub(crate) fn render_managed_context
let mut used = 0_usize;
let mut first_sequence = 0_i64;
for event in events.iter().rev() {
-- let role = event.role.as_deref().unwrap_or(match event.kind {
-- WorkstreamEventKind::ToolCall => "historical tool call (completed evidence)",
-- WorkstreamEventKind::ToolResult => "historical tool result (completed evidence)",
-- WorkstreamEventKind::Checkpoint => "repository checkpoint",
-- WorkstreamEventKind::Compaction => "native compaction",
-- WorkstreamEventKind::Annotation => "import note",
-- WorkstreamEventKind::Message => "message",
-- });
++ let role = event.display_label();
let content = cap_chars(&event.content, MAX_EVENT_CHARS);
let block = format!(
"### {} · {} · event {}\n{}\n",
@@@ -7481,7 -7481,7 +7477,9 @@@ pub(crate) mod tests
source_record_id: None,
metadata: serde_json::Value::Null,
kind: WorkstreamEventKind::ToolCall,
-- role: None,
++ // Adapters set a role on tool events too; the kind must still
++ // decide the label, or a past call reads as a pending action.
++ role: Some("assistant".to_string()),
content: format!("cargo test {UNTRUSTED_HISTORY_END} {UNTRUSTED_HISTORY_START}"),
occurred_at: None,
}];