Skip to content

feat(providers): add native OpenAI provider on Pydantic AI - #421

Open
hertznsk wants to merge 12 commits into
microsoft:mainfrom
hertznsk:feat/openai-pydantic-provider
Open

feat(providers): add native OpenAI provider on Pydantic AI#421
hertznsk wants to merge 12 commits into
microsoft:mainfrom
hertznsk:feat/openai-pydantic-provider

Conversation

@hertznsk

Copy link
Copy Markdown
Contributor

Summary

This PR adds a native OpenAI-compatible provider backed by the shared Pydantic AI runtime introduced for Claude in #355. It also extracts the common Pydantic AI execution pipeline so the Claude and OpenAI adapters share Conductor-owned retry, interrupt, event, MCP, structured-output, usage, and partial-output behavior.

Together with the already merged #355, this closes #315 by demonstrating and shipping Pydantic AI as the shared inner runtime for direct Anthropic and OpenAI providers.

What changed

  • adds an openai provider using Pydantic AI and the OpenAI Chat Completions API;
  • supports OpenAI-compatible endpoints through YAML and OPENAI_API_KEY / OPENAI_BASE_URL;
  • preserves Conductor provider contracts for events, retries, interrupts, MCP tools, structured output, usage accounting, reasoning effort, and working directories;
  • extracts the shared Pydantic AI execution pipeline from the Claude provider;
  • adds provider registration, capability validation, diagnostics, documentation, an example workflow, and focused HTTP-stub/integration coverage;
  • completes Claude dialog-agent limits while keeping the shared runtime behavior aligned.

Practical validation

Builds from this branch have been used for an extended period on real working workflows. No shortcomings were identified during that use beyond the separately reported MCP 2.0 compatibility issue in #419. The issue is not specific to this provider implementation and is intentionally tracked separately.

Verification

  • rebased onto the latest origin/main;
  • verified conflict-free against origin/main;
  • make check;
  • make test: 6295 passed, 39 skipped, 8 deselected;
  • CLI smoke test: conductor --help;
  • validation smoke tests for examples/openai-compatible.yaml and a missing workflow path.

Closes #315.

Related: #355, #419.

Drive the real OpenAIChatModel + AsyncOpenAI through run_agent_pipeline
with httpx.MockTransport. Covers success usage mapping, 400 non-retryable
(one request), and 429 retryable then success (two requests).
…gration

Add todo-11 test coverage for the openai provider:
- factory: string + structured construction, YAML api_key precedence over env,
  missing API key raises ValidationError naming OPENAI_API_KEY
- validate-level: runtime/provider: openai, per-agent provider: openai,
  reasoning.effort: max static rejection, tools allowlist, mcp_servers, skills
- retry: existing openai.RateLimitError/BadRequestError tests already cover the
  requirement; no new code needed
- SecretStr redaction for openai ProviderSettings
- temperature: schema-level 1.5 valid / 2.5 invalid, validator-level mixed
  default=openai + per-agent/for_each inline claude override fails naming
  temperature and claude

Also exclude openai-named example files from the copilot backward-compatibility
helper so the existing copilot-only assertion does not trip over
examples/openai-compatible.yaml.

Verification: uv run pytest tests/test_config tests/test_providers/test_factory.py tests/test_providers/test_pydantic_ai_retry.py -x (1253 passed, 9 skipped); make check clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Idea: evaluate Pydantic AI as a shared inner agent runtime for direct OpenAI and Anthropic providers

1 participant