ResponseContext Class

Runtime context exposed to response handlers and used by hosting orchestration.

  • response identifier

  • shutdown signal flag

  • async input/history resolution

Constructor

ResponseContext(*, response_id: str, mode_flags: ResponseModeFlags, request: CreateResponse | None = None, created_at: datetime | None = None, provider: ResponseProviderProtocol | None = None, input_items: list[InputParam] | list[OutputItem] | None = None, previous_response_id: str | None = None, conversation_id: str | None = None, history_limit: int = 100, client_headers: dict[str, str] | None = None, query_parameters: dict[str, str] | None = None, isolation: IsolationContext | None = None, prefetched_history_ids: list[str] | None = None)

Keyword-Only Parameters

Name Description
response_id
Required
mode_flags
Required
request
Default value: None
created_at
Default value: None
provider
Default value: None
input_items
Default value: None
previous_response_id
Default value: None
conversation_id
Default value: None
history_limit
Default value: 100
client_headers
Default value: None
query_parameters
Default value: None
isolation
Default value: None
prefetched_history_ids
Default value: None

Methods

get_history

Resolve and cache conversation history items via the provider.

When prefetched history IDs are available (from eager validation), the provider's get_history_item_ids call is skipped and only get_items is invoked to materialise the items.

get_input_items

Return the caller's input items as <xref:azure.ai.agentserver.responses.Item> subtypes.

Inline items are returned as-is — the same <xref:azure.ai.agentserver.responses.Item> subtypes from the original request (e.g. <xref:azure.ai.agentserver.responses.ItemMessage>, <xref:azure.ai.agentserver.responses.FunctionCallOutputItemParam>). <xref:azure.ai.agentserver.responses.ItemReferenceParam> entries are batch-resolved via the provider and converted back to <xref:azure.ai.agentserver.responses.Item> subtypes. Unresolvable references (provider returns None) are silently dropped.

get_input_text

Resolve input items and extract all text content as a single string.

Convenience method that calls get_input_items, filters for <xref:azure.ai.agentserver.responses.ItemMessage> items, expands their content, and joins all <xref:azure.ai.agentserver.responses.MessageContentInputTextContent> text values with newline separators.

get_history

Resolve and cache conversation history items via the provider.

When prefetched history IDs are available (from eager validation), the provider's get_history_item_ids call is skipped and only get_items is invoked to materialise the items.

async get_history() -> Sequence[OutputItem]

Returns

Type Description

A tuple of conversation history items.

get_input_items

Return the caller's input items as <xref:azure.ai.agentserver.responses.Item> subtypes.

Inline items are returned as-is — the same <xref:azure.ai.agentserver.responses.Item> subtypes from the original request (e.g. <xref:azure.ai.agentserver.responses.ItemMessage>, <xref:azure.ai.agentserver.responses.FunctionCallOutputItemParam>). <xref:azure.ai.agentserver.responses.ItemReferenceParam> entries are batch-resolved via the provider and converted back to <xref:azure.ai.agentserver.responses.Item> subtypes. Unresolvable references (provider returns None) are silently dropped.

async get_input_items(*, resolve_references: bool = True) -> Sequence[Item]

Keyword-Only Parameters

Name Description
resolve_references

When True (default), <xref:azure.ai.agentserver.responses.ItemReferenceParam> items are resolved via the provider and returned as their concrete <xref:azure.ai.agentserver.responses.Item> subtype. When False, item references are left as <xref:azure.ai.agentserver.responses.ItemReferenceParam> in the returned sequence.

Default value: True

Returns

Type Description

A tuple of input items.

get_input_text

Resolve input items and extract all text content as a single string.

Convenience method that calls get_input_items, filters for <xref:azure.ai.agentserver.responses.ItemMessage> items, expands their content, and joins all <xref:azure.ai.agentserver.responses.MessageContentInputTextContent> text values with newline separators.

async get_input_text(*, resolve_references: bool = True) -> str

Keyword-Only Parameters

Name Description
resolve_references

When True (default), item references are resolved before extracting text.

Default value: True

Returns

Type Description
str

The combined text content, or "" if no text found.