#2055

fix: stop Memory from treating trigger messages as the user's words

Draft4pmtongwants to merge intofrom

Summary

Tasks started by a schedule, a webhook or Slack were saved in the Session history as ordinary user messages. Memory treats user messages as the user's own words, so it could learn from text the user never wrote.

Now each user message records who sent it, and Memory only uses messages the user wrote.

Changes

  • Message source. A user message records its source.
    • Trigger tasks send scheduled.
    • Chat, Improve, and Session sends from this device or Remote Control count as the user's own.
    • A queued follow-up keeps the source of the request that queued it.
  • Memory checks.
    • Automatic Memory skips messages the user did not write.
    • An agent cannot cite those messages as something the user said.
    • Their text is treated as external content, not as the user's words.
  • Unknown sources fail closed. A message with a missing or unknown source is never treated as the user's.
    • Session input saved before this change has no source. Eigent looks it up from the request that sent it, so existing history keeps working.
  • Session context. A Session's context reads its own input whether or not that input carries the new source field.

Testing

  • Backend: tests/app/lightweight_memory, tests/app/agent/toolkit, test_chat_controller.py, test_managed_context_source.py and workspace_runtime/test_service.py give 557 passed, 1 skipped. New tests cover:
    • trigger messages being excluded;
    • citations of trigger messages being rejected;
    • a missing source failing closed;
    • a queued follow-up keeping its trigger source;
    • older managed input without a source.
  • Frontend: test/unit/store/chatStore.test.ts passes (238 tests). It checks that trigger tasks send source: "scheduled".

Activity

1

This pull request is a draft

Merging is unavailable until it is marked ready for review.