Skip to content

LCORE-4707: Bumped PAI version to 2.38.0 - #3020

Merged
tisnik merged 1 commit into
lightspeed-core:mainfrom
asimurka:bump/pydantic-ai-2.38
Oct 26, 2026
Merged

tisnik merged 1 commit into
lightspeed-core:mainfrom
asimurka:bump/pydantic-ai-2.38

Conversation

@asimurka

@asimurka asimurka commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Bump Pydantic AI to 2.38.0 (requires openai≥3) and pin litellm to 1.107.0rc2 so the openai 3 / litellm conflict resolves cleanly. Adapt call sites for PAI 2.38 API changes (AbstractModel, AsyncHTTPClient, SourcedInstruction, _model_id_namespace). Keep legacy httpx clients with # type: ignore[arg-type] where OpenAI 3 types http_client as httpx2 only (runtime still accepts httpx until PAI v3). Narrow extract_conversation_id via isinstance(..., Model) instead of getattr. Update unit tests/mocks accordingly.

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library [pyproject.toml + uv.lock]
  • Bump-up dependent library [requirements.*.txt for Konflux]
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: Cursor (Composer)
  • Generated by: N/A

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • uv sync --group dev --group ogxlibdev
  • uv run make format && uv run make verify
  • uv run make test-unit
  • Confirm watsonx / granite guardian / OGX providers still construct AsyncOpenAI with legacy httpx.AsyncClient (type ignores only; no httpx2 migration in this PR).

Summary by CodeRabbit

  • Bug Fixes
    • Conversation ID extraction now safely returns no ID for model-like objects without model settings.
    • Streamed responses now retain the provider namespace when API errors are mapped, improving provider-specific error handling.
  • Compatibility
    • Improved compatibility with asynchronous HTTP clients across supported OpenAI client versions.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between feda2b0 and c41f819.

Files ignored due to path filters: 1
  • uv.lock is excluded by !**/*.lock
Files selected for processing: 11
  • pyproject.toml
  • src/providers/inference/watsonx/pai_provider.py
  • src/pydantic_ai_lightspeed/capabilities/granite_guardian/_capability.py
  • src/pydantic_ai_lightspeed/capabilities/utils.py
  • src/pydantic_ai_lightspeed/ogx/_model.py
  • src/pydantic_ai_lightspeed/ogx/_provider.py
  • tests/unit/providers/inference/azure/test_provider.py
  • tests/unit/pydantic_ai_lightspeed/capabilities/granite_guardian/test_capability.py
  • tests/unit/pydantic_ai_lightspeed/capabilities/question_validity/test_capability.py
  • tests/unit/pydantic_ai_lightspeed/ogx/test_model.py
  • tests/unit/utils/test_pydantic_ai.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details
Context from checks skipped due to timeout: 23
  • GitHub Check: Pylinter
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: E2E: server / ci / tls
  • GitHub Check: E2E: library / ci / other
  • GitHub Check: E2E: server / ci / default
  • GitHub Check: E2E: server / ci / rbac
  • GitHub Check: E2E: library / ci / mcp
  • GitHub Check: E2E: library / ci / authorized
  • GitHub Check: E2E: server / ci / other
  • GitHub Check: E2E: library / ci / shields
  • GitHub Check: E2E: library / ci / default
  • GitHub Check: E2E: server / ci / mcp
  • GitHub Check: E2E: library / ci / rbac
  • GitHub Check: E2E: library / ci / skills
  • GitHub Check: E2E: server / ci / shields
  • GitHub Check: E2E: server / ci / authorized
  • GitHub Check: E2E: server / ci / skills
  • GitHub Check: build-pr
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-8-on-pull-request
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: integration_tests (3.14)
  • GitHub Check: integration_tests (3.13)
Additional context used
GitHub Check: Bandit
src/providers/inference/watsonx/pai_provider.py

[warning] 63-63:
Call to httpx without timeout

Additional comments: 11
src/pydantic_ai_lightspeed/ogx/_model.py: 1

488-488: LGTM!

Also applies to: 510-510

tests/unit/pydantic_ai_lightspeed/ogx/test_model.py: 1

593-593: LGTM!

pyproject.toml: 1

60-60: LGTM!

Also applies to: 88-88

src/pydantic_ai_lightspeed/ogx/_provider.py: 1

12-12: LGTM!

Also applies to: 92-92, 106-107, 127-127, 129-129, 140-140, 147-148, 157-157

src/providers/inference/watsonx/pai_provider.py: 1

58-58: LGTM!

Also applies to: 63-63

src/pydantic_ai_lightspeed/capabilities/granite_guardian/_capability.py: 1

399-399: LGTM!

Also applies to: 408-408

tests/unit/providers/inference/azure/test_provider.py: 1

66-69: LGTM!

Also applies to: 72-72

tests/unit/utils/test_pydantic_ai.py: 1

226-229: LGTM!

src/pydantic_ai_lightspeed/capabilities/utils.py: 1

7-7: LGTM!

Also applies to: 52-52, 60-63, 71-73

tests/unit/pydantic_ai_lightspeed/capabilities/granite_guardian/test_capability.py: 1

13-13: LGTM!

Also applies to: 409-409, 504-504

tests/unit/pydantic_ai_lightspeed/capabilities/question_validity/test_capability.py: 1

10-10: LGTM!

Also applies to: 75-75, 77-77, 81-81, 83-83, 87-87, 89-89, 93-93, 95-95, 99-99, 101-103, 105-107, 276-276, 377-377, 607-607

Walkthrough

This change updates dependency pins and HTTP client type annotations. It also broadens conversation-ID extraction to accept AbstractModel and passes the provider model ID namespace into OGX streamed responses and API error mapping.

Changes

Runtime compatibility and OGX updates

Layer / File(s) Summary
Dependency pins and HTTP client typing
pyproject.toml, src/pydantic_ai_lightspeed/ogx/_provider.py, src/providers/inference/watsonx/pai_provider.py, src/pydantic_ai_lightspeed/capabilities/granite_guardian/_capability.py, tests/unit/providers/inference/azure/test_provider.py, tests/unit/utils/test_pydantic_ai.py
The dependency declarations and HTTP client annotations are updated. The Azure client mock and instruction assertion are also adjusted.
Conversation-ID extraction
src/pydantic_ai_lightspeed/capabilities/utils.py, tests/unit/pydantic_ai_lightspeed/capabilities/granite_guardian/test_capability.py, tests/unit/pydantic_ai_lightspeed/capabilities/question_validity/test_capability.py
extract_conversation_id accepts AbstractModel and returns None for values that are not Model instances. Capability tests use TestModel fixtures and cover an object without model settings.
Streamed-response namespace
src/pydantic_ai_lightspeed/ogx/_model.py, tests/unit/pydantic_ai_lightspeed/ogx/test_model.py
OGX passes the provider model ID namespace to API error mapping and the streamed response. The stream-test fixture sets the namespace.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Possibly related PRs

Suggested reviewers: tisnik, jrobertboos

Merge Risk: Minimal · up to c41f8

The reviewed changes are ready to merge after normal checks; no unresolved issue was identified.

Pre-merge checks: Passed 7
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the primary change: updating Pydantic AI to version 2.38.0. It is concise and directly related to the pull request changes.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 10 files. (1 skipped: …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Performance And Algorithmic Complexity Passed PASSED. The pull request changes dependency pins, type annotations, constant-time conversation-ID extraction, streamed-response metadata, and test fixtures. No changed production path adds nested iter…
Security And Secret Handling Passed PASSED. The pull-request diff contains dependency updates, HTTP client type compatibility changes, conversation-ID type validation, provider namespace propagation, and test mock updates. It adds no pl…
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 10 files. (1 skipped: 1 unsupported.)

Full details: Performance And Algorithmic Complexity

Explanation

PASSED. The pull request changes dependency pins, type annotations, constant-time conversation-ID extraction, streamed-response metadata, and test fixtures. No changed production path adds nested iteration, per-item API or database queries, repeated parsing or regex compilation, unbounded state, or unbounded list/API operations. The only new iteration is any(...) in a unit-test assertion.

Full details: Security And Secret Handling

Explanation

PASSED. The pull-request diff contains dependency updates, HTTP client type compatibility changes, conversation-ID type validation, provider namespace propagation, and test mock updates. It adds no plaintext secret or token, logging of sensitive data, API endpoint/auth change, injection sink, or Kubernetes Secret manifest change. Existing API keys and credentials remain environment/configuration inputs and are not logged.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
✨ Simplify code
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread src/providers/inference/watsonx/pai_provider.py Dismissed
from ogx_client import AsyncOgxClient
from openai import AsyncOpenAI
from pydantic_ai import ModelProfile
from pydantic_ai._http import AsyncHTTPClient

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type union for httpx and httpx2 clients

Comment thread pyproject.toml
"google-cloud-aiplatform>=1.130.0",
# API inference: remote::watsonx
# LCORE-1565
"litellm>=1.88.6",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WatsonX no longer uses litellm dependency, litellm is already present in root deps.

Comment thread pyproject.toml
"genai-prices>=0.1.12",
# Used for Pydantic AI
"pydantic-ai==2.27.1",
"pydantic-ai==2.38.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required for vLLM provider

@tisnik tisnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tisnik
tisnik merged commit 995ea10 into lightspeed-core:main Oct 26, 2026
42 of 43 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Oct 26, 2026
5 of 20 tasks
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.

3 participants