Skip to content

fix: scope agent memory files to selected agent in admin UI#1049

Merged
chubes4 merged 1 commit intomainfrom
fix/agent-memory-scope
Apr 14, 2026
Merged

fix: scope agent memory files to selected agent in admin UI#1049
chubes4 merged 1 commit intomainfrom
fix/agent-memory-scope

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Apr 14, 2026

Summary

When switching agents in the dropdown on the Agents admin page, the MEMORY.md content (and all memory files) never changed — it always showed the same agent's data.

Root Cause

agentFiles.js used raw @wordpress/api-fetch instead of the shared client from @shared/utils/api, completely bypassing the agent ID interceptor. The agent_id param was never sent to the REST API, so the backend always fell back to the default agent.

Fixes

  • api/agentFiles.js — Replaced raw apiFetch with the shared client. GET requests now receive agent_id via the interceptor automatically. PUT/DELETE mutations pass agent_id explicitly from the Zustand store since the interceptor only covers GET.

  • queries/agentFiles.js — Added selectedAgentId to all TanStack Query cache keys (KEYS, DAILY_KEYS, CONTEXT_KEYS) so each agent's files are cached independently and refetch automatically on agent switch.

  • Api/AgentFiles.php — The 4 daily memory REST handlers (list_daily_files, get_daily_file, put_daily_file, delete_daily_file) now extract agent_id from the request and forward it to DailyMemoryAbilities, matching the pattern already used by the core agent file handlers above them.

The agent files API (agentFiles.js) was using raw @wordpress/api-fetch
instead of the shared client, bypassing the agent ID interceptor entirely.
Memory content never changed when switching agents in the dropdown.

Three fixes:
- Replace raw apiFetch with shared client in agentFiles.js so GET requests
  receive agent_id via the interceptor, and mutations pass it explicitly
- Include selectedAgentId in all TanStack Query cache keys so each agent's
  files are cached independently
- Forward agent_id from REST request to DailyMemoryAbilities in all four
  daily memory PHP handlers (list, get, put, delete)
@chubes4 chubes4 merged commit 87052a0 into main Apr 14, 2026
1 check passed
@chubes4 chubes4 deleted the fix/agent-memory-scope branch April 14, 2026 01:28
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