Skip to content

TemporalAgent drops openai_ reasoning effort #2937

@leecjohnny

Description

@leecjohnny

Initial Checks

Description

To reproduce:

  1. run the example code
  2. review the https request to OpenAI logged in logfire for the 2 runs

For temporal agent request body:

{
  "messages": [
    {
      "content": "You're an expert in geography.",
      "role": "system"
    },
    {
      "role": "user",
      "content": "What is the capital of Mexico?"
    }
  ],
  "model": "gpt-5-nano",
  "stream": false
}

For normal agent request body:

{
  "messages": [
    {
      "content": "You're an expert in geography.",
      "role": "system"
    },
    {
      "role": "user",
      "content": "What is the capital of Mexico?"
    }
  ],
  "model": "gpt-5-nano",
  "reasoning_effort": "high",
  "stream": false
}

Example Code

import asyncio
import uuid

import dotenv
import logfire
from pydantic_ai import Agent
from pydantic_ai.durable_exec.temporal import (
    AgentPlugin,
    PydanticAIPlugin,
    TemporalAgent,
)
from pydantic_ai.models.openai import OpenAIChatModelSettings
from temporalio import workflow
from temporalio.client import Client
from temporalio.worker import Worker

dotenv.load_dotenv()
logfire.configure(
    scrubbing=False,
)
logfire.instrument_openai(suppress_other_instrumentation=False)
logfire.instrument_pydantic_ai()
logfire.instrument_httpx(capture_all=True)

agent = Agent(
    "gpt-5-nano",
    instructions="You're an expert in geography.",
    name="geography",
    model_settings=OpenAIChatModelSettings(
        openai_reasoning_effort="high",
    ),
)

temporal_agent = TemporalAgent(agent, name="temporal_geography")


@workflow.defn
class GeographyWorkflow:
    @workflow.run
    async def run(self, prompt: str) -> str:
        result = await temporal_agent.run(prompt)
        return result.output


async def main():
    client = await Client.connect(
        "localhost:7233",
        plugins=[PydanticAIPlugin()],
    )

    async with Worker(
        client,
        task_queue="geography",
        workflows=[GeographyWorkflow],
        plugins=[AgentPlugin(temporal_agent)],
    ):
        output = await client.execute_workflow(
            GeographyWorkflow.run,
            args=["What is the capital of Mexico?"],
            id=f"geography-{uuid.uuid4()}",
            task_queue="geography",
        )
        print(output)
        # > Mexico City (Ciudad de México, CDMX)
    normal_output = await agent.run("What is the capital of Mexico?")
    print(normal_output.output)


if __name__ == "__main__":
    asyncio.run(main())

Python, Pydantic AI & LLM client version

python-version = "3.12"

name = "openai"
version = "1.107.3"

name = "pydantic-ai-slim"
version = "1.0.8"

name = "temporalio"
version = "1.17.0"

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions