Skip to content

fix: align agentId resolution to prevent scope mismatch (#231)#309

Open
AliceLJY wants to merge 1 commit intomasterfrom
fix/align-agentid-resolution
Open

fix: align agentId resolution to prevent scope mismatch (#231)#309
AliceLJY wants to merge 1 commit intomasterfrom
fix/align-agentid-resolution

Conversation

@AliceLJY
Copy link
Collaborator

Summary

  • Root cause: memory_update, memory_forget, memory_stats, and memory_list used resolveRuntimeAgentId(runtimeContext.agentId, runtimeCtx) in their execute functions, which re-resolves agentId from the execute-time runtimeCtx. When the execute-time context provides a different agentId than the definition-time runtimeContext.agentId, this causes "Memory is outside accessible scopes" errors because the scope filter is built from a different agentId than what memory_store used.
  • Fix: Replace resolveRuntimeAgentId(runtimeContext.agentId, runtimeCtx) with runtimeContext.agentId in all 4 tools, aligning them with memory_store's pattern of using the stable definition-time agentId.
  • PR fix: use resolveToolContext in memory_forget and memory_update #270 partially addressed agentId resolution but the runtimeCtx override path remained in these 4 tools.

Fixes #231

Test plan

  • All existing tests pass (npm test — 0 failures)
  • Verify that memory_store + memory_update/forget/stats/list use consistent agentId when execute-time context differs from definition-time context

🤖 Generated with Claude Code

… context

memory_update/forget/stats/list were re-resolving agentId from execute-time runtimeCtx, causing scope mismatch when the execute-time context provides a different agentId than definition-time. This aligns all tools with memory_store's pattern of using the stable definition-time runtimeContext.agentId.

Fixes #231

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

memory_update rejects agent-scoped memories as outside accessible scopes

2 participants