Skip to content

Utilities

tac_microsoft.utils

Utility functions for TAC Agent Framework integration.

format_memory_context

format_memory_context(
    memory_response: TACMemoryResponse | None,
    user_message: str,
) -> str

Format TAC auto-retrieved memory into an augmented user message.

TAC automatically retrieves relevant memories for the profile when a message arrives. This function formats those memories as structured context and prepends them to the user message so the agent has personalization context without needing a separate tool call.

Parameters:

Name Type Description Default
memory_response TACMemoryResponse | None

Auto-retrieved memory from TAC's on_message_ready callback. May be None if memory is not configured or no memories exist.

required
user_message str

The original user message.

required

Returns:

Type Description
str

The user message, optionally prefixed with formatted memory context.