airflow.providers.common.ai.durable.member_stamp

Record which member of a FallbackModel chain answered a model request.

Attributes

MEMBER_STAMP_KEY

MEMBER_MODEL_ID_KEY

MEMBER_CONN_ID_KEY

Classes

MemberStampingModel

Stamp each response with the model_id of the wrapped model.

Functions

get_member_model_id(response)

Return the model_id of the chain member that produced response, if it was stamped.

get_member_conn_id(response)

Return the connection ID of the chain member that produced response, if it was stamped with one.

Module Contents

airflow.providers.common.ai.durable.member_stamp.MEMBER_STAMP_KEY = '__airflow_common_ai__'[source]
airflow.providers.common.ai.durable.member_stamp.MEMBER_MODEL_ID_KEY = 'member_model_id'[source]
airflow.providers.common.ai.durable.member_stamp.MEMBER_CONN_ID_KEY = 'member_conn_id'[source]
airflow.providers.common.ai.durable.member_stamp.get_member_model_id(response)[source]

Return the model_id of the chain member that produced response, if it was stamped.

airflow.providers.common.ai.durable.member_stamp.get_member_conn_id(response)[source]

Return the connection ID of the chain member that produced response, if it was stamped with one.

class airflow.providers.common.ai.durable.member_stamp.MemberStampingModel(wrapped, *, conn_id=None)[source]

Bases: pydantic_ai.models.wrapper.WrapperModel

Stamp each response with the model_id of the wrapped model.

pydantic-ai’s FallbackModel only records which member answered on suspended responses, so a durable replay cannot otherwise tell whether the recorded answer came from a model that is still in the chain. The stamp lives under its own key rather than the __pydantic_ai__ namespace that pydantic-ai owns.

The hook also passes the ID of the connection the model came from, so a replay can tell two connections that serve the same model apart. It is a name, not an identity: it says nothing about the connection’s host or credentials. A member built without one stamps only the model.

conn_id: str | None = None[source]
async request(messages, model_settings, model_request_parameters)[source]

Make a request to the model.

This is ultimately called by pydantic_ai._agent_graph.ModelRequestNode._make_request(…).

async request_stream(messages, model_settings, model_request_parameters, run_context=None)[source]

Make a request to the model and return a streaming response.

Was this entry helpful?