Open
Description
My initial use case here is to know which provider and model combination produced the output when using FallbackModel
. Right now we can know the model name (possibly different than the input model name str) but not the provider. Example:
from pydantic_ai import Agent
from pydantic_ai.models import infer_model
from pydantic_ai.models.fallback import FallbackModel
agent = Agent(
model=FallbackModel([
infer_model("provider_1:model_1"),
infer_model("provider_2:model_1"),
]),
)
result = await agent.run(
user_prompt="This is a test. Respond with only the word 'okay'."
)
result.new_messages()[-1].model_name
But I think there are a broader set of related use cases:
- knowing which model succeeded when there are multiple instances of the same provider model pair in a Fallback scenario with different settings post FallbackModel to allow model_settings specific to each model #2119
- introspection on failed model calls prior to the success call
Is there a way for AgentRunResult
to learn more about the models and calls behind it including each model in a Fallback scenario?