Build Context For Task • AI Agent SDK

build_context_for_task: Merges relevant short-term, long-term, entity, user memories

build_context_for_task

Method

</div>

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

Merges relevant short-term, long-term, entity, user memories into a single text block with deduplication and clean formatting.

Signature

python
def build_context_for_task(task_descr: str, user_id: Optional[str], additional: str, max_items: int, include_in_output: Optional[bool]) -> str

Parameters

ParamField str

No description available.

ParamField Optional[str]

No description available.

ParamField str

No description available.

ParamField int

No description available.

ParamField Optional[bool]

If None, memory content is included (the primary purpose of this method is to feed retrieved memory into the prompt). If True, memory content is always included. If False, memory content is never included (only logged for debugging).

Returns

ResponseField str

The result of the operation.

Uses

  • c.isspace
  • content.rfind
  • format_content
  • normalize_content
  • seen_contents.add
  • logger.debug
  • search_short_term
  • search_long_term
  • search_entity
  • search_user_memory

Used By

Source

View on GitHub

praisonaiagents/memory/memory.py at line 1969


Related Documentation