Skip to content

LCORE-2850: renamed pydantic ai utils module#2117

Merged
tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-2850-renamed-pydantic-ai-utils-module
Jul 12, 2026
Merged

LCORE-2850: renamed pydantic ai utils module#2117
tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-2850-renamed-pydantic-ai-utils-module

Conversation

@tisnik

@tisnik tisnik commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Description

LCORE-2850: renamed pydantic_ai utils module to avoid tool confusion.

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • 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

  • Assisted-by: N/A
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue #LCORE-2850

Summary by CodeRabbit

  • New Features

    • Added support for configuring agents with capability-based tools and skills.
    • Improved compatibility with Responses API behavior when creating agents.
    • Capability tools are now exposed with clearer metadata and descriptions.
  • Bug Fixes

    • Updated agent and tool handling to use the improved configuration flow across supported endpoints.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2a8a13f2-d8ad-415a-afbf-42af1ab6091e

📥 Commits

Reviewing files that changed from the base of the PR and between e8e226c and b645bdb.

📒 Files selected for processing (6)
  • src/app/endpoints/a2a.py
  • src/app/endpoints/tools.py
  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/utils/pydantic_ai_helpers.py
  • tests/unit/utils/test_pydantic_ai.py
📜 Recent review details
⏰ Context from checks skipped due to timeout. (13)
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: Pylinter
  • GitHub Check: spectral
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-7-on-pull-request
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 2
🧰 Additional context used
📓 Path-based instructions (4)
src/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.py: Use absolute imports for internal modules: from authentication import get_auth_dependency
Llama Stack imports: Use from llama_stack_client import AsyncLlamaStackClient
Check constants.py for shared constants before defining new ones
All modules must start with descriptive docstrings explaining purpose
Use logger = get_logger(__name__) from log.py for module logging
All functions must have complete type annotations for parameters and return types, use modern syntax (str | int), and include descriptive docstrings
Use snake_case with descriptive, action-oriented names for functions (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns; return new data structures instead of modifying function parameters
Use async def for I/O operations and external API calls
Use standard log levels with clear purposes: debug() for diagnostic info, info() for program execution, warning() for unexpected events, error() for serious problems
All classes must have descriptive docstrings explaining purpose and use PascalCase with standard suffixes: Configuration, Error/Exception, Resolver, Interface
Abstract classes must use ABC with @abstractmethod decorators
Follow Google Python docstring conventions with required sections: Parameters, Returns, Raises, and Attributes for classes

Files:

  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/a2a.py
  • src/utils/pydantic_ai_helpers.py
**/*

📄 CodeRabbit inference engine (Custom checks)

**/*: Flag meaningful O(n^2)+ algorithms on non-trivial inputs, including handlers and Kubernetes list operations.
Flag N+1 patterns that list items and then query once per item, including Kubernetes API and database access.
Flag expensive work inside loops, including API calls, JSON parsing, and regex compilation.
Flag unbounded growth in caches, watchers, or buffers when eviction or limits are missing.
Flag missing pagination or limits on list operations and API endpoints.
Flag secrets or tokens logged in plaintext or hardcoded in source.
Flag API endpoints missing authentication or authorization.
Flag injection vulnerabilities, including SQL injection, command injection, and path traversal.
Flag sensitive data leaked in API responses, WebSocket messages, or logs.
Flag Kubernetes Secrets and Red Hat secrets missing OwnerReferences.

Files:

  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/app/endpoints/tools.py
  • tests/unit/utils/test_pydantic_ai.py
  • src/app/endpoints/a2a.py
  • src/utils/pydantic_ai_helpers.py
src/app/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/app/**/*.py: FastAPI dependencies: Import from fastapi module for APIRouter, HTTPException, Request, status, Depends
Use FastAPI HTTPException with appropriate status codes for API endpoints and handle APIConnectionError from Llama Stack

Files:

  • src/app/endpoints/tools.py
  • src/app/endpoints/a2a.py
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.py: Use pytest for all unit and integration tests; do not use unittest
Use pytest.mark.asyncio marker for async tests

Files:

  • tests/unit/utils/test_pydantic_ai.py
🧠 Learnings (3)
📚 Learning: 2026-06-24T13:45:37.249Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 1971
File: src/utils/markdown_repair.py:31-36
Timestamp: 2026-06-24T13:45:37.249Z
Learning: In the lightspeed-stack repository, docstrings must use the section header name "Parameters:" (not "Args:") for function arguments, even if the project references Google Python docstring conventions. Ensure docstrings follow the project’s established "Parameters:" header format for any documented function parameters.

Applied to files:

  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/app/endpoints/tools.py
  • tests/unit/utils/test_pydantic_ai.py
  • src/app/endpoints/a2a.py
  • src/utils/pydantic_ai_helpers.py
📚 Learning: 2026-07-06T15:26:18.398Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 2071
File: src/models/config.py:2416-2422
Timestamp: 2026-07-06T15:26:18.398Z
Learning: In this repo’s Python code under src/**, don’t treat differences in string concatenation style as a style inconsistency when Black has effectively forced (or made clearer) use of explicit `+` string concatenation in multi-line logger/string expressions. If adjacent-literal implicit concatenation is avoided/changed specifically to accommodate Black’s formatting in these call sites, accept the `+` usage and don’t recommend converting it solely for consistency with nearby blocks that use implicit concatenation.

Applied to files:

  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/a2a.py
  • src/utils/pydantic_ai_helpers.py
📚 Learning: 2026-04-06T20:18:07.852Z
Learnt from: major
Repo: lightspeed-core/lightspeed-stack PR: 1463
File: src/app/endpoints/rlsapi_v1.py:266-271
Timestamp: 2026-04-06T20:18:07.852Z
Learning: In the lightspeed-stack codebase, within `src/app/endpoints/` inference/MCP endpoints, treat `tools: Optional[list[Any]]` in MCP tool definitions as an intentional, consistent typing pattern (used across `query`, `responses`, `streaming_query`, `rlsapi_v1`). Do not raise or suggest this as a typing issue during code review; changing it in isolation could break endpoint typing consistency across the codebase.

Applied to files:

  • src/app/endpoints/tools.py
  • src/app/endpoints/a2a.py
🛑 Comments failed to post (2)
src/utils/pydantic_ai_helpers.py (2)

27-27: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Use modern X | None syntax instead of Optional[X].

The coding guidelines require modern type annotation syntax (str | int). build_agent already uses | for the client parameter (line 160), but Optional[X] is used elsewhere — inconsistent within the same file. With from __future__ import annotations present, X | None works on all supported Python versions.

As per coding guidelines, all functions must use modern syntax (str | int) for type annotations.

♻️ Proposed refactor
-from typing import Any, Final, Optional
+from typing import Any, Final

Then replace all Optional[X] with X | None:

 def _skills_capability(
-    skills_config: Optional[SkillsConfiguration],
-) -> Optional[SkillsCapability]:
+    skills_config: SkillsConfiguration | None,
+) -> SkillsCapability | None:
 def _json_schema_to_parameters(
-    schema: Optional[dict[str, Any]],
+    schema: dict[str, Any] | None,
 ) -> list[dict[str, Any]]:
 def get_agent_capability_tools(
-    skills: Optional[SkillsConfiguration],
+    skills: SkillsConfiguration | None,
 ) -> list[dict[str, Any]]:
 def _agent_capabilities(
-    skills: Optional[SkillsConfiguration],
+    skills: SkillsConfiguration | None,
     no_tools: bool = False,
-) -> Optional[list[AgentCapability[object]]]:
+) -> list[AgentCapability[object]] | None:
 def build_agent(
     client: AsyncLlamaStackClient | AsyncLlamaStackAsLibraryClient,
     responses_params: ResponsesApiParams,
-    skills: Optional[SkillsConfiguration],
+    skills: SkillsConfiguration | None,
     no_tools: bool = False,
 ) -> Agent[None, str]:

Also applies to: 28-28, 46-46, 108-108, 132-132, 134-134, 162-162

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/pydantic_ai_helpers.py` at line 27, Replace every Optional type
annotation in pydantic_ai_helpers.py with the equivalent modern X | None syntax,
including the skills_config parameter and the other referenced annotations.
Preserve the existing types and function behavior while keeping the annotation
style consistent with build_agent’s client parameter.

Source: Coding guidelines


31-31: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use Parameters: instead of Args: in docstrings.

Two functions use the Args: section header, but this repo's convention is Parameters:.

Based on learnings, docstrings must use the section header name "Parameters:" (not "Args:") for function arguments.

📝 Proposed fix
 def _skills_capability(
     skills_config: Optional[SkillsConfiguration],
 ) -> Optional[SkillsCapability]:
     """Return a skills capability when skill paths are configured.

-    Args:
+    Parameters:
         skills_config: Agent skills configuration from LCS, or None when skills are disabled.
 def _agent_capabilities(
     skills: Optional[SkillsConfiguration],
     no_tools: bool = False,
 ) -> Optional[list[AgentCapability[object]]]:
     """Assemble pydantic-ai capabilities for an LCS agent.

-    Args:
+    Parameters:
         skills: Agent skills configuration from LCS, or None when skills are disabled.
         no_tools: When True, omit capabilities that expose a toolset via ``get_toolset()``.

Also applies to: 137-137

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/pydantic_ai_helpers.py` at line 31, Update the docstrings for both
affected functions in pydantic_ai_helpers.py to rename the section header from
“Args:” to “Parameters:”. Leave the documented parameters and all implementation
code unchanged.

Source: Learnings

🔇 Additional comments (7)
src/utils/pydantic_ai_helpers.py (2)

76-80: LGTM!

Also applies to: 83-104


20-23: 📐 Maintainability & Code Quality

No duplicate constants in src/constants.py

src/app/endpoints/a2a.py (1)

66-66: LGTM!

src/app/endpoints/tools.py (1)

31-31: LGTM!

src/utils/agents/query.py (1)

45-45: LGTM!

src/utils/agents/streaming.py (1)

60-60: LGTM!

tests/unit/utils/test_pydantic_ai.py (1)

13-13: LGTM!


Walkthrough

A new pydantic_ai_helpers module centralizes Pydantic AI agent construction and capability-tool serialization. A2A, tools, query, streaming, and unit-test imports are redirected to the new helpers.

Changes

Pydantic AI helper migration

Layer / File(s) Summary
Capability and tool metadata helpers
src/utils/pydantic_ai_helpers.py
Adds skills capability selection, schema-to-parameter conversion, docstring summary extraction, and capability-tool serialization.
Responses-compatible agent construction
src/utils/pydantic_ai_helpers.py
Adds capability filtering and build_agent, configured with the Llama Stack Responses model and response instructions.
Caller and test migration
src/app/endpoints/a2a.py, src/app/endpoints/tools.py, src/utils/agents/..., tests/unit/utils/test_pydantic_ai.py
Redirects agent and capability-tool imports to the new helper module.

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

Possibly related PRs

Suggested reviewers: jrobertboos, asimurka

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main refactor: renaming the pydantic AI utils module and updating imports/tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 No meaningful perf regressions found; changed code is refactor-only, and the only HEAD^..HEAD diff is a test import change.
Security And Secret Handling ✅ Passed PASS: touched code only renames imports and adds helper serialization; endpoints keep @authorize/auth deps, and the new helper has no I/O, logging, or secret handling.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/pydantic_ai_helpers.py`:
- Line 31: Update the docstrings for both affected functions in
pydantic_ai_helpers.py to rename the section header from “Args:” to
“Parameters:”. Leave the documented parameters and all implementation code
unchanged.
- Line 27: Replace every Optional type annotation in pydantic_ai_helpers.py with
the equivalent modern X | None syntax, including the skills_config parameter and
the other referenced annotations. Preserve the existing types and function
behavior while keeping the annotation style consistent with build_agent’s client
parameter.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2a8a13f2-d8ad-415a-afbf-42af1ab6091e

📥 Commits

Reviewing files that changed from the base of the PR and between e8e226c and b645bdb.

📒 Files selected for processing (6)
  • src/app/endpoints/a2a.py
  • src/app/endpoints/tools.py
  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/utils/pydantic_ai_helpers.py
  • tests/unit/utils/test_pydantic_ai.py
📜 Review details
⏰ Context from checks skipped due to timeout. (13)
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: Pylinter
  • GitHub Check: spectral
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-7-on-pull-request
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 2
🧰 Additional context used
📓 Path-based instructions (4)
src/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.py: Use absolute imports for internal modules: from authentication import get_auth_dependency
Llama Stack imports: Use from llama_stack_client import AsyncLlamaStackClient
Check constants.py for shared constants before defining new ones
All modules must start with descriptive docstrings explaining purpose
Use logger = get_logger(__name__) from log.py for module logging
All functions must have complete type annotations for parameters and return types, use modern syntax (str | int), and include descriptive docstrings
Use snake_case with descriptive, action-oriented names for functions (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns; return new data structures instead of modifying function parameters
Use async def for I/O operations and external API calls
Use standard log levels with clear purposes: debug() for diagnostic info, info() for program execution, warning() for unexpected events, error() for serious problems
All classes must have descriptive docstrings explaining purpose and use PascalCase with standard suffixes: Configuration, Error/Exception, Resolver, Interface
Abstract classes must use ABC with @abstractmethod decorators
Follow Google Python docstring conventions with required sections: Parameters, Returns, Raises, and Attributes for classes

Files:

  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/a2a.py
  • src/utils/pydantic_ai_helpers.py
**/*

📄 CodeRabbit inference engine (Custom checks)

**/*: Flag meaningful O(n^2)+ algorithms on non-trivial inputs, including handlers and Kubernetes list operations.
Flag N+1 patterns that list items and then query once per item, including Kubernetes API and database access.
Flag expensive work inside loops, including API calls, JSON parsing, and regex compilation.
Flag unbounded growth in caches, watchers, or buffers when eviction or limits are missing.
Flag missing pagination or limits on list operations and API endpoints.
Flag secrets or tokens logged in plaintext or hardcoded in source.
Flag API endpoints missing authentication or authorization.
Flag injection vulnerabilities, including SQL injection, command injection, and path traversal.
Flag sensitive data leaked in API responses, WebSocket messages, or logs.
Flag Kubernetes Secrets and Red Hat secrets missing OwnerReferences.

Files:

  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/app/endpoints/tools.py
  • tests/unit/utils/test_pydantic_ai.py
  • src/app/endpoints/a2a.py
  • src/utils/pydantic_ai_helpers.py
src/app/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/app/**/*.py: FastAPI dependencies: Import from fastapi module for APIRouter, HTTPException, Request, status, Depends
Use FastAPI HTTPException with appropriate status codes for API endpoints and handle APIConnectionError from Llama Stack

Files:

  • src/app/endpoints/tools.py
  • src/app/endpoints/a2a.py
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.py: Use pytest for all unit and integration tests; do not use unittest
Use pytest.mark.asyncio marker for async tests

Files:

  • tests/unit/utils/test_pydantic_ai.py
🧠 Learnings (3)
📚 Learning: 2026-06-24T13:45:37.249Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 1971
File: src/utils/markdown_repair.py:31-36
Timestamp: 2026-06-24T13:45:37.249Z
Learning: In the lightspeed-stack repository, docstrings must use the section header name "Parameters:" (not "Args:") for function arguments, even if the project references Google Python docstring conventions. Ensure docstrings follow the project’s established "Parameters:" header format for any documented function parameters.

Applied to files:

  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/app/endpoints/tools.py
  • tests/unit/utils/test_pydantic_ai.py
  • src/app/endpoints/a2a.py
  • src/utils/pydantic_ai_helpers.py
📚 Learning: 2026-07-06T15:26:18.398Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 2071
File: src/models/config.py:2416-2422
Timestamp: 2026-07-06T15:26:18.398Z
Learning: In this repo’s Python code under src/**, don’t treat differences in string concatenation style as a style inconsistency when Black has effectively forced (or made clearer) use of explicit `+` string concatenation in multi-line logger/string expressions. If adjacent-literal implicit concatenation is avoided/changed specifically to accommodate Black’s formatting in these call sites, accept the `+` usage and don’t recommend converting it solely for consistency with nearby blocks that use implicit concatenation.

Applied to files:

  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/a2a.py
  • src/utils/pydantic_ai_helpers.py
📚 Learning: 2026-04-06T20:18:07.852Z
Learnt from: major
Repo: lightspeed-core/lightspeed-stack PR: 1463
File: src/app/endpoints/rlsapi_v1.py:266-271
Timestamp: 2026-04-06T20:18:07.852Z
Learning: In the lightspeed-stack codebase, within `src/app/endpoints/` inference/MCP endpoints, treat `tools: Optional[list[Any]]` in MCP tool definitions as an intentional, consistent typing pattern (used across `query`, `responses`, `streaming_query`, `rlsapi_v1`). Do not raise or suggest this as a typing issue during code review; changing it in isolation could break endpoint typing consistency across the codebase.

Applied to files:

  • src/app/endpoints/tools.py
  • src/app/endpoints/a2a.py
🔇 Additional comments (7)
src/utils/pydantic_ai_helpers.py (2)

76-80: LGTM!

Also applies to: 83-104


20-23: 📐 Maintainability & Code Quality

No duplicate constants in src/constants.py

src/app/endpoints/a2a.py (1)

66-66: LGTM!

src/app/endpoints/tools.py (1)

31-31: LGTM!

src/utils/agents/query.py (1)

45-45: LGTM!

src/utils/agents/streaming.py (1)

60-60: LGTM!

tests/unit/utils/test_pydantic_ai.py (1)

13-13: LGTM!

@coderabbitai coderabbitai Bot 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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/pydantic_ai_helpers.py`:
- Line 31: Update the docstrings for both affected functions in
pydantic_ai_helpers.py to rename the section header from “Args:” to
“Parameters:”. Leave the documented parameters and all implementation code
unchanged.
- Line 27: Replace every Optional type annotation in pydantic_ai_helpers.py with
the equivalent modern X | None syntax, including the skills_config parameter and
the other referenced annotations. Preserve the existing types and function
behavior while keeping the annotation style consistent with build_agent’s client
parameter.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2a8a13f2-d8ad-415a-afbf-42af1ab6091e

📥 Commits

Reviewing files that changed from the base of the PR and between e8e226c and b645bdb.

📒 Files selected for processing (6)
  • src/app/endpoints/a2a.py
  • src/app/endpoints/tools.py
  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/utils/pydantic_ai_helpers.py
  • tests/unit/utils/test_pydantic_ai.py
📜 Review details
🔇 Additional comments (7)
src/utils/pydantic_ai_helpers.py (2)

76-80: LGTM!

Also applies to: 83-104


20-23: 📐 Maintainability & Code Quality

No duplicate constants in src/constants.py

src/app/endpoints/a2a.py (1)

66-66: LGTM!

src/app/endpoints/tools.py (1)

31-31: LGTM!

src/utils/agents/query.py (1)

45-45: LGTM!

src/utils/agents/streaming.py (1)

60-60: LGTM!

tests/unit/utils/test_pydantic_ai.py (1)

13-13: LGTM!

🛑 Comments failed to post (2)
src/utils/pydantic_ai_helpers.py (2)

27-27: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Use modern X | None syntax instead of Optional[X].

The coding guidelines require modern type annotation syntax (str | int). build_agent already uses | for the client parameter (line 160), but Optional[X] is used elsewhere — inconsistent within the same file. With from __future__ import annotations present, X | None works on all supported Python versions.

As per coding guidelines, all functions must use modern syntax (str | int) for type annotations.

♻️ Proposed refactor
-from typing import Any, Final, Optional
+from typing import Any, Final

Then replace all Optional[X] with X | None:

 def _skills_capability(
-    skills_config: Optional[SkillsConfiguration],
-) -> Optional[SkillsCapability]:
+    skills_config: SkillsConfiguration | None,
+) -> SkillsCapability | None:
 def _json_schema_to_parameters(
-    schema: Optional[dict[str, Any]],
+    schema: dict[str, Any] | None,
 ) -> list[dict[str, Any]]:
 def get_agent_capability_tools(
-    skills: Optional[SkillsConfiguration],
+    skills: SkillsConfiguration | None,
 ) -> list[dict[str, Any]]:
 def _agent_capabilities(
-    skills: Optional[SkillsConfiguration],
+    skills: SkillsConfiguration | None,
     no_tools: bool = False,
-) -> Optional[list[AgentCapability[object]]]:
+) -> list[AgentCapability[object]] | None:
 def build_agent(
     client: AsyncLlamaStackClient | AsyncLlamaStackAsLibraryClient,
     responses_params: ResponsesApiParams,
-    skills: Optional[SkillsConfiguration],
+    skills: SkillsConfiguration | None,
     no_tools: bool = False,
 ) -> Agent[None, str]:

Also applies to: 28-28, 46-46, 108-108, 132-132, 134-134, 162-162

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/pydantic_ai_helpers.py` at line 27, Replace every Optional type
annotation in pydantic_ai_helpers.py with the equivalent modern X | None syntax,
including the skills_config parameter and the other referenced annotations.
Preserve the existing types and function behavior while keeping the annotation
style consistent with build_agent’s client parameter.

Source: Coding guidelines


31-31: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use Parameters: instead of Args: in docstrings.

Two functions use the Args: section header, but this repo's convention is Parameters:.

Based on learnings, docstrings must use the section header name "Parameters:" (not "Args:") for function arguments.

📝 Proposed fix
 def _skills_capability(
     skills_config: Optional[SkillsConfiguration],
 ) -> Optional[SkillsCapability]:
     """Return a skills capability when skill paths are configured.

-    Args:
+    Parameters:
         skills_config: Agent skills configuration from LCS, or None when skills are disabled.
 def _agent_capabilities(
     skills: Optional[SkillsConfiguration],
     no_tools: bool = False,
 ) -> Optional[list[AgentCapability[object]]]:
     """Assemble pydantic-ai capabilities for an LCS agent.

-    Args:
+    Parameters:
         skills: Agent skills configuration from LCS, or None when skills are disabled.
         no_tools: When True, omit capabilities that expose a toolset via ``get_toolset()``.

Also applies to: 137-137

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/pydantic_ai_helpers.py` at line 31, Update the docstrings for both
affected functions in pydantic_ai_helpers.py to rename the section header from
“Args:” to “Parameters:”. Leave the documented parameters and all implementation
code unchanged.

Source: Learnings

@tisnik tisnik merged commit 365f637 into lightspeed-core:main Jul 12, 2026
32 checks passed
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.

1 participant