Get Context • AI Agent SDK
get_context: Return retrieved memory as a prompt-ready context string.
get_context
Method
</div>
Return retrieved memory as a prompt-ready context string.
Satisfies `AgentMemoryProtocol (used by Agent.get_memory_context()) so the non-prompt-caching code path can inject memory into the system prompt. Without this, hasattr(memory, 'get_context')` was False and the fallback branch always returned “”.
Signature
def get_context(query: Optional[str]) -> strParameters
ParamField
Optional[str]No description available.
Returns
ResponseField
strThe result of the operation.
Uses
build_context_for_task
Used By
Source
View on GitHubpraisonaiagents/memory/memory.py at line 2162