Build Context • AI Agent SDK

build_context: Build a prepared turn context from agent and request.

build_context

Method

</div>

This is a method of the DefaultTurnContextBuilder class in the context_builder module.

Build a prepared turn context from agent and request.

Signature

python
def build_context(agent: AgentProtocol, prompt: str) -> PreparedTurnContext

Parameters

ParamField AgentProtocol

The agent instance

ParamField str

The user prompt for this turn **kwargs: Additional request parameters including: – model: Override model ID – tools: Override tools list. Omit or pass None to use agent.tools. Pass [] to explicitly disable tools for this turn. – stream: Enable streaming – temperature: Model temperature – max_tokens: Token limit – session_id: Session identifier – turn_id: Turn identifier

Returns

ResponseField PreparedTurnContext

A prepared turn context ready for execution

Uses

  • PreparedTurnContext
  • time.time
  • logger.debug
  • context.get_message_count
  • logger.error

Source

View on GitHub

praisonaiagents/runtime/context_builder.py at line 48


Related Documentation