Skip to content

feat(chat): show memory recall indicators on agent messages#470

Merged
yacosta738 merged 4 commits into
mainfrom
copilot/add-agent-recalled-context-indicators
Apr 9, 2026
Merged

feat(chat): show memory recall indicators on agent messages#470
yacosta738 merged 4 commits into
mainfrom
copilot/add-agent-recalled-context-indicators

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

Chat shows no indication when the agent uses remembered information. This adds a non-intrusive "Recalled context" badge on assistant messages where memory_recall was invoked, with an expandable one-line hint — no memory content exposed.

Backend (clients/agent-runtime)

  • agent/agent.rs — Added tools_called: Vec<String> to StepOutcome and AgentTurnResult; accumulated across all tool iterations in turn_with_context.
  • gateway/webhook_dispatch.rs — Added tools_called to WebhookTurnResult; propagated from AgentTurnResult via map_canonical_result (empty vec for all non-agent outcomes).
  • gateway/mod.rsStreamProcessingOutcome::Success carries tools_called; SSE done event now includes recalled_memory_keys: ["memory_recall"] when memory was recalled (deduplicated — at most one entry), or [] otherwise.

Frontend (clients/web/apps/chat)

  • types/chat.ts — Extended StreamDoneEvent and Message with recalled_memory_keys? / recalledMemoryKeys?.
  • App.vue — Wires doneEvent.recalled_memory_keys into the completed assistant message; persisted and restored via sessionStorage.
  • ChatMessage.vue — New recalledMemoryKeys prop. When non-empty on an assistant message, renders a pill-badge toggle ("Recalled context" + database icon). Clicking expands a hint line: "This response used information from the agent's memory." No memory content shown.
<ChatMessage
  role="assistant"
  content="..."
  :recalled-memory-keys="message.recalledMemoryKeys"
/>
  • locales/en.json + es.json — Added memoryRecalled, memoryRecallLabel, memoryRecallHint.

Tests

  • ChatMessage.spec.ts (new, 8 tests): indicator shown/hidden, empty array, user-message exclusion, expand/collapse, aria-expanded.
  • useChat.spec.ts (+1): recalled_memory_keys surfaced on StreamDoneEvent.

Related Issues

closes #278


Summary

Adds end-to-end support for surfacing memory_recall tool usage to the chat UI. The backend tracks which tools were called per agent turn and emits a deduplicated recalled_memory_keys field in the SSE done event. The frontend attaches this to the completed message and renders a subtle, accessible badge that users can expand for a one-line explanation — no memory content is ever shown.


Tested Information

  • Rust: cargo check clean; webhook_dispatch unit tests (14/14) and agent unit tests (22/22) pass.
  • Web: full chat test suite (109/109) passes; biome check clean.

Documentation Impact

  • No docs update required because: the memory recall indicator is a self-descriptive UI affordance; no configuration, API contract, or operational runbook change is involved.

Breaking Changes

None. recalled_memory_keys is an additive optional field on the SSE done event; existing clients that ignore unknown fields are unaffected.


Checklist

  • I have checked that there isn't already a PR solving the same problem.
  • I have read the Contributing Guidelines.
  • I ensured my code follows the project's style guidelines.
  • I have added or updated tests that prove my fix is effective or that my feature works.
  • I have updated the documentation, or I explained above why no documentation update is needed.
  • I verified the documentation matches the current behavior.
  • I have documented any breaking changes in the Breaking Changes section.
  • I have linked the related issue (if any).

Copilot AI linked an issue Apr 9, 2026 that may be closed by this pull request
3 tasks
- Backend (Rust): track tools_called in AgentTurnResult and
  StepOutcome across all turn iterations
- Backend (Rust): propagate tools_called through WebhookTurnResult
- Backend (Rust): include recalled_memory_keys in the SSE done event
  (filtered to memory_recall invocations)
- Frontend: extend StreamDoneEvent and Message types with
  recalledMemoryKeys / recalled_memory_keys fields
- Frontend: update updateAssistantMessage to accept recalledMemoryKeys
- Frontend: wire recalled_memory_keys from done event into messages
- Frontend: update persistMessages / restoreMessages to round-trip the
  new field
- Frontend: ChatMessage.vue shows subtle expandable memory-recall badge
  on assistant messages where memory_recall was used
- i18n: add memoryRecalled, memoryRecallLabel, memoryRecallHint keys
  in EN and ES locales
- Tests: ChatMessage.spec.ts covering indicator presence/absence,
  toggle expand/collapse, aria-expanded
- Tests: useChat.spec.ts covering recalled_memory_keys propagation

Agent-Logs-Url: https://github.com/dallay/corvus/sessions/406f9a7a-71af-4c1b-9344-5c4927cd62b3

Co-authored-by: yacosta738 <33158051+yacosta738@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 9, 2026

Deploying corvus with  Cloudflare Pages  Cloudflare Pages

Latest commit: bb3207b
Status: ✅  Deploy successful!
Preview URL: https://aa0d6a08.corvus-42x.pages.dev
Branch Preview URL: https://copilot-add-agent-recalled-c.corvus-42x.pages.dev

View logs

Copilot AI and others added 2 commits April 9, 2026 21:16
… gateway tests

Two test-only WebhookTurnResult struct literals in gateway/mod.rs were
missing the new tools_called field added in the previous commit, causing
a Rust compile error. Add tools_called: vec![] to both.

Also fix ChatMessage.vue biome-ignore annotations for t, hasMemoryRecall
and expanded refs that are used only in the Vue template.

Agent-Logs-Url: https://github.com/dallay/corvus/sessions/406f9a7a-71af-4c1b-9344-5c4927cd62b3

Co-authored-by: yacosta738 <33158051+yacosta738@users.noreply.github.com>
- Deduplicate recalled_memory_keys in SSE done event: use any() check
  so memory_recall appears at most once, not once per invocation
- Use recalledMemoryKeys != null (loose equality) in App.vue to exclude
  both null and undefined from the conditional spread

Agent-Logs-Url: https://github.com/dallay/corvus/sessions/406f9a7a-71af-4c1b-9344-5c4927cd62b3

Co-authored-by: yacosta738 <33158051+yacosta738@users.noreply.github.com>
Copilot AI changed the title [WIP] Add indicators for agent recalled memory in chat feat(chat): show memory recall indicators on agent messages Apr 9, 2026
Copilot AI requested a review from yacosta738 April 9, 2026 21:24
@yacosta738 yacosta738 marked this pull request as ready for review April 9, 2026 21:27
@yacosta738 yacosta738 merged commit d0b28ef into main Apr 9, 2026
12 of 15 checks passed
@yacosta738 yacosta738 deleted the copilot/add-agent-recalled-context-indicators branch April 9, 2026 21:34
@dallay-bot dallay-bot Bot mentioned this pull request Apr 9, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 9, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat context indicators — show when agent recalls memory Create cross-client i18n governance and shared UX/UI language for Corvus

2 participants