diff --git a/changelog.d/1446.md b/changelog.d/1446.md new file mode 100644 index 0000000000..e61150557a --- /dev/null +++ b/changelog.d/1446.md @@ -0,0 +1,10 @@ +### Security +- pydantic-ai moves from 2.35.0 to 2.54.0, with pydantic-ai-slim, pydantic-evals and pydantic-graph; the resolver also moves anthropic to 1.12.1, openai to 3.26.1 and google-genai to 2.29.0. This fixes three advisories: GHSA-4x9p-g9wm-8q7f (tool and agent run spans put content in exception events even with `include_content=False`), GHSA-fpf4-vwcp-v4hp (quadratic title extraction in `web_fetch` blocked the event loop) and GHSA-vmxc-h2x2-jmf3 (an IPv6 zone identifier got past the SSRF cloud-metadata blocklist, which devops-cli's URL pre-flight checks and connect-time egress check also use). `uv audit` passes again, and with it `uv run devops ci` and the pre-push gate (#1446). + +### Changed +- `LocalDurabilityCapability` is built on pydantic-ai's public durable engine API: an `engine_spec` and a backend that runs each operation in-process. Toolsets are not wrapped, and model requests go through pydantic-ai's durable model in the same process. An `event_stream_handler` must be async, as pydantic-ai's `EventStreamHandler` type requires. pydantic-ai now rejects a second durability capability on the same agent (#1446). +- A `PydanticAgent` tool that takes a context must annotate it with pydantic-ai's `RunContext`. A tool annotated with `devops_cli.ai.agents.context.RunContext` now fails schema generation, because the private pydantic-ai hook that accepted the subclass no longer exists. Use `isinstance` to narrow to the subclass when the tool reads `loaded_capability_ids` or `tool_call_approved` (#1446). +- `calculate_usage_cost` prices through `genai_prices.calc_price` and returns its `PriceCalculation`, or None when genai-prices cannot price the model or usage. `get_active_traceparent` reads the active span through OpenTelemetry's W3C trace-context propagator (#1446). + +### Removed +- `devops_cli.ai`, `devops_cli.ai.agents`, `devops_cli.ai.agents.pydantic_agent`, `devops_cli.ai.result` and `devops_cli.ai.run` no longer re-export these pydantic-ai internals: `best_effort_price` (removed from pydantic-ai), `OutputSchema`, `OutputValidator`, `TextOutputSchema`, `run_image_process_hooks`, `run_output_with_hooks`, `SyncStreamBridge` and `current_otel_traceparent` (#1446). diff --git a/docs/agent/tasks/task-1446-pydantic-ai-advisories.md b/docs/agent/tasks/task-1446-pydantic-ai-advisories.md new file mode 100644 index 0000000000..8d05d914e7 --- /dev/null +++ b/docs/agent/tasks/task-1446-pydantic-ai-advisories.md @@ -0,0 +1,57 @@ +# Task: Upgrade pydantic-ai to 2.54.0, past three advisories that fail the devops ci audit (#1446) + +**Issue**: [#1446](https://github.com/dan-petty/devops-cli/issues/1446) +**Status**: Done +**Milestone**: v0.2.29 +**Priority**: priority/p0-critical +**Scope**: type/security, scope/ai, scope/security + +## Description + +`pyproject.toml` pinned `pydantic-ai==2.35.0`. Three advisories against that version (GHSA-4x9p-g9wm-8q7f, GHSA-fpf4-vwcp-v4hp, GHSA-vmxc-h2x2-jmf3) made `uv audit` fail on every branch, and with it `uv run devops ci` and the pre-push gate. The pin is now `pydantic-ai==2.54.0`, the latest 2.x release. `uv lock --upgrade-package` moved pydantic-ai, pydantic-ai-slim, pydantic-evals and pydantic-graph to 2.54.0. The resolver also requires anthropic 1.5.0 → 1.12.1, openai 3.13.0 → 3.26.1 and google-genai 2.23.0 → 2.29.0. No other package in the lock changes. + +devops-cli imported private pydantic-ai modules, and 2.54.0 removed or changed some of them. Each private import, and what replaced it: + +| Private import (2.35.0) | In 2.54.0 | Replacement | +| :--- | :--- | :--- | +| `pydantic_ai._cost.best_effort_price` (`ai/result`) | module removed | `genai_prices.calc_price`, a direct dependency already used by `ai/spend/pricing.py`. `calculate_usage_cost` returns its `PriceCalculation`, or None on `LookupError`/`ValueError`, the two errors pydantic-ai treats as "cannot price". | +| `pydantic_ai._output` (`OutputSchema`, `OutputValidator`, `TextOutputSchema`, `run_image_process_hooks`, `run_output_with_hooks`) and `pydantic_ai._sync_stream.SyncStreamBridge` (`ai/result`) | still present | Removed. Nothing in devops-cli used them; they were only re-exported from `ai`, `ai.agents`, `ai.agents.pydantic_agent` and `ai.result`. | +| `pydantic_ai._function_schema._is_call_ctx`, monkey-patched in `ai/agents/context.py` so tool schemas accepted the devops `RunContext` subclass | renamed `is_call_ctx`; the patch's `getattr` guard made it a silent no-op | Patch removed. pydantic-ai recognises only its own `RunContext` as a context annotation. `PydanticAgent`'s `load_capability` tool annotates its context with it and narrows to the devops subclass with `isinstance`, as `harness/workflow.py`'s `delegate_task` already did. | +| `pydantic_ai.durable_exec._base.BaseDurabilityCapability` and `pydantic_ai.durable_exec._runtime_toolsets.RuntimeToolsetKind` (`ai/durable.py`, `tests/test_pydantic_ai_durable.py`) | `BaseDurabilityCapability` is public in `pydantic_ai.durable_exec` and has become pydantic-ai's durable engine builder, with an abstract `get_durable_operation_backend` | `LocalDurabilityCapability` follows pydantic-ai's durable backend guide. An `engine_spec` (`DurabilityEngineSpec`: engine Local, unit step, container run, `wrapped_toolset_kinds=frozenset()`) replaces the private ClassVars. `get_durable_operation_backend` returns `_LocalOperationBackend`, a `JournalCallableOperationBackend` whose `execute` awaits the body in place. The overrides of the private `_bind_to_agent`, `_wrap_leaf_toolset` and `_dispatch_event_stream_event` are gone, because the base now owns them and the empty `wrapped_toolset_kinds` keeps toolsets unwrapped. `before_model_request` delegates to the base's, which validates the request. | +| `pydantic_ai._enqueue` (`EnqueueContent`, `PendingMessage`, `PendingMessagePriority`) (`ai/run`) | still present | Imported from `pydantic_ai.run`, where pydantic-ai documents them. That module has no `__all__`, so a `[[tool.mypy.overrides]]` entry sets `implicit_reexport` for `pydantic_ai.run` alone. mypy still reports a name the module lacks. | +| `pydantic_ai._instrumentation.current_otel_traceparent` (`ai/run`) | still present, undocumented | `get_active_traceparent` reads the active span through OpenTelemetry's `TraceContextTextMapPropagator`, and the re-export is removed. | + +`ai/tools`' `DeferredToolRequests.build_results` override now takes `approvals` as a `Mapping`, because pydantic-ai widened the parameter. + +**What remains private, for #1001 to retire:** +- `pydantic_ai._ssrf` in `core/validation.py` (`_PRIVATE_NETWORKS`, `is_cloud_metadata_ip`, `is_private_ip`) and `http/egress.py` (`is_cloud_metadata_ip`). pydantic-ai exposes no public SSRF classifier; only its `web_fetch` tool and model downloads use this module. Replacing it would mean choosing another SSRF library or hand-rolling the classification, which is a redesign. The shared classifier is also what keeps the URL pre-flight checks and the connect-time egress check in agreement. The 2.54.0 module contains the GHSA-vmxc-h2x2-jmf3 fix, so both checks get it. `tests/test_validation.py`'s contract test guards the names. +- `LocalDurabilityCapability.resolve_model_id_sync` reads the base's private `_models_by_id`. pydantic-ai's public equivalent is the async `resolve_model_id`. +- `CONST_OPENAI_FINISH_REASONS` and `CONST_ANTHROPIC_STOP_REASONS` in `config/constants.py` are copies of pydantic-ai's private finish-reason maps, not imports. The maps are identical in 2.54.0, and the comment now names that version. + +**Behaviour that changed with the library:** +- `LocalDurabilityCapability` now passes its event stream handler to pydantic-ai, whose `EventStreamHandler` type requires an async handler. The old private override also accepted a sync handler; that support is gone. +- pydantic-ai refuses a second durability capability on one agent (`UserError`). +- A tool whose context is annotated with the devops `RunContext` subclass fails pydantic-ai's schema generation. +- The devops `RunContext` subclass and the in-house `PydanticAgent` loop that builds it are #1001's to retire. + +## Acceptance Criteria + +- [x] `uv audit` reports no pydantic-ai advisory, and `uv run devops ci` passes. +- [x] `pyproject.toml` and `uv.lock` agree. The lock changes only the four pydantic-ai packages and the anthropic, openai and google-genai versions the resolver requires. +- [x] `changelog.d/1446.md` records the upgrade under `### Security`, with the API changes under `### Changed` and `### Removed`. `CHANGELOG.md` and `docs/ROADMAP.md` are untouched. +- [x] The only private pydantic-ai imports left in `src` are the two `pydantic_ai._ssrf` imports listed above. There are no version checks, `ImportError` fallbacks or copied internals. +- [x] Tests change only where the API changed: + - `tests/test_pydantic_ai_durable.py` imports `BaseDurabilityCapability` from `pydantic_ai.durable_exec`. + - `test_local_durability_delivers_run_events_and_leaves_toolsets_unwrapped` replaces the test that called the private `_dispatch_event_stream_event` and `_wrap_leaf_toolset`. It runs an agent on `TestModel` and checks that the async handler receives the tool call and result events, that `get_wrapper_toolset` leaves every toolset unwrapped, and that the steps are recorded. + - The extended-options test uses `StepPersistence` as its extra capability, since a second engine is refused. + - Three test tools annotate their context with pydantic-ai's `RunContext`. + - The result and run tests drop the removed names, and `test_get_active_traceparent` pins the traceparent of a known span context and None outside a span. + - No test reaches the network, and each one finishes in under 1 s. +- [x] The knowledge base pages that named 2.35.0 (`libraries/pydantic_ai.md`, `python_packages.md`) name 2.54.0, and `uv run devops docs generate --sync-readme` leaves the generated docs unchanged. + +## Deliverables + +- [x] Pin and lock: `pyproject.toml`, `uv.lock`. +- [x] Code: `ai/result`, `ai/run`, `ai/durable.py`, `ai/agents/context.py`, `ai/agents/agent.py`, `ai/tools`, and the export maps in `ai/__init__.py`, `ai/agents/__init__.py` and `ai/agents/pydantic_agent.py`. +- [x] mypy override for `pydantic_ai.run` in `pyproject.toml`. +- [x] Tests, knowledge base pages, the `config/constants.py` comment, `changelog.d/1446.md`. diff --git a/pyproject.toml b/pyproject.toml index d70e43ade2..fc641e2d97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ dependencies = [ "fastapi==0.142.2", "uvicorn==0.53.0", "tiktoken==0.14.0", - "pydantic-ai==2.35.0", + "pydantic-ai==2.54.0", "dnspython==2.8.0", "genai-prices==0.1.9", "opentelemetry-exporter-otlp-proto-grpc==1.44.0", @@ -121,6 +121,13 @@ strict = true plugins = ['pydantic.mypy'] enable_error_code = ["ignore-without-code"] +# pydantic-ai documents EnqueueContent, PendingMessage and PendingMessagePriority as members of +# pydantic_ai.run (https://pydantic.dev/docs/ai/api/run/), but the module has no __all__, so +# strict mode would not count them as exported. +[[tool.mypy.overrides]] +module = "pydantic_ai.run" +implicit_reexport = true + [tool.pytest.ini_options] asyncio_mode = "auto" testpaths = ["tests"] diff --git a/src/devops_cli/ai/__init__.py b/src/devops_cli/ai/__init__.py index b9348392fe..8e95702b1e 100644 --- a/src/devops_cli/ai/__init__.py +++ b/src/devops_cli/ai/__init__.py @@ -284,19 +284,12 @@ def __getattr__(name: str) -> Any: # noqa: C901 "AgentStream", "AgentStreamEvent", "FinalResult", - "OutputSchema", - "OutputValidator", "OutputValidatorFunc", "RunUsage", "StreamedRunResult", "StreamedRunResultSync", - "SyncStreamBridge", - "TextOutputSchema", - "best_effort_price", "calculate_usage_cost", "create_run_usage", - "run_image_process_hooks", - "run_output_with_hooks", "to_agent_response", "to_final_result", }: @@ -338,7 +331,6 @@ def __getattr__(name: str) -> Any: # noqa: C901 "PendingMessage", "PendingMessagePriority", "create_pending_message", - "current_otel_traceparent", "format_run_summary", "get_active_traceparent", }: @@ -845,10 +837,8 @@ def __getattr__(name: str) -> Any: # noqa: C901 "OutputDataT", "OutputMode", "OutputObjectDefinition", - "OutputSchema", "OutputSpec", "OutputTypeOrFunction", - "OutputValidator", "OutputValidatorFunc", "OverflowStore", "PackedContext", @@ -919,14 +909,12 @@ def __getattr__(name: str) -> Any: # noqa: C901 "Summarize", "SummarizingCompaction", "SuspendedResponseExpired", - "SyncStreamBridge", "TavilySearchResult", "TavilySearchTool", "TemplateStr", "TenacityTransport", "TextOutput", "TextOutputFunc", - "TextOutputSchema", "ThinkingEffort", "ThinkingLevel", "ThinkingStreamProcessor", @@ -978,7 +966,6 @@ def __getattr__(name: str) -> Any: # noqa: C901 "amazon_model_profile", "anthropic_model_profile", "approve_all_requests", - "best_effort_price", "build_output_spec", "bundle_ollama_models", "calculate_usage_cost", @@ -1004,7 +991,6 @@ def __getattr__(name: str) -> Any: # noqa: C901 "create_tool", "create_tool_definition", "create_tool_or_output", - "current_otel_traceparent", "deepseek_model_profile", "defer_loading_toolset", "deny_all_requests", @@ -1121,8 +1107,6 @@ def __getattr__(name: str) -> Any: # noqa: C901 "resolve_model_profile", "resolve_output_mode", "resolve_runtime_model_settings", - "run_image_process_hooks", - "run_output_with_hooks", "scaffold_agent_instructions", "signature_from_callable", "signature_from_schema", diff --git a/src/devops_cli/ai/agents/__init__.py b/src/devops_cli/ai/agents/__init__.py index b1c925cde2..9330f9eab1 100644 --- a/src/devops_cli/ai/agents/__init__.py +++ b/src/devops_cli/ai/agents/__init__.py @@ -454,19 +454,12 @@ def __getattr__(name: str) -> Any: # noqa: C901 if name in { "AgentStream", "FinalResult", - "OutputSchema", - "OutputValidator", "OutputValidatorFunc", "RunUsage", "StreamedRunResult", "StreamedRunResultSync", - "SyncStreamBridge", - "TextOutputSchema", - "best_effort_price", "calculate_usage_cost", "create_run_usage", - "run_image_process_hooks", - "run_output_with_hooks", "to_agent_response", "to_final_result", }: @@ -507,7 +500,6 @@ def __getattr__(name: str) -> Any: # noqa: C901 "PendingMessage", "PendingMessagePriority", "create_pending_message", - "current_otel_traceparent", "format_run_summary", "get_active_traceparent", }: @@ -879,10 +871,8 @@ def __getattr__(name: str) -> Any: # noqa: C901 "OutputGuardrail", "OutputMode", "OutputObjectDefinition", - "OutputSchema", "OutputSpec", "OutputTypeOrFunction", - "OutputValidator", "OutputValidatorFunc", "OverflowStore", "ParallelExecutionMode", @@ -969,7 +959,6 @@ def __getattr__(name: str) -> Any: # noqa: C901 "Summarize", "SummarizingCompaction", "SuspendedResponseExpired", - "SyncStreamBridge", "SystemReminders", "TavilySearchResult", "TavilySearchTool", @@ -979,7 +968,6 @@ def __getattr__(name: str) -> Any: # noqa: C901 "TestModel", "TextOutput", "TextOutputFunc", - "TextOutputSchema", "Thinking", "ThinkingEffort", "ThinkingLevel", @@ -1050,7 +1038,6 @@ def __getattr__(name: str) -> Any: # noqa: C901 "anthropic_model_profile", "approval_required", "approve_all_requests", - "best_effort_price", "build_output_spec", "calculate_usage_cost", "capture_run_messages", @@ -1076,7 +1063,6 @@ def __getattr__(name: str) -> Any: # noqa: C901 "create_tool", "create_tool_definition", "create_tool_or_output", - "current_otel_traceparent", "deepseek_model_profile", "defer_loading_toolset", "deferred_loading", @@ -1184,8 +1170,6 @@ def __getattr__(name: str) -> Any: # noqa: C901 "resolve_output_mode", "resolve_runtime_model_settings", "restore_media", - "run_image_process_hooks", - "run_output_with_hooks", "signature_from_callable", "signature_from_schema", "signature_from_tool", diff --git a/src/devops_cli/ai/agents/agent.py b/src/devops_cli/ai/agents/agent.py index aaa4da7afd..c2460655e5 100644 --- a/src/devops_cli/ai/agents/agent.py +++ b/src/devops_cli/ai/agents/agent.py @@ -17,6 +17,7 @@ from devops_cli.ai.concurrency import AbstractConcurrencyLimiter, AnyConcurrencyLimit from devops_cli.ai.function_signature import FunctionSignature +from pydantic_ai.tools import RunContext as NativeRunContext from pydantic_ai.toolsets import AbstractToolset as PyAIAbstractToolset from devops_cli.ai.agents.capabilities import ( @@ -336,7 +337,7 @@ def __init__( # noqa: C901 self._register_load_capability_tool() def _register_load_capability_tool(self) -> None: - def load_capability(ctx: RunContext[Any], capability_id: str) -> str: + def load_capability(ctx: NativeRunContext[Any], capability_id: str) -> str: """Load an on-demand capability by ID, unlocking its tools, instructions, and hooks.""" matching = next( (c for c in self.capabilities if c.id == capability_id and c.defer_loading), None @@ -344,7 +345,9 @@ def load_capability(ctx: RunContext[Any], capability_id: str) -> str: if not matching: avail = [c.id for c in self.capabilities if c.defer_loading] return f"Capability '{capability_id}' not found. Available on-demand: {avail}" - ctx.loaded_capability_ids.add(capability_id) + run_ctx = ctx if isinstance(ctx, RunContext) else None + if run_ctx is not None: + run_ctx.loaded_capability_ids.add(capability_id) for t in matching.get_tools(): self.add_tool(t) cap_hooks = matching.get_hooks() @@ -354,7 +357,7 @@ def load_capability(ctx: RunContext[Any], capability_id: str) -> str: self.hooks.before_tool_execute.extend(cap_hooks.before_tool_execute) self.hooks.after_tool_execute.extend(cap_hooks.after_tool_execute) self.hooks.on_tool_error.extend(cap_hooks.on_tool_error) - additions = matching.get_system_prompt_additions(ctx=ctx) + additions = matching.get_system_prompt_additions(ctx=run_ctx) inst = (" " + " ".join(additions)) if additions else "" return f"Capability '{capability_id}' loaded successfully.{inst}" diff --git a/src/devops_cli/ai/agents/context.py b/src/devops_cli/ai/agents/context.py index acfb5e67ae..0e1c57dd83 100644 --- a/src/devops_cli/ai/agents/context.py +++ b/src/devops_cli/ai/agents/context.py @@ -5,7 +5,6 @@ from collections.abc import Callable from typing import Any, TypeVar, cast -import pydantic_ai._function_schema as _pydantic_fs from pydantic import BaseModel, Field from pydantic_ai.tools import RunContext as NativeRunContext @@ -89,30 +88,6 @@ def model_copy( return copied -# Guarded, idempotent compatibility registration for RunContext subclasses in pydantic_ai -_orig_fs_is_call_ctx = getattr(_pydantic_fs, "_is_call_ctx", None) - -if _orig_fs_is_call_ctx is not None and not getattr( - _orig_fs_is_call_ctx, "_is_subclass_aware", False -): - - def _subclass_aware_is_call_ctx(annotation: Any) -> bool: - if _orig_fs_is_call_ctx is not None: - try: - if _orig_fs_is_call_ctx(annotation): - return True - except Exception: - pass - origin = getattr(annotation, "__origin__", None) or annotation - try: - return isinstance(origin, type) and issubclass(origin, NativeRunContext) - except TypeError: - return False - - _subclass_aware_is_call_ctx._is_subclass_aware = True # type: ignore[attr-defined] - _pydantic_fs._is_call_ctx = _subclass_aware_is_call_ctx - - class AgentStepNode(BaseModel): """Represents a discrete step or node in the agent execution graph.""" diff --git a/src/devops_cli/ai/agents/pydantic_agent.py b/src/devops_cli/ai/agents/pydantic_agent.py index bdf6c390b2..8ac3a69e86 100644 --- a/src/devops_cli/ai/agents/pydantic_agent.py +++ b/src/devops_cli/ai/agents/pydantic_agent.py @@ -365,19 +365,12 @@ from devops_cli.ai.result import ( AgentStream, FinalResult, - OutputSchema, - OutputValidator, OutputValidatorFunc, RunUsage, StreamedRunResult, StreamedRunResultSync, - SyncStreamBridge, - TextOutputSchema, - best_effort_price, calculate_usage_cost, create_run_usage, - run_image_process_hooks, - run_output_with_hooks, to_agent_response, to_final_result, ) @@ -410,7 +403,6 @@ PendingMessage, PendingMessagePriority, create_pending_message, - current_otel_traceparent, format_run_summary, get_active_traceparent, ) @@ -640,10 +632,8 @@ "OutputDataT", "OutputMode", "OutputObjectDefinition", - "OutputSchema", "OutputSpec", "OutputTypeOrFunction", - "OutputValidator", "OutputValidatorFunc", "ParallelExecutionMode", "PendingMessage", @@ -694,7 +684,6 @@ "StructuredDict", "StructuredOutputMode", "SuspendedResponseExpired", - "SyncStreamBridge", "SystemReminders", "TavilySearchResult", "TavilySearchTool", @@ -704,7 +693,6 @@ "TestModel", "TextOutput", "TextOutputFunc", - "TextOutputSchema", "Thinking", "ThinkingEffort", "ThinkingLevel", @@ -778,7 +766,6 @@ "abstract", "approval_required", "approve_all_requests", - "best_effort_price", "build_output_spec", "calculate_usage_cost", "capability", @@ -803,7 +790,6 @@ "create_tool", "create_tool_definition", "create_tool_or_output", - "current_otel_traceparent", "deepseek_model_profile", "defer_loading_toolset", "deferred_loading", @@ -901,8 +887,6 @@ "resolve_model_profile", "resolve_output_mode", "resolve_runtime_model_settings", - "run_image_process_hooks", - "run_output_with_hooks", "select_model", "set_tool_metadata", "signature_from_callable", diff --git a/src/devops_cli/ai/durable.py b/src/devops_cli/ai/durable.py index 84af8b0bb1..3282b6f1b0 100644 --- a/src/devops_cli/ai/durable.py +++ b/src/devops_cli/ai/durable.py @@ -2,27 +2,28 @@ from __future__ import annotations -import inspect import json import re import sqlite3 import time import uuid -from collections.abc import Mapping, Sequence +from collections.abc import Awaitable, Callable, Mapping, Sequence from pathlib import Path from typing import TYPE_CHECKING, Any, ClassVar, Protocol, runtime_checkable from pydantic import BaseModel, Field from pydantic_ai import Agent from pydantic_ai.agent import EventStreamHandler -from pydantic_ai.agent.abstract import AbstractAgent from pydantic_ai.capabilities.abstract import AbstractCapability -from pydantic_ai.durable_exec._base import BaseDurabilityCapability -from pydantic_ai.durable_exec._runtime_toolsets import RuntimeToolsetKind -from pydantic_ai.messages import AgentStreamEvent +from pydantic_ai.durable_exec import ( + BaseDurabilityCapability, + DurabilityEngineSpec, + DurableOperationId, + JournalCallableOperationBackend, + RoleBasedOperationConfig, +) from pydantic_ai.models import KnownModelName, Model, ModelRequestContext, ModelResolutionContext from pydantic_ai.tools import AgentDepsT, RunContext -from pydantic_ai.toolsets import AbstractToolset, WrapperToolset from devops_cli.config.defaults import ( DEFAULT_AI_DURABLE_AGENT_NAME, @@ -314,17 +315,43 @@ def get_available_durable_engines() -> dict[str, bool]: # ── Local Durability Capability ─────────────────────────────────────────────── +class _LocalOperationBackend(JournalCallableOperationBackend[None]): + """Runs each durable operation in this process; the capability's hooks record the steps.""" + + def __init__(self, agent_name: str, default_model_id: str | None) -> None: + super().__init__( + agent_name=agent_name, + default_model_id=default_model_id, + config=RoleBasedOperationConfig(model=None, event=None, capability=None, tool=None), + ) + + async def execute( + self, + *, + operation_id: DurableOperationId, + name: str, + body: Callable[[], Awaitable[object]], + cache_key: tuple[object, ...], + config: None, + ) -> object: + """Run the operation's body in place.""" + return await body() + + class LocalDurabilityCapability(BaseDurabilityCapability[AgentDepsT]): - """Local, workstation-ready durability capability adhering to BaseDurabilityCapability. + """Local, workstation-ready durability engine built on pydantic-ai's durable engine API. - Provides step-by-step recording, model resolution, tool execution tracking, and checkpointing - backed by SQLite or In-Memory step stores without requiring external server orchestration. + Operations run in this process (`_LocalOperationBackend`), and the lifecycle hooks record + each run, model request and tool call as steps in a SQLite or in-memory step store, with + checkpointing, without external server orchestration. Toolsets pass through unwrapped. """ - engine_name: ClassVar[str] = "Local" - _unsupported_runtime_toolset_kinds: ClassVar[frozenset[RuntimeToolsetKind]] = frozenset() - _durable_unit_noun: ClassVar[str] = "step" - _durable_container_noun: ClassVar[str] = "run" + engine_spec: ClassVar[DurabilityEngineSpec] = DurabilityEngineSpec( + engine_name="Local", + durable_unit_noun="step", + durable_container_noun="run", + wrapped_toolset_kinds=frozenset(), + ) def __init__( self, @@ -348,24 +375,9 @@ def in_durable_context(self) -> bool: """Whether execution is currently inside the local durable container.""" return True - def _bind_to_agent(self, agent: AbstractAgent[AgentDepsT, Any]) -> None: - """Register local durability units on this bound capability.""" - self._agent = agent - - def _wrap_leaf_toolset( - self, ts: AbstractToolset[AgentDepsT] - ) -> WrapperToolset[AgentDepsT] | None: - """Wrap dynamic or leaf toolsets with durability tracking if needed.""" - return None - - async def _dispatch_event_stream_event( - self, ctx: RunContext[AgentDepsT], event: AgentStreamEvent - ) -> None: - """Deliver one workflow-side event inside the local durable boundary.""" - if self._event_stream_handler is not None: - res = self._event_stream_handler(ctx, self._single_event_stream(event)) - if inspect.isawaitable(res): - await res + def get_durable_operation_backend(self) -> _LocalOperationBackend: + """Return the in-process backend that runs this capability's durable operations.""" + return _LocalOperationBackend(self.name, self.default_model_id) def resolve_model_id_sync( self, @@ -424,7 +436,7 @@ async def before_model_request( """Lifecycle hook recording model invocation parameters.""" model_repr = getattr(request_context.model, "model_id", str(request_context.model)) self.save_step("model_request", {"model": model_repr}) - return request_context + return await super().before_model_request(ctx, request_context) async def after_model_request( self, diff --git a/src/devops_cli/ai/knowledge_base/devops_cli/libraries/pydantic_ai.md b/src/devops_cli/ai/knowledge_base/devops_cli/libraries/pydantic_ai.md index cdeb6d22db..22a4f39331 100644 --- a/src/devops_cli/ai/knowledge_base/devops_cli/libraries/pydantic_ai.md +++ b/src/devops_cli/ai/knowledge_base/devops_cli/libraries/pydantic_ai.md @@ -6,7 +6,7 @@ | :--- | :--- | | **Official Documentation** | [ai.pydantic.dev](https://ai.pydantic.dev/) | | **Public Git Repository** | [github.com/pydantic/pydantic-ai](https://github.com/pydantic/pydantic-ai) | -| **Official PyPI Package** | [pypi.org/project/pydantic-ai](https://pypi.org/project/pydantic-ai/) (`2.35.0`) | +| **Official PyPI Package** | [pypi.org/project/pydantic-ai](https://pypi.org/project/pydantic-ai/) (`2.54.0`) | | **DevOps CLI Integration** | [`src/devops_cli/ai/agents/`](../../../../../../src/devops_cli/ai/agents/) • [`src/devops_cli/ai/review/`](../../../../../../src/devops_cli/ai/review/) | --- diff --git a/src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md b/src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md index 89ffba2355..3bb9c2acc2 100644 --- a/src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md +++ b/src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md @@ -116,7 +116,7 @@ from devops_cli.ai.review_schema import Finding ### 3. Agentic AI, LLM Client & Semantic Search #### `pydantic-ai` ([Dedicated Manual](libraries/pydantic_ai.md)) -- **Pinned Version**: `pydantic-ai==2.35.0` +- **Pinned Version**: `pydantic-ai==2.54.0` - **Ecosystem Role**: Multi-agent framework enabling type-safe tool execution, dynamic instructions, structured output validation, model overrides, and sub-agent delegation. - **Codebase Integration**: - `devops_cli.ai.agents.agent.PydanticAgent`: High-level agent abstraction managing toolsets, usage tracking (`AgentUsage`), and async lifecycles (`async with agent:`). diff --git a/src/devops_cli/ai/result/__init__.py b/src/devops_cli/ai/result/__init__.py index 155c02c992..de623f4a80 100644 --- a/src/devops_cli/ai/result/__init__.py +++ b/src/devops_cli/ai/result/__init__.py @@ -1,22 +1,15 @@ """Native Pydantic AI result subsystem for devops-cli. Provides unified execution result handling, streaming results, usage tracking, -dynamic model pricing calculation, and output validation. +and model pricing through genai-prices. """ from __future__ import annotations from typing import TYPE_CHECKING, Any -from pydantic_ai._cost import best_effort_price -from pydantic_ai._output import ( - OutputSchema, - OutputValidator, - TextOutputSchema, - run_image_process_hooks, - run_output_with_hooks, -) -from pydantic_ai._sync_stream import SyncStreamBridge +from genai_prices import calc_price +from genai_prices.types import PriceCalculation from pydantic_ai.messages import AgentStreamEvent from pydantic_ai.result import ( AgentStream, @@ -52,8 +45,12 @@ def calculate_usage_cost( usage: RunUsage | Any, model_name: str | None = None, **kwargs: Any, -) -> Any: - """Calculate live financial cost for an execution run using native best_effort_price.""" +) -> PriceCalculation | None: + """Price an execution run with genai-prices, or None for a model or usage it cannot price. + + Extra keyword arguments (`provider_id`, `provider_api_url`, `genai_request_timestamp`) go + to `genai_prices.calc_price`. + """ if usage is None or model_name is None: return None @@ -68,8 +65,8 @@ def calculate_usage_cost( run_u = RunUsage(input_tokens=in_tok, output_tokens=out_tok, requests=reqs, tool_calls=tc) try: - return best_effort_price(run_u, model_name=model_name, **kwargs) - except Exception: + return calc_price(run_u, model_name, **kwargs) + except LookupError, ValueError: return None @@ -102,19 +99,12 @@ def to_agent_response(result: Any) -> AgentResponse[Any]: "AgentStream", "AgentStreamEvent", "FinalResult", - "OutputSchema", - "OutputValidator", "OutputValidatorFunc", "RunUsage", "StreamedRunResult", "StreamedRunResultSync", - "SyncStreamBridge", - "TextOutputSchema", - "best_effort_price", "calculate_usage_cost", "create_run_usage", - "run_image_process_hooks", - "run_output_with_hooks", "to_agent_response", "to_final_result", ] diff --git a/src/devops_cli/ai/run/__init__.py b/src/devops_cli/ai/run/__init__.py index 3f3bf2f953..67ade77ed5 100644 --- a/src/devops_cli/ai/run/__init__.py +++ b/src/devops_cli/ai/run/__init__.py @@ -9,17 +9,15 @@ from datetime import datetime from typing import Any -from pydantic_ai._enqueue import ( - EnqueueContent, - PendingMessage, - PendingMessagePriority, -) -from pydantic_ai._instrumentation import current_otel_traceparent +from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator from pydantic_ai.messages import ModelMessage, ModelRequest, UserPromptPart from pydantic_ai.run import ( AgentRun, AgentRunResult, AgentRunResultEvent, + EnqueueContent, + PendingMessage, + PendingMessagePriority, ) from pydantic_graph import ( BaseNode, @@ -53,21 +51,10 @@ def create_pending_message( def get_active_traceparent() -> str | None: - """Resolve the active OpenTelemetry W3C traceparent string using native Pydantic AI instrumentation.""" - traceparent = current_otel_traceparent() - if traceparent: - return traceparent - - try: - from opentelemetry import trace - - span = trace.get_current_span() - ctx = span.get_span_context() - if ctx.is_valid: - return f"00-{ctx.trace_id:032x}-{ctx.span_id:016x}-{ctx.trace_flags:02x}" - except Exception: - pass - return None + """Return the W3C traceparent of the active OpenTelemetry span, or None when no span is valid.""" + carrier: dict[str, str] = {} + TraceContextTextMapPropagator().inject(carrier) + return carrier.get("traceparent") def format_run_summary(result: AgentRunResult[Any] | Any) -> dict[str, Any]: @@ -139,7 +126,6 @@ def format_run_summary(result: AgentRunResult[Any] | Any) -> dict[str, Any]: "PendingMessage", "PendingMessagePriority", "create_pending_message", - "current_otel_traceparent", "format_run_summary", "get_active_traceparent", ] diff --git a/src/devops_cli/ai/tools/__init__.py b/src/devops_cli/ai/tools/__init__.py index 33ed51332a..1cc2ffe23d 100644 --- a/src/devops_cli/ai/tools/__init__.py +++ b/src/devops_cli/ai/tools/__init__.py @@ -3,7 +3,7 @@ from __future__ import annotations import asyncio -from collections.abc import Callable +from collections.abc import Callable, Mapping from dataclasses import dataclass from typing import Any, cast @@ -262,7 +262,7 @@ class DeferredToolRequests(NativeDeferredToolRequests): def build_results( self, *, - approvals: dict[str, Any] | None = None, + approvals: Mapping[str, Any] | None = None, calls: dict[str, Any] | None = None, metadata: dict[str, dict[str, Any]] | None = None, approve_all: bool = False, diff --git a/src/devops_cli/config/constants.py b/src/devops_cli/config/constants.py index 9d17fe86f4..11262b8e9b 100644 --- a/src/devops_cli/config/constants.py +++ b/src/devops_cli/config/constants.py @@ -2389,7 +2389,7 @@ # Response header in which the LiteLLM gateway names the backend (api_base) that served a call. CONST_AI_GATEWAY_SERVED_BY_HEADER: Final[str] = "x-litellm-model-api-base" # Why a provider says a reply ended, as pydantic-ai's FinishReason. The OpenAI-compatible and -# Anthropic tables copy pydantic-ai 2.35.0's private maps (models/openai.py, models/anthropic.py), +# Anthropic tables copy pydantic-ai 2.54.0's private maps (models/openai.py, models/anthropic.py), # which are not imported because they are private. A value absent from a table, or mapped to # None, is unknown: truncation is never guessed. CONST_OPENAI_FINISH_REASONS: Final[dict[str, FinishReason]] = { diff --git a/tests/test_pydantic_agent.py b/tests/test_pydantic_agent.py index 6c56d0d4d7..fccdf54929 100644 --- a/tests/test_pydantic_agent.py +++ b/tests/test_pydantic_agent.py @@ -4,6 +4,7 @@ import pytest from pydantic import BaseModel +from pydantic_ai import RunContext as NativeRunContext from devops_cli.ai.agents.pydantic_agent import ( AgentTool, @@ -239,7 +240,7 @@ def dynamic_prompt(ctx: RunContext[dict[str, str]]) -> str: # 2. Tool with RunContext injection @agent.tool - def analyze_ctx(ctx: RunContext[dict[str, str]], target: str) -> str: + def analyze_ctx(ctx: NativeRunContext[dict[str, str]], target: str) -> str: env = ctx.deps.get("env") if ctx and ctx.deps else "unknown" return f"Target {target} analyzed in {env}" @@ -753,8 +754,9 @@ def delete_prod_cluster(cluster_name: str) -> str: return f"Cluster {cluster_name} deleted" # 2. Tool requiring dynamic approval via exception - def modify_config(ctx: RunContext[Any], key: str, value: str) -> str: - if key == "secret" and not ctx.tool_call_approved: + def modify_config(ctx: NativeRunContext[Any], key: str, value: str) -> str: + approved = isinstance(ctx, RunContext) and ctx.tool_call_approved + if key == "secret" and not approved: raise ApprovalRequired("Modifying secret requires approval", metadata={"risk": "high"}) return f"Config {key}={value} applied" diff --git a/tests/test_pydantic_ai_durable.py b/tests/test_pydantic_ai_durable.py index abdd8ed5cc..3c57542be4 100644 --- a/tests/test_pydantic_ai_durable.py +++ b/tests/test_pydantic_ai_durable.py @@ -2,13 +2,15 @@ from __future__ import annotations +from collections.abc import AsyncIterable from pathlib import Path from typing import Any, cast import pytest -from pydantic_ai import Agent +from pydantic_ai import Agent, RunContext from pydantic_ai.capabilities.abstract import AbstractCapability -from pydantic_ai.durable_exec._base import BaseDurabilityCapability +from pydantic_ai.durable_exec import BaseDurabilityCapability +from pydantic_ai.messages import AgentStreamEvent, FunctionToolCallEvent, FunctionToolResultEvent from pydantic_ai.models.test import TestModel from devops_cli.ai.agents.persistence import InMemoryStepStore, SqliteStepStore, StepPersistence @@ -305,38 +307,28 @@ def calculate_sum(a: int, b: int) -> int: @pytest.mark.asyncio -async def test_local_durability_event_stream_dispatch_and_leaf_toolset() -> None: - """Verify event stream dispatching for sync and async handlers and leaf toolset wrapper.""" - events_received: list[Any] = [] +async def test_local_durability_delivers_run_events_and_leaves_toolsets_unwrapped() -> None: + """Verify a run hands its tool events to the async handler and calls the tool unwrapped.""" + events: list[AgentStreamEvent] = [] - def sync_handler(ctx: Any, event: Any) -> None: - events_received.append(("sync", event)) + async def handler(ctx: RunContext[Any], stream: AsyncIterable[AgentStreamEvent]) -> None: + async for event in stream: + events.append(event) - async def async_handler(ctx: Any, event: Any) -> None: - events_received.append(("async", event)) + cap = LocalDurabilityCapability(name="streamer", event_stream_handler=handler) + agent = Agent(model=TestModel(), name="stream_worker", capabilities=[cap]) - cap_sync = LocalDurabilityCapability( - name="sync_streamer", event_stream_handler=cast(Any, sync_handler) - ) - cap_async = LocalDurabilityCapability( - name="async_streamer", event_stream_handler=cast(Any, async_handler) - ) - - from types import SimpleNamespace - - dummy_ctx = SimpleNamespace() - dummy_event = SimpleNamespace(type="test_event") - - await cap_sync._dispatch_event_stream_event(dummy_ctx, dummy_event) # type: ignore[arg-type] - assert len(events_received) == 1 - assert events_received[0][0] == "sync" + @agent.tool_plain + def calculate_sum(a: int, b: int) -> int: + return a + b - await cap_async._dispatch_event_stream_event(dummy_ctx, dummy_event) # type: ignore[arg-type] - assert len(events_received) == 2 - assert events_received[1][0] == "async" + await agent.run("Add two numbers") + bound = LocalDurabilityCapability.from_agent(agent) - # Leaf toolset returns None - assert cap_sync._wrap_leaf_toolset(dummy_ctx) is None # type: ignore[arg-type] + assert bound is not None + assert {type(e) for e in events} >= {FunctionToolCallEvent, FunctionToolResultEvent} + assert all(bound.get_wrapper_toolset(ts) is None for ts in agent.toolsets) + assert {"tool_call", "tool_result"} <= {s.kind for s in cap.get_steps()} def test_resolve_durability_capability_mocked_external_engines( @@ -382,7 +374,7 @@ def test_resolve_durability_capability_mocked_external_engines( def test_create_durable_pydantic_agent_extended_options() -> None: """Verify create_durable_pydantic_agent with string model, custom capabilities, and system prompt.""" - extra_cap = LocalDurabilityCapability(name="extra_cap") + extra_cap = StepPersistence(name="extra_persistence") agent = create_durable_pydantic_agent( model="test", name="configured_worker", diff --git a/tests/test_pydantic_ai_result.py b/tests/test_pydantic_ai_result.py index 69084ce5b7..40369baae5 100644 --- a/tests/test_pydantic_ai_result.py +++ b/tests/test_pydantic_ai_result.py @@ -12,14 +12,9 @@ AgentStream, AgentStreamEvent, FinalResult, - OutputSchema, - OutputValidator, RunUsage, StreamedRunResult, StreamedRunResultSync, - SyncStreamBridge, - TextOutputSchema, - best_effort_price, calculate_usage_cost, create_run_usage, to_agent_response, @@ -43,13 +38,8 @@ def test_core_classes_and_type_exports(self) -> None: assert FinalResult is not None assert StreamedRunResult is not None assert StreamedRunResultSync is not None - assert SyncStreamBridge is not None - assert OutputValidator is not None - assert OutputSchema is not None - assert TextOutputSchema is not None assert AgentStream is not None assert AgentStreamEvent is not None - assert callable(best_effort_price) def test_create_run_usage(self) -> None: """Verify create_run_usage constructs a valid RunUsage instance.""" @@ -65,8 +55,8 @@ def test_create_run_usage(self) -> None: assert otel.get("gen_ai.usage.input_tokens") == 1500 assert otel.get("gen_ai.usage.output_tokens") == 300 - def test_calculate_usage_cost_with_best_effort_price(self) -> None: - """Test calculation of financial cost using native best_effort_price.""" + def test_calculate_usage_cost_with_genai_prices(self) -> None: + """Test calculation of financial cost through genai-prices.""" usage = create_run_usage(input_tokens=10000, output_tokens=2000) cost_calc = calculate_usage_cost(usage, model_name="gpt-4o") assert cost_calc is not None @@ -158,7 +148,6 @@ def test_package_reexports(self) -> None: assert hasattr(mod, "FinalResult") assert hasattr(mod, "StreamedRunResult") assert hasattr(mod, "StreamedRunResultSync") - assert hasattr(mod, "best_effort_price") assert hasattr(mod, "create_run_usage") assert hasattr(mod, "calculate_usage_cost") assert hasattr(mod, "to_agent_response") diff --git a/tests/test_pydantic_ai_run.py b/tests/test_pydantic_ai_run.py index 22894a657c..45c15b1acf 100644 --- a/tests/test_pydantic_ai_run.py +++ b/tests/test_pydantic_ai_run.py @@ -5,6 +5,9 @@ from datetime import UTC, datetime from unittest.mock import MagicMock +from opentelemetry import trace +from opentelemetry.trace import NonRecordingSpan, SpanContext, TraceFlags + from devops_cli.ai.agents.models import AgentResponse from devops_cli.ai.run import ( AgentRun, @@ -21,7 +24,6 @@ NodeStep, PendingMessage, create_pending_message, - current_otel_traceparent, format_run_summary, get_active_traceparent, ) @@ -45,7 +47,6 @@ def test_core_classes_and_type_exports(self) -> None: assert JoinItem is not None assert NodeStep is not None assert PendingMessage is not None - assert callable(current_otel_traceparent) assert callable(get_active_traceparent) assert callable(create_pending_message) assert callable(format_run_summary) @@ -61,9 +62,20 @@ def test_create_pending_message(self) -> None: assert msg_asap.priority == "asap" def test_get_active_traceparent(self) -> None: - """Verify get_active_traceparent returns string or None depending on active span.""" - tp = get_active_traceparent() - assert tp is None or isinstance(tp, str) + """Verify get_active_traceparent names the active span, and is None outside any span.""" + span_context = SpanContext( + trace_id=0x4BF92F3577B34DA6A3CE929D0E0E4736, + span_id=0x00F067AA0BA902B7, + is_remote=False, + trace_flags=TraceFlags(TraceFlags.SAMPLED), + ) + with trace.use_span(NonRecordingSpan(span_context)): + inside = get_active_traceparent() + + assert (inside, get_active_traceparent()) == ( + "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01", + None, + ) def test_format_run_summary(self) -> None: """Verify format_run_summary extracts structured metadata from an AgentRunResult.""" @@ -125,7 +137,6 @@ def test_package_reexports(self) -> None: assert hasattr(pkg, "JoinItem") assert hasattr(pkg, "NodeStep") assert hasattr(pkg, "PendingMessage") - assert hasattr(pkg, "current_otel_traceparent") assert hasattr(pkg, "get_active_traceparent") assert hasattr(pkg, "create_pending_message") assert hasattr(pkg, "format_run_summary") diff --git a/tests/test_pydantic_ai_toolsets.py b/tests/test_pydantic_ai_toolsets.py index 6fb1992b9c..ae4bdffdae 100644 --- a/tests/test_pydantic_ai_toolsets.py +++ b/tests/test_pydantic_ai_toolsets.py @@ -10,6 +10,8 @@ from typing import Any from unittest.mock import MagicMock +from pydantic_ai import RunContext as NativeRunContext + from devops_cli.ai.agents.context import RunContext from devops_cli.ai.tools import Tool from devops_cli.ai.toolsets import ( @@ -83,7 +85,7 @@ def test_function_toolset_tool_and_plain_decorators(self) -> None: ts = FunctionToolset() @ts.tool - def inspect_cluster(ctx: RunContext[Any], namespace: str) -> str: + def inspect_cluster(ctx: NativeRunContext[Any], namespace: str) -> str: """Inspect cluster namespace.""" return f"Cluster namespace: {namespace}" diff --git a/uv.lock b/uv.lock index acfff89a1b..b424edeeaf 100644 --- a/uv.lock +++ b/uv.lock @@ -132,7 +132,7 @@ wheels = [ [[package]] name = "anthropic" -version = "1.5.0" +version = "1.12.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, @@ -143,9 +143,9 @@ dependencies = [ { name = "sniffio" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/6e/43/6f3f6006f5216d43a059a1a856d275ef6536cdfa94883b64cc04d7873cb7/anthropic-1.5.0.tar.gz", hash = "sha256:b25f87f5758861f25993383a5c9bf274eb6e0f1b010c84019ad91854cb4e1bc6", size = 1156657, upload-time = "2026-09-10T17:45:35.93Z" } +sdist = { url = "https://files.pythonhosted.org/packages/bd/cc/0da23e94020c62c0077c17648252f32d575b187710faaf3b85145e8e555d/anthropic-1.12.1.tar.gz", hash = "sha256:10f720ab6ddf40ef12e0e5743412c3a6dfac1109c244e633c9a2dbd36778ad30", size = 1555908, upload-time = "2026-10-08T03:42:00.588Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/c2/1c/c32fce35ca0be0205f2377d2238e3ed73dea5abc2be09d15fbd032091d60/anthropic-1.5.0-py3-none-any.whl", hash = "sha256:d9ce04b29ad1f7025dda3e3bc478cde8d2924d2de5417d2d4a4bb0378ecbc2a6", size = 1235236, upload-time = "2026-09-10T17:45:34.216Z" }, + { url = "https://files.pythonhosted.org/packages/8b/35/1ccdc3e950dd869b66de15035e15d9614607fcef9664dec403fe639f01df/anthropic-1.12.1-py3-none-any.whl", hash = "sha256:1c1469bb3f4118291756816b7850cc839f17b2be5cdc99c8fde3890a61a49ca2", size = 1919752, upload-time = "2026-10-08T03:41:58.596Z" }, ] [[package]] @@ -763,7 +763,7 @@ requires-dist = [ { name = "packaging", specifier = "==26.3" }, { name = "pathspec", specifier = "==1.1.1" }, { name = "pydantic", specifier = "==2.13.5" }, - { name = "pydantic-ai", specifier = "==2.35.0" }, + { name = "pydantic-ai", specifier = "==2.54.0" }, { name = "pydantic-handlebars", specifier = "==0.2.1" }, { name = "pydantic-settings", specifier = "==2.15.0" }, { name = "pygithub", specifier = "==2.10.0" }, @@ -1097,7 +1097,7 @@ requests = [ [[package]] name = "google-genai" -version = "2.23.0" +version = "2.29.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, @@ -1111,9 +1111,9 @@ dependencies = [ { name = "typing-extensions" }, { name = "websockets" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/ae/9a/db14adffb0144584889e05f433a4e8ce540f9ed2928ed8b23cc65ab96178/google_genai-2.23.0.tar.gz", hash = "sha256:1ceebffdcd2af30c039a922ba05de61cd4054bb61c94be7649c4bf9ff8b33c5f", size = 686707, upload-time = "2026-09-10T22:55:31.12Z" } +sdist = { url = "https://files.pythonhosted.org/packages/21/2b/977616ef350e51d3d263eb43be23a91be793544cd937b51c0fac313be233/google_genai-2.29.0.tar.gz", hash = "sha256:124d3eef9ff6b9e4ea548f95ff5b7721683e7990c0a936b006d9e2ab61ea897d", size = 706902, upload-time = "2026-10-07T22:22:57.153Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/7f/b0/f6bc58a6a7c8ad7ad2b6a36b0bf4732b3504dd7d48c6674f848304548869/google_genai-2.23.0-py3-none-any.whl", hash = "sha256:1e63211d44d188b8069c2b354d92b9bde25c1e821513fdbe1948b7c0d9f6b922", size = 1093785, upload-time = "2026-09-10T22:55:29.282Z" }, + { url = "https://files.pythonhosted.org/packages/b8/27/a3dede4a1deb21f7fde6a171daa039bf0ea149a5e7826a785e8f109a6e13/google_genai-2.29.0-py3-none-any.whl", hash = "sha256:7adda55cb6746fb46d38ad3202c3372840b96eede964b5fb3df1469cd4998570", size = 1167603, upload-time = "2026-10-07T22:22:55.215Z" }, ] [[package]] @@ -2059,7 +2059,7 @@ wheels = [ [[package]] name = "openai" -version = "3.13.0" +version = "3.26.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, @@ -2069,9 +2069,9 @@ dependencies = [ { name = "sniffio" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/40/f1/4874c4f7db30121885e6a763e2670b2fe1d76c79ed4732f8acbb51c8d96e/openai-3.13.0.tar.gz", hash = "sha256:a8f87a9b3b9c08eb446d68bd0a80e8ec907c4c35fdea63f4265c7b34b2de3a60", size = 1624217, upload-time = "2026-09-10T19:38:27.597Z" } +sdist = { url = "https://files.pythonhosted.org/packages/36/f5/c9accd2d4077b0e56ffb63e9a943a656797c715bbd7c80f13f401865a350/openai-3.26.1.tar.gz", hash = "sha256:4b64060155596aece83aa81d270f326ee081b83da70a0d4b50091a0c60e9151c", size = 1820349, upload-time = "2026-10-08T08:54:23.757Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/63/7f/ee9ebb7c5ab7abf016969faec7c748a91c1fd893078bfe1e5ba5d82e96c2/openai-3.13.0-py3-none-any.whl", hash = "sha256:e35b1f6fe99245e86e37504d9fad1ad2a363807307c424232c1d849bd0666c8e", size = 2009683, upload-time = "2026-09-10T19:38:25.855Z" }, + { url = "https://files.pythonhosted.org/packages/1a/ee/f6042342ff42116ff8018849ef24a950ef367730ab0f9912c08c2f9b8aa0/openai-3.26.1-py3-none-any.whl", hash = "sha256:6a05a4615c678922aa16a1a560cfbe059cb20d5b7ab9753d0bf38b41fce1c67a", size = 2163859, upload-time = "2026-10-08T08:54:21.963Z" }, ] [[package]] @@ -2445,19 +2445,19 @@ email = [ [[package]] name = "pydantic-ai" -version = "2.35.0" +version = "2.54.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pydantic-ai-slim", extra = ["anthropic", "cli", "evals", "google", "logfire", "mcp", "openai", "web"] }, ] -sdist = { url = "https://files.pythonhosted.org/packages/e6/ed/772bca243444c47137aedc62d453a3138618bdf9496d8f15e5e5ae1b4117/pydantic_ai-2.35.0.tar.gz", hash = "sha256:72a571a6dc4784da6002988cdf443d7b3a3eb6f95ab6aef7e9fea484e76b8cfe", size = 23462, upload-time = "2026-08-26T01:41:41.512Z" } +sdist = { url = "https://files.pythonhosted.org/packages/91/ba/fe435fa9f06b5a78e72d2ba44918656e5824ccfc739700e141f3e2a386d8/pydantic_ai-2.54.0.tar.gz", hash = "sha256:8c3e4a08a9e5a4aa28c80ca40e064fe1115dfcc9ffdd2faa3818046ab6766467", size = 27974, upload-time = "2026-10-03T03:38:47.889Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/40/1f/253f51e8c1cb2c9f7588270f53745c698d2b208b16f037fb8d67786a1446/pydantic_ai-2.35.0-py3-none-any.whl", hash = "sha256:638c4678edbe85d351793ac512baa2f24f419c6c6427506511b528ff90f5f5ea", size = 9449, upload-time = "2026-08-26T01:41:32.531Z" }, + { url = "https://files.pythonhosted.org/packages/5d/74/92ebc5f809e1791bc909dc04fb032a885c1e2f32ab69ce6ee9d661d68eaf/pydantic_ai-2.54.0-py3-none-any.whl", hash = "sha256:c69ad15501e49a8584ce24bc89c4fa7bd67e15a8294fbeb28e3d017fe6480119", size = 10154, upload-time = "2026-10-03T03:38:33.763Z" }, ] [[package]] name = "pydantic-ai-slim" -version = "2.35.0" +version = "2.54.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, @@ -2469,9 +2469,9 @@ dependencies = [ { name = "pydantic-graph" }, { name = "typing-inspection" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/20/fa/29705d123404dbb354a36d558fd04af49b96999ff876080befba8357b884/pydantic_ai_slim-2.35.0.tar.gz", hash = "sha256:a19cec47fdba200944e207d2862afe87b8918eb6661f46ae124dfc836aab390b", size = 1262636, upload-time = "2026-08-26T01:41:43.869Z" } +sdist = { url = "https://files.pythonhosted.org/packages/54/c0/b5e33b82b05c87a03e2c18089e89671da5c8fb0ba0da143011917d102745/pydantic_ai_slim-2.54.0.tar.gz", hash = "sha256:e39fd5ded83c5f2f1b271f42707de04fba420c4fd2c3bbc809d8d57614b904df", size = 1802066, upload-time = "2026-10-03T03:38:51.982Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/ff/6c/c232c99e306529454f23704385dbd6e204a2fef24f6128cff97859a20ea3/pydantic_ai_slim-2.35.0-py3-none-any.whl", hash = "sha256:bfb542fd5d6e4cb1ccabb6b64ef110a41591ff6886395a45390d262c18a2d6df", size = 1489896, upload-time = "2026-08-26T01:41:35.905Z" }, + { url = "https://files.pythonhosted.org/packages/e7/2c/93dbb3ba7d13eea6b1c4af02da6a3ab84ed087747b7e801ab675523b3e59/pydantic_ai_slim-2.54.0-py3-none-any.whl", hash = "sha256:b64d2394f1b38d8b02c9a7916ce7bd331cfc25df41372e68d847fd71801fe112", size = 2115426, upload-time = "2026-10-03T03:38:39.601Z" }, ] [package.optional-dependencies] @@ -2550,7 +2550,7 @@ wheels = [ [[package]] name = "pydantic-evals" -version = "2.35.0" +version = "2.54.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, @@ -2560,14 +2560,14 @@ dependencies = [ { name = "pyyaml" }, { name = "rich" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/9c/10/68174f5022d798963ceda349dc4c8dd145cc8bef604dc6dea6b27fc1e24d/pydantic_evals-2.35.0.tar.gz", hash = "sha256:c0f0a6d7bc24ba795072b08bba09e512b5521f21385b848c42e7963eddd8d587", size = 86809, upload-time = "2026-08-26T01:41:45.308Z" } +sdist = { url = "https://files.pythonhosted.org/packages/e7/d9/493e0009c1bb72f749f175c9edb8aa4dbebd743ede29130adc81bc5bbb29/pydantic_evals-2.54.0.tar.gz", hash = "sha256:e2bf339714006a1095e738db8e5a49c1e8f03c832d7877b11ecb32bd3dcd5a6c", size = 91275, upload-time = "2026-10-03T03:38:54.905Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/11/49/2f6785afc8b0b07b909334d73e65a9cc91d6ac19b6d2ac8e21bb5c3addb3/pydantic_evals-2.35.0-py3-none-any.whl", hash = "sha256:aeebb624e757a50a48a4e78d81761cd2209f27d297ca5ccbc8bf53344f3ea746", size = 102013, upload-time = "2026-08-26T01:41:37.741Z" }, + { url = "https://files.pythonhosted.org/packages/6b/10/ecee90fa15fc385360988a36f69db14211d5324b065da7aa059b0b7f9937/pydantic_evals-2.54.0-py3-none-any.whl", hash = "sha256:8665229260b3af238c1d6a36f7cbd79801b4d315d50685a66c1bb260e5466227", size = 106542, upload-time = "2026-10-03T03:38:43.756Z" }, ] [[package]] name = "pydantic-graph" -version = "2.35.0" +version = "2.54.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, @@ -2575,9 +2575,9 @@ dependencies = [ { name = "pydantic" }, { name = "typing-inspection" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/e5/7b/848bb2843f74296d389cfc936a63986640f43286b73c63ddaeb3e9fe8dde/pydantic_graph-2.35.0.tar.gz", hash = "sha256:abb85087d2b9992f24b58ad94fc3580c7e921ee55740acedf410d858f880fc8c", size = 45162, upload-time = "2026-08-26T01:41:46.323Z" } +sdist = { url = "https://files.pythonhosted.org/packages/ef/6f/b5cb10c937c8d00a219eb5a07aeb991d0c44d09d5ac31a087cd1ad40dbcd/pydantic_graph-2.54.0.tar.gz", hash = "sha256:948ff7249c28643ff028b47fab22b8a5b36912c59bb947c2a9b9bc18de1d5fa5", size = 45970, upload-time = "2026-10-03T03:38:55.987Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/e9/f1/fb23f32ad9072bced0b7854218f3e7c13de7c1aa1ab12af540790ba9b0b3/pydantic_graph-2.35.0-py3-none-any.whl", hash = "sha256:6cddd23b3481d532c3c91e1c149c6c65ab277ab03c72857e83f385dc5d11a40a", size = 52648, upload-time = "2026-08-26T01:41:39.226Z" }, + { url = "https://files.pythonhosted.org/packages/6f/31/0d46d4003cb9e452bcf97f56f7c948006b5ad8036fd2ddb6fd7d5c73e8ff/pydantic_graph-2.54.0-py3-none-any.whl", hash = "sha256:465b87d5507af1341ba31b949af8619009c5010068159e52cf9b9806eb674fa4", size = 53423, upload-time = "2026-10-03T03:38:45.385Z" }, ] [[package]]