Resolve Runtime • AI Agent SDK

resolve_runtime: Resolve runtime for the given agent and model at turn-time.

resolve_runtime

Function

</div>

This function is defined in the resolve module.

Resolve runtime for the given agent and model at turn-time.

This is the main API that handoffs and sub-agent invocations should call to get the appropriate runtime instead of using construction-time pins.

Signature

python
def resolve_runtime(agent_id: str, model_ref: str, session_ctx: SessionContext) -> AgentRuntimeProtocol

Parameters

ParamField str

Unique identifier for the agent

ParamField str

Model reference (e.g., ‘gpt-4o’, ‘claude-3-sonnet’)

ParamField SessionContext

Session context for caching and tracking

Returns

ResponseField AgentRuntimeProtocol

AgentRuntimeProtocol instance configured for the model

Exceptions

RuntimeError

If no suitable runtime can be resolved

Usage

python
session_ctx = SessionContext(
        session_id="session_123",
        timestamp=time.time(),
        handoff_depth=1
    )
    runtime = resolve_runtime("agent_1", "gpt-4o", session_ctx)
    response = runtime.execute("Hello, world!")

Uses

  • time.time
  • logger.debug
  • logger.info
  • get_global_resolver
  • resolver.supports_model
  • RuntimeError
  • resolver.resolve
  • logger.error

Used By

Source

View on GitHub

praisonaiagents/runtime/resolve.py at line 232