Feature Request: Per-thread context isolation for agents
- Dominant language
- Rust
- Stars
- 32.7k
- Forks
- 4.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 253
Description
## Summary
Add an **optional** per-thread context isolation mode for agents. When enabled, each thread maintains its own independent conversation history with an agent, rather than sharing context across threads. This should be a user-configurable option, not the default behavior.
## Motivation
Currently, agent context can leak across threads or channels. When an agent is referenced in multiple threads, conversation history from one thread may influence responses in another, even when the conversations should be independent.
This is particularly problematic for:
- **Parallel work**: Multiple threads discussing different topics with the same agent
- **Privacy**: Sensitive information in one thread shouldn't inform responses in another
- **Debugging**: Difficult to trace issues when context is shared across conversations
## Proposed Behavior
When **per-thread isolation is enabled** for an agent:
1. **Separate conversation context per thread ID** — thread root event determines the context boundary
2. **No cross-thread context sharing** — a response in thread A does not affect thread B
3. **Persistent thread-scoped memory** — when returning to a thread, the agent recalls that specific conversation
**Default behavior:** Shared context across threads (current behavior)
## Implementation Considerations
- Thread ID could be the root event ID (`e` tag for reply root)
- Agent sessions keyed by `(agent_pubkey, thread_root_id)` when isolation is enabled
- Existing per-channel context (already implemented) is a good starting point
- Core memory and workspace could remain shared (useful for persistent learning)
- **Configuration:** Could be a per-agent setting (e.g., checkbox in agent config) or per-channel setting
## Configuration Options
Possible approaches:
1. **Per-agent toggle** — "Isolate context per thread" checkbox in agent settings
2. **Per-channel toggle** — Channel-level setting for all agents
3. **Per-mention flag** — Temporary override like `@Agent (isolated)`
## Alternatives
- **Per-channel isolation** (current): Good, but threads within a channel still share context
- **Per-conversation isolation** (requested): Finer-grained, aligns with user mental model
- **No isolation** (problematic): Causes context leakage
## Related
- Agent session model in buzz-acp harness
- Conversation context management
Contributor guide
Assessment
This issue has not been assessed yet.