Skip to content

Add arbiter agent to gate memory retrieval interruptions - #62

Draft
adamd9 with Copilot wants to merge 2 commits into
mainfrom
copilot/add-arbiter-agent-memory-retrieval
Draft

adamd9 with Copilot wants to merge 2 commits into
mainfrom
copilot/add-arbiter-agent-memory-retrieval

Conversation

Copilot AI commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Memory retrieval currently interrupts conversations (via shadow turns) automatically whenever new memories arrive, leading to poorly-timed or excessive interruptions. This adds a lightweight MemoryArbiter component that decides allow/deny/defer before any interruption fires.

New: src/memory/arbiter.ts

Stateless decision engine with three ordered policies:

  1. Priority-tag force-allow — rationale containing any configured tag (e.g. "safety", "billing") bypasses all other rules
  2. Rate-limit — denies if last allowed interruption was within rateLimitMs (default 30 s); returns suggestedDelayMs
  3. Confidence threshold — denies if score below confidenceThreshold (default 0.5); score = min(1, newItemCount / 3)
arbiter.decide({ query, newItemCount: 2, rationale: 'billing issue' })
// → { decision: 'allow', confidence: 1.0, reason: 'priority tag "billing" matched' }

Config: MemoryConfig (persisted in memory-config.json, tunable via /memory-config API)

Field Default Description
arbiter_enabled false Feature flag — off by default
arbiter_rate_limit_ms 30000 Min ms between allowed interruptions
arbiter_confidence_threshold 0.5 Min confidence to allow
arbiter_priority_tags ["safety","billing","urgent","critical"] Force-allow tags

Integration: MemoryModule.retrieveWithLate()

  • Syncs arbiter config on every call
  • Gates both the sync newMemories return value and the async onLateArrival callback
  • Suppressed decisions logged to console and persisted as memory_arbiter DB events (metadata only — no memory content in logs)
  • Arbiter state resets on conversation complete and clearCache()

Tests: tests/unit/memory-arbiter.test.ts

10 unit tests covering allow, deny, rate-limit, priority-tag override, case-insensitive tag matching, zero items, reset, live reconfigure, and rapid-call suppression. Runnable via npm run test:arbiter.

…upt conversations

Agent-Logs-Url: https://github.com/adamd9/delegate1/sessions/869cb696-86e1-4431-952b-aeee98f8eb0c

Co-authored-by: adamd9 <4033496+adamd9@users.noreply.github.com>
Copilot AI changed the title [WIP] Add arbiter agent for memory retrieval interruptions Add arbiter agent to gate memory retrieval interruptions Apr 1, 2026
Copilot AI requested a review from adamd9 April 1, 2026 22:35
@adamd9 adamd9 closed this Apr 2, 2026
@adamd9 adamd9 reopened this Apr 2, 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.

Add arbiter agent to decide when memory retrieval should interrupt conversations

2 participants