Skip to content

build(deps): move pydantic-ai to 2.68 and its retry parts #5098

Description

@dan-petty

Problem or Motivation

pyproject.toml pins pydantic-ai 2.59.0 and pydantic-ai-harness 0.59.0. The newest are 2.68.0 and 0.68.0. The baseline (#5065) keeps them. Renovate (#4893) will offer them, and the move breaks run-time checks with no error:

  • 2.60.0 compatibility note: "Deprecate RetryPromptPart in favor of ToolReturnPart(outcome=retried) and RetryFeedbackPart". The framework no longer builds RetryPromptPart, so isinstance checks stop matching at run time. A RetryPromptPart that a test builds still matches, which hides the change.
  • Code: src/devops_cli/roadmap/agent_run.py:28,310,336,355-363,373,383 (_add_violations no longer counts output-schema violations), src/devops_cli/roadmap/refine/refine_investigation.py:38,466.
  • Tests that build RetryPromptPart: tests/roadmap/stage/test_roadmap_stage_toolbox.py:923, tests/roadmap/test_roadmap_alternatives.py:19,2116, tests/roadmap/refine/test_roadmap_refine_investigation.py:35,1163, tests/roadmap/implement/test_roadmap_implement_shell_refusal.py:14,218.
  • mypy: src/devops_cli/ai/tools/__init__.py:248, the DeferredToolRequests.build_results override lacks the new answered_by parameter.
  • 15 tests fail on 2.68.0: test_roadmap_stage_toolbox (4), test_roadmap_implement_step (5), test_roadmap_alternatives (4), test_roadmap_refine_investigation (2).
  • pydantic-ai 2.67 and later cap google-genai<3. The baseline adds a Renovate rule that holds google-genai below 3 until this item; the same move lifts that rule. Also check genai-prices>=0.2.3 and openai>=3.31.0 (already met).
  • tenacity 9.2.x cannot resolve while google-genai caps tenacity<9.2.0.

Research of 2026-11-12 (research-python, migration pydantic-ai + pydantic-ai-harness).

Proposed Solution & Architectural Design

  • Match ToolReturnPart(outcome=retried) and RetryFeedbackPart where the code matches RetryPromptPart; make the tests build the parts that 2.68 builds (from a recorded run, not by hand).
  • Add answered_by to the build_results override.
  • Pin pydantic-ai 2.68.0 and pydantic-ai-harness 0.68.0; remove the google-genai hold of the Renovate preset.

Done when the 15 tests pass on 2.68 with parts that the framework builds, and mypy is clean.

Target Subsystem

AI & Agentic Review Pipeline

Existing Tool Considered

pydantic-ai itself. No new code beyond the part matching.

Source: #4893

Alternatives check of 2026-11-15: in-use.
The repository already uses this tool.
Tool: pydantic-ai (https://pypi.org/project/pydantic-ai), MIT, last activity 2026-11-12, maintained.

Proposed design

Problem statement

pyproject.toml pins pydantic-ai 2.59.0 and pydantic-ai-harness 0.59.0. Versions 2.68.0 and 0.68.0 replace RetryPromptPart with ToolReturnPart(outcome=retried) and RetryFeedbackPart. They also add the answered_by parameter to DeferredToolRequests.build_results. The repository still matches the old class in two modules and in five test modules, and the type override lacks the new parameter. So 15 tests fail on 2.68.0, and the trace stops counting output-schema violations with no error. The baseline item #5065 also added a Renovate rule that holds google-genai below 3, and .github/renovate.json states that this item removes it, so the move lifts that hold as well.

Acceptance criteria

Requirement: The trace counts a retried output

RunTrace.absorb SHALL count the output-schema violations of a retry from the parts that pydantic-ai 2.68 builds.

Scenario: A recorded retry of the output tool

  • WHEN a test feeds the messages of a recorded 2.68 run in which the output tool retried once
  • THEN the trace has violations == 1 and one masked text in violation_texts

Requirement: A retried tool call keeps its error outcome

The trace SHALL record a retried function-tool call with the error outcome and the characters of its retry text.

Scenario: A recorded retry of a function tool

  • WHEN a test absorbs the messages of a recorded 2.68 run in which a function tool retried
  • THEN the ToolCallRecord of that call has outcome error and the length of the retry text

Requirement: The investigation detects a retried output

refine_investigation SHALL detect a retried output from the parts that pydantic-ai 2.68 builds.

Scenario: The investigation reads a retry

  • WHEN a test feeds the investigation the messages of a recorded 2.68 run that retried its output tool
  • THEN the investigation reports the retry as it reported a RetryPromptPart before

Requirement: No code or test names the deprecated part

src/ and tests/ MUST hold no reference to RetryPromptPart.

Scenario: The scan of the source tree

  • WHEN a test searches src/ and tests/ for the name RetryPromptPart
  • THEN the search returns no path

Requirement: The build_results override takes answered_by

The DeferredToolRequests.build_results override SHALL accept the answered_by parameter.

Scenario: A call with answered_by

  • WHEN a test calls build_results with answered_by set
  • THEN the call returns the built results with no error

Requirement: The type check is clean

src/devops_cli/ai/tools/__init__.py MUST pass the strict type check with no error.

Scenario: The strict check of the module

  • WHEN uv run mypy src/devops_cli/ai/tools/__init__.py runs
  • THEN it exits 0 and reports no error

Requirement: The lock agrees with the new pins

pyproject.toml and uv.lock SHALL pin pydantic-ai 2.68.0 and pydantic-ai-harness 0.68.0.

Scenario: The lock check after the pin change

  • WHEN uv lock --check runs after the pins change
  • THEN it exits 0 and reports no lock that differs from the pins

Requirement: The affected test modules pass on 2.68.0

The roadmap and AI test modules that failed on 2.68.0 SHALL pass on 2.68.0.

Scenario: The five affected modules

  • WHEN uv run pytest tests/roadmap tests/ai runs on pydantic-ai 2.68.0
  • THEN it exits 0 with no failed test

Requirement: The google-genai hold is gone

.github/renovate.json MUST hold no allowedVersions rule that keeps google-genai below 3.

Scenario: The Renovate config validator

  • WHEN npx --yes --package [email protected] renovate-config-validator --strict --no-global .github/renovate.json .github/renovate/base.json runs after the rule is removed
  • THEN it exits 0 and prints Config validated successfully against 2 file(s)

Existing Tool Considered

pydantic-ai (https://pypi.org/project/pydantic-ai), MIT, maintained, last activity 2026-11-12, with pydantic-ai-harness (https://pypi.org/project/pydantic-ai-harness). The repository already pins both, and the check found 2.68.0 and 0.68.0 released and maintained. The library covers the need: it ships ToolReturnPart(outcome=retried), RetryFeedbackPart and the answered_by parameter of DeferredToolRequests.build_results (https://pydantic.dev/docs/ai/tools-toolsets/deferred-tools/). It lacks the repository's own work: the isinstance matching in agent_run.py and refine_investigation.py, the fixtures of five test modules, the mypy override in ai/tools/__init__.py, and the removal of the google-genai hold in .github/renovate.json. The change adds no code beyond the part matching.

Key questions

  • Which parts must the code match for a retry after pydantic-ai 2.68?: Match RetryFeedbackPart and ToolReturnPart with a retried outcome in place of RetryPromptPart. Keep no match on the deprecated class. (best practice) [sources: src/devops_cli/roadmap/agent_run.py:347, src/devops_cli/roadmap/refine/refine_investigation.py:482]
    • Chosen: Match the new parts. 2.68 builds these parts, so the match holds at run time.
    • Rejected: Keep the RetryPromptPart match. 2.68 builds no such part, so the isinstance check stops matching with no error.
    • Rejected: Match by tool_call_id only. The trace also needs the outcome and the violation text of the retry.
  • How do the tests get the retry parts that 2.68 builds?: Record the messages of a 2.68 run and feed them through the test support module. Do not build the parts by hand. (best practice) [sources: tests/support/model_script.py:151, tests/roadmap/stage/test_roadmap_stage_toolbox.py:963]
    • Chosen: Record the parts from a run. The recorded parts are the parts that the framework builds, so the test cannot pass on a shape that 2.68 never emits.
    • Rejected: Keep the hand-built parts. A hand-built RetryPromptPart still matches, which hides the change.
  • Do the two dependencies keep an exact pin?: Yes. Set pydantic-ai[spec]==2.68.0 and pydantic-ai-harness[coder]==0.68.0, because the file pins every dependency exactly. (best practice) [sources: pyproject.toml:40, pyproject.toml:41]
    • Chosen: Exact pin. Every dependency of pyproject.toml has an exact pin, so a range would break the file's convention.
    • Rejected: Range pin. A range lets an untested release into the lock and departs from the file's convention.
  • How does the mypy override change?: Add the answered_by parameter, with the type that 2.68 declares, to the DeferredToolRequests.build_results override in src/devops_cli/ai/tools/__init__.py, and pass it through to super().build_results(...). (best practice) [sources: src/devops_cli/ai/tools/init.py:248, https://pydantic.dev/docs/ai/tools-toolsets/deferred-tools/]
    • Chosen: Add the parameter to the override. The strict check reads the override signature, and the new parameter keeps it the same as the library's.
    • Rejected: Suppress the error. A suppression hides a real signature difference and needs a reason and an expiry.
  • Do the other constraints of pydantic-ai 2.68 hold in the current pins?: Yes. genai-prices==0.2.3 meets >=0.2.3, and openai==3.49.0 meets >=3.31.0. [sources: pyproject.toml:51, pyproject.toml:44]
  • Does the tenacity<9.2.0 cap of google-genai block the move?: No. pyproject.toml pins tenacity==9.1.4, below the cap, so the resolver is satisfied. [sources: pyproject.toml:54]
  • Does the move need the baseline item build(deps): take every safe version update before Renovate #5065 first?: No. build(deps): take every safe version update before Renovate #5065 is already merged: its change is archived, its tasks are done, and the baseline pins and the google-genai hold it added are in the tree. This item only moves the pins on top of them. [sources: .github/renovate.json:341, openspec/changes/archive/2026-11-12-5065-take-every-safe-version-update-before/tasks.md:15, pyproject.toml:40]
  • Does this item remove the google-genai hold of the Renovate config?: Yes. The hold is the allowedVersions: "<3" rule for google-genai in the repository's own .github/renovate.json, not in the shared preset .github/renovate/base.json. Both that file's description and the design of build(deps): take every safe version update before Renovate #5065 name this item as the one that removes it, so delete the rule here and validate the file with npx --yes --package [email protected] renovate-config-validator --strict --no-global .github/renovate.json .github/renovate/base.json. (best practice) [sources: .github/renovate.json:341, openspec/changes/archive/2026-11-12-5065-take-every-safe-version-update-before/design.md:10, openspec/changes/archive/2026-11-16-6051-searxng-renovate-branch/tasks.md:8]
    • Chosen: Remove the rule here. The rule lives in .github/renovate.json, and that file and the design of build(deps): take every safe version update before Renovate #5065 both record that this item removes it.
    • Rejected: Defer the rule removal to a new issue. The file is in this repository and a validator command exists, so the removal is part of this item and needs no person.
    • Rejected: Change the shared preset. The hold was put in .github/renovate.json because it is a fact of this repository's lock, not of every Service repository.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/infra
    scope/deps
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The web searches returned only unrelated Docker Hub hits, but the fact reads show that pydantic-ai 2.68.0 and pydantic-ai-harness 0.68.0 — exactly the versions the issue asks to move to — are released and maintained, and the issue itself names pydantic-ai as the tool that ships the new retry-part types (ToolReturnPart(outcome=retried), RetryFeedbackPart) and the answered_by parameter. The library covers the whole need; only the repository's own isinstance matching, test fixtures and mypy override must be adapted on top of it.

    The repository already uses this tool.

    Tool: pydantic-ai (https://pypi.org/project/pydantic-ai)

    • License: MIT
    • Last activity: 2026-11-12
    • Maintained: yes

    Covers:

    • Ships the replacement retry parts ToolReturnPart(outcome=retried) and RetryFeedbackPart that the code must match
    • Supplies the new answered_by parameter on DeferredToolRequests.build_results
    • pydantic-ai 2.68.0 and pydantic-ai-harness 0.68.0 are the released versions the pin moves to
    • Already the agent runtime the project pins in pyproject.toml, so no new dependency is needed

    Lacks:

    • The repository's own isinstance checks in agent_run.py and refine_investigation.py still need to be rewritten for the new parts
    • The five test modules that build RetryPromptPart by hand must build the parts 2.68 actually emits
    • The mypy override fix in ai/tools/init.py is project code, not provided by the library
    • Removing the Renovate google-genai hold and resolving the tenacity/google-genai cap is repository configuration work

    Tools considered:

    Searches run:

    • pydantic-ai RetryPromptPart deprecated ToolReturnPart outcome retried RetryFeedbackPart, results: 5
    • pydantic-ai 2.68 release notes answered_by DeferredToolRequests build_results, results: 5
    • "pydantic-ai" github repository pydantic, results: 5
    • pydantic-ai PyPI package agent framework, results: 5
    • pydantic-ai changelog "RetryPromptPart" deprecation, results: 5

    Sources:

    Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.

  6. added
    status/ready
    and removed
    status/new
    on Nov 17, 2026
  7. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at c58b592 (see proposed design in issue body).

  8. added
    status/in-progress
    and removed
    status/ready
    on Nov 20, 2026
  9. added
    status/in-review
    and removed
    status/in-progress
    on Nov 20, 2026
  10. removed
    status/in-review
    on Nov 20, 2026
  11. added a commit that references this issue on Nov 20, 2026
  12. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-20 19:43 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/depssource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions