Skip to content

Scope prompt recent history by session - #4274

Merged
Re-bin merged 2 commits into
mainfrom
cy/4259-session-scoped-history
Jun 10, 2026
Merged

Scope prompt recent history by session#4274
Re-bin merged 2 commits into
mainfrom
cy/4259-session-scoped-history

Conversation

@chengyongru

Copy link
Copy Markdown
Collaborator

Summary

  • Add optional session_key metadata to history.jsonl writes from summaries and raw archive fallbacks.
  • Filter # Recent History prompt injection by current session for non-unified mode.
  • In unified mode, keep user-visible/global history while excluding internal cron/dream/heartbeat sessions; cron sessions can still see their own cron history.

Verification

  • $verify: external package-consumer script after python -m pip install -e . passed non-unified, unified-user, and unified-cron prompt checks.
  • python -m pytest tests/agent/test_memory_store.py tests/agent/test_context_prompt_cache.py tests/agent/test_consolidator.py tests/agent/test_unified_session.py tests/cron/test_cron_tool_list.py tests/cron/test_cron_service.py -q — 192 passed.
  • ruff check nanobot/agent/memory.py nanobot/agent/context.py nanobot/agent/loop.py tests/agent/test_memory_store.py tests/agent/test_context_prompt_cache.py tests/agent/test_consolidator.py — all checks passed.
  • $simplify: reduced unified visibility filtering and raw archive callback boilerplate; focused checks still passed.

Fixes #4259

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

history.jsonl 跨会话注入导致上下文污染

2 participants