Context
In #191 / PR #271, the core issue was fixed: retrieved LTM is now injected before the last user message (instead of after), which resolves the assistant-prefill error on Claude 4.6+ models and improves instruction-following.
However, PR #271 also renamed the <user_context> XML tag to <retrieved_memory>. This tag rename is a breaking change for users who depend on the existing <user_context> tag in their system prompts, parsing logic, or downstream processing. That rename has been reverted to preserve backwards compatibility.
Proposal
Add a configurable context_tag parameter to AgentCoreMemorySessionManager (or AgentCoreMemoryConfig) that lets users customize the XML tag used to wrap retrieved memory context.
- Default value:
user_context (preserves backwards compatibility)
- Users who prefer a more semantically accurate tag like
retrieved_memory can opt in without breaking existing setups
Example API
config = AgentCoreMemoryConfig(
memory_id="...",
session_id="...",
actor_id="...",
context_tag="retrieved_memory", # optional, defaults to "user_context"
)
This approach gives users flexibility without forcing a breaking change.
Related