Get Context • AI Agent SDK

get_context: Return retrieved memory as a prompt-ready context string.

get_context

Method

</div>

This is a method of the Memory class in the memory module.

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

python
def get_context(query: Optional[str]) -> str

Parameters

ParamField Optional[str]

No description available.

Returns

ResponseField str

The result of the operation.

Uses

  • build_context_for_task

Used By

Source

View on GitHub

praisonaiagents/memory/memory.py at line 2162


Related Documentation