Skip to content

feat: Phase 1B channel-isolated conversation memory#40

Merged
zevorn merged 1 commit intomainfrom
feat/phase1b-channel-isolation
Mar 16, 2026
Merged

feat: Phase 1B channel-isolated conversation memory#40
zevorn merged 1 commit intomainfrom
feat/phase1b-channel-isolation

Conversation

@zevorn
Copy link
Owner

@zevorn zevorn commented Mar 16, 2026

Summary

  • Channel-isolated conversation memory: each source (shell, Feishu, Telegram, scheduler) tags messages with a channel ID. ai_memory_build(channel) filters by channel so different sources maintain independent conversation history in the shared 20-slot ring buffer
  • New API: ai_set_channel() / ai_get_channel(), ai_memory_add() with channel param, ai_memory_clear_channel(), ai_memory_count_channel()
  • Callers updated: feishu.c, telegram.c, tool_sched.c set channel before ai_chat() and reset to SHELL after
  • Smart eviction: drop_oldest_pair_for(channel) prefers evicting same-channel pairs when the buffer is full

Test plan

  • meson compile passes on vexpress-a9 (zero warnings)
  • make build-esp32c3-qemu passes (zero warnings)
  • scripts/check-patch.sh --staged passes
  • QEMU boot test with shell conversation
  • Verify Feishu/Telegram conversations don't leak into shell history

🦞 Generated with Claude Code

Each conversation source (shell, Feishu, Telegram, scheduler)
now tags its messages with a channel ID. ai_memory_build()
filters by channel so different sources maintain independent
conversation history in the shared ring buffer.

New API:
- ai_set_channel() / ai_get_channel() — set active channel
- ai_memory_add() — add message with channel tag
- ai_memory_build() — build messages for a specific channel
- ai_memory_clear_channel() — clear one channel only
- ai_memory_count_channel() — count messages per channel
- AI_CHANNEL_SHELL/FEISHU/TELEGRAM/SCHED constants

Old API (ai_memory_add_message, ai_memory_build_messages)
kept as backward-compatible wrappers defaulting to SHELL.

Callers updated: feishu.c, telegram.c, tool_sched.c now set
their channel ID before ai_chat() and reset to SHELL after.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
@zevorn zevorn merged commit a6aadbc into main Mar 16, 2026
9 checks passed
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.

1 participant