Skip to content

fix(deps): move pydantic-ai to 2.71 and the harness to 0.71 - #6524

Merged
dan-petty merged 9 commits into
mainfrom
fix/5098-pydantic-ai-2-71
Nov 20, 2026
Merged

dan-petty merged 9 commits into
mainfrom
fix/5098-pydantic-ai-2-71

Conversation

@dan-petty

@dan-petty dan-petty commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Move pydantic-ai from 2.59.0 to 2.71.0 and pydantic-ai-harness from 0.59.0 to 0.71.0. Experiment 1 of #6519 runs the stock harness Coder and needs them.

2.60 builds no RetryPromptPart, so the run trace and refine find a retry with is_retry. The build_results override takes answered_by. 2.71 names an HTTP error by its status category, so the gateway model reads a 408 stream frame before its timeout class and sends again, and the provider failure rule takes the class names that 2.71 adds. FileSystem comes from file_system, and ruff bans the old names. pydantic-ai caps google-genai below 3, so the Renovate hold is gone.

Coder now answers a spent tool retry with a failed result and the run goes on. The tool log notes that call as failed, so its repeat gets the refusal of a repeated failed call. A PR comment lists each behavior change that the upgrade forces.

Closes #5098

Change: openspec/changes/archive/2026-11-20-5098-pydantic-ai-2-71/

Pin pydantic-ai 2.71.0 and pydantic-ai-harness 0.71.0. Find retries with
is_retry, pass answered_by, send a 408 frame again, import FileSystem from
file_system, and drop the google-genai hold of Renovate.

Refs #5098
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/deps Dependency pins, upgrades and the supply chain labels Nov 20, 2026
@dan-petty

dan-petty commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner Author

Behavior changes that the upgrade forces

This pull request only moves the pins and keeps the behavior of today where the code can keep it. It adopts no new feature: no change to the shell policy, repo_context, the prompts of the jobs or the limits. The upgrade changes these behaviors, and the pull request keeps them as upstream gives them. Read the grade of the next runner version against this list.

Implement step (stock Coder 0.59 -> 0.71)

  1. A spent tool retry no longer ends the run (0.65). Coder now holds _ReportExhaustedRetries: the call that spends the retries of a tool gets the last error as a failed tool result (outcome='failed', with the text "<tool> has failed several times in a row. Do not repeat the same call: check the current state and try a different approach."), and the run goes on until the model ends it or a limit stops it. Before, the run stopped with UnexpectedModelBehavior: Tool '<tool>' exceeded max retries count of 5. Effects:
    • The "Last retries of : ..." line of the stop reason (feat(roadmap): the tool log of an implement step names why an edit_file call was retried #2866) does not show in a step any more, and the spent call counts as failed, not as a retry, so "Other retries" counts one less.
    • Arguments that break the schema of a tool still end the run when they spend the retries (validation does not go through the execute hook).
    • Correction after review: on 2.71 the spent call reaches ToolCallLog._execute as a raw ToolFailed (pydantic-ai makes it a ToolFailedError only after the wrap hooks return), which the log did not catch. So that call and each later failing call of the tool had no Job log line, no trace event and no failed digest, and the feat(roadmap): a repair attempt cannot repeat a failed tool call #3570 refusal did not stop an identical failing call. The log now catches ToolFailed and notes the call as failed with its reason, so the repeat gets the refusal and does not run. This keeps the behavior of today for the log; the run going on is the forced change.
  2. New base instructions of Coder (0.64, 0.65, 0.69). Old text: "Use tools to investigate, implement, and verify ... follow repository instructions and conventions ... Apply DRY, YAGNI, SOLID, and the Zen of Python ... Run focused tests and appropriate lint/type checks; report what you actually verified ... add tests only where the project already has them, and delete any scratch files". New text: "Match the surrounding code's style, structure, and imports. Work until done. ... Read files with read_file, not batched cat. ... Measure results against any numeric target the task states. Before finishing, go through each requirement and edge case the task states and confirm each one explicitly. ... Write checks from the task's stated behavior, not your code. Check behavior with heredocs for one-offs, not new files. Finish long-running work before replying; poll until done or blocked." The benchmark text moved to the opt-in BenchmarkInstructions (0.69), which the step does not add.
  3. No strict tool schemas for the Coder tools (0.64). _SetToolStrict(strict=False) sets strict=False on read_file, write_file, edit_file, list_files, grep and shell. Before, strict was unset, and an OpenAI-profile model sent a tool as strict when its schema allowed it.
  4. FileSystem protects the .git file (2.60). The read-only pattern **/.git/* became **/.git, so the agent cannot write the .git file of a worktree. Denied and read-only patterns match with no case.
  5. FileSystem moved to pydantic_ai_harness.file_system (0.69). The step imports it from there. The old module gives a HarnessDeprecationWarning.

All agent runs (pydantic-ai 2.59 -> 2.71)

  1. Retry parts (2.60). A retry that answers a tool call is that call's ToolReturnPart with outcome='retried'; one that answers no call is a RetryFeedbackPart. The text that the model reads at a retry changed with it: a retried call reaches the model as {"error": ...} tool content, and a RetryFeedbackPart goes in a <pyai:validation_errors> or <pyai:retry_feedback> fence. The run trace, the stop cause and the investigation of refine now read these parts (they read nothing on 2.60+ before this change).
  2. A reply cut by the output token limit with no output (2.68) ends the run at once with OutputTokenLimitExceeded, a kind of UnexpectedModelBehavior, and gets no output retry. The stop of refine names OutputTokenLimitExceeded in place of UnexpectedModelBehavior. The stage and implement checks of the length finish reason did not change.
  3. An HTTP error takes the class of its status category (2.62 and later). 400, 413 and 422 are ModelRequestRejectedError, 404 ModelNotFoundError, 408 ModelTimeoutError, 401 and 403 ModelAuthenticationError, and the class name is in the stop reason. The provider rule of roadmap/failure.py matched only ModelHTTPError and HTTP 429/5xx, so such stops fell to ci_infra. The rule now also takes Model<category>Error: HTTP <status>, after the parser rule (fix(security): the subprocess environment guard accepts the pytest and npm keys that make a child write a file #2747), so they stay provider. ModelContextWindowExceededError and ModelQuotaExceededError are left out: 2.59 named them already, and their stops stay ci_infra, as on main.
  4. An error frame inside a stream takes the category of its status. A 408 frame is a ModelTimeoutError (and still a ModelHTTPError). failed_before_first_event read it as a timeout of the client and stopped the second send. The change reads an error frame first, so the gateway call model sends the call again as before. A report of a model call that such a frame ends names the category class, for example ModelTimeoutError, and sets timed_out.
  5. Framing of application text (2.63, 2.67, 2.68). pydantic-ai says what its <system> tag means once a conversation needs it, and notes text that looks like an application frame in user and tool content. On open-model routes it breaks chat-template special tokens in content and restores them in model output.
  6. capture_run_messages keeps the reply that crosses a token or cost limit (2.61), so a trace of such a stop can count one more reply.

Not a change

  • google-genai stays 2.34.0: pydantic-ai 2.71 caps it below 3 itself, so the Renovate hold is gone. tenacity 9.1.4, genai-prices 0.2.5 and openai 3.49.0 meet the new floors.
  • The first-run banner of pydantic-ai stays off: src/devops_cli/entry.py sets PYDANTIC_AI_NO_BANNER.
  • The finish-reason tables of constants.py equal the maps of 2.71 (models/openai/_chat_completions.py, models/anthropic/_response.py); only the comment moved.

Tests that changed, and why

  • tests/support/model_script.py: new refused_call, refused_output and refused_text record the retry parts from a run of an agent on the installed pydantic-ai, and replace only the content when a test needs given errors. tool_answers reads ToolReturnPart | RetryFeedbackPart.
  • Stage toolbox, test_roadmap_agent_run, implement tool log, refine window: the hand-built RetryPromptPart became a recorded part. Alternatives, refine investigation, shell refusal: the class check became is_retry.
  • test_tool_definition: a new check that build_results passes answered_by (red before the override took it).
  • Refine: the stop of a cut reply names OutputTokenLimitExceeded (change 7).
  • Implement step (change 1): the outside-root read test uses 5 reads and a broken reply, so it counts retries inside the budget. "A tool that ends the run on retries" became "a file tool that runs out of retries fails its call and the run goes on". The three step tests of the last-retries line (masking, plain secret, cut) moved to one unit test of ToolCallLog on an agent with no Coder, where a tool still ends the run; the masking and the cut of each reason keep their unit tests in test_roadmap_implement_tool_log.py.

Checks run locally

See the later comment of the review round for the checks on the new head.

Overlap with other builders

None. This pull request touches no file of #6513 or #6518.

@dan-petty

dan-petty commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner Author

Check results

Head commit: 8623c1d85a28d6f04725c652749c5b0d4feefd14

Check Conclusion Link
Tests & Coverage success run
devops-cli success run
zizmor success run
trivy-config success run
Trivy success run
CodeQL success run
Service Image Tests (shard 2 of 6) success run
Service Image Tests (shard 6 of 6) success run
Service Image Tests (shard 4 of 6) success run
Service Image Tests (shard 3 of 6) success run
Service Image Tests (shard 5 of 6) success run
Service Image Tests (shard 1 of 6) success run
Plan Check skipped run
Semantic PR title success run
Tests on Main skipped run
Dependency Freshness skipped run
Test Job Duration skipped run
Fail-to-Pass Check success run
MCP Server Image success run
Design Tokens success run
Tests & Coverage (shard 5 of 5) success run
Tests & Coverage (shard 2 of 5) success run
Tests & Coverage (shard 1 of 5) success run
DevContainer Image success run
Tests & Coverage (shard 4 of 5) success run
Static Analysis success run
Service Image Build success run
Service Image success run
Docs Site Build success run
Runner Image success run
Changed-Test Independence success run
Tests & Coverage (shard 3 of 5) success run
Analyze (actions) success run
Analyze (python) success run

Fail-to-pass run: https://github.com/dan-petty/devops-cli/actions/runs/44796817642/job/136498389750

Skipped check: Plan Check
Skipped check: Tests on Main
Skipped check: Dependency Freshness
Skipped check: Test Job Duration

… as provider

On 2.71 the call that spends the retries of a tool reaches ToolCallLog as a raw
ToolFailed. The log now notes it as failed with its reason, so its repeat gets
the refusal of a repeated failed call (#3570). The provider rule takes the class
of an HTTP status category, such as ModelRequestRejectedError: HTTP 400. The
tool_retries description and the budgets spec say that a spent retry comes back
as a failed result. Each is_retry check of the run trace has a test.

Refs #5098
@dan-petty

dan-petty commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner Author

Review round 2: four findings fixed

The branch takes origin/main with a merge commit, not a rebase, so the push needed no force. Each fix keeps the behavior of today; none is new gate work.

  1. The call that spends the retries of a tool (major). On 2.71 Coder's _ReportExhaustedRetries raises a raw ToolFailed, which pydantic-ai makes a ToolFailedError only after the wrap hooks return. ToolCallLog._execute caught neither, so that call and each later failing call of the tool had no Job log line, no trace event and no failed digest, and the feat(roadmap): a repair attempt cannot repeat a failed tool call #3570 refusal did not stop an identical call. _execute now catches ToolFailed, notes the call as failed with its reason, and raises it again.
    • New test tests/roadmap/implement/test_roadmap_implement_step_trace.py::test_the_call_that_spends_the_retries_of_a_tool_fails_and_its_repeat_does_not_run: 6 edit_file calls on missing files, then the 6th call again. It checks the trace events (5 retry, 1 failed, 1 refused), the Job log line Tool call: edit_file, failed (File not found: <path>)., and that the repeat gets the feat(roadmap): a repair attempt cannot repeat a failed tool call #3570 refusal text and runs no tool.
    • Without the fix: 1 failed (the trace held 5 retry events and nothing for the spent call or the repeat). With the fix: 1 passed.
  2. HTTP status classes (minor). 2.71 names a 400, 413 or 422 ModelRequestRejectedError, a 404 ModelNotFoundError and a 408 ModelTimeoutError, and the stop reason holds that name, so the provider rule of roadmap/failure.py let them fall to ci_infra. The rule now also matches Model(?!ContextWindowExceeded|QuotaExceeded)\w*Error: HTTP \d{3}, still after the parser rule (fix(security): the subprocess environment guard accepts the pytest and npm keys that make a child write a file #2747). A transport timeout, which has no status, keeps its class. Round 3: the two classes that 2.59 named already keep ci_infra, as on main.
    • New test tests/roadmap/implement/test_roadmap_implement_step.py::test_a_status_that_pydantic_ai_names_by_its_category_is_a_failure_of_the_provider[400|404|408|413|422] builds the error with ModelHTTPError.for_category(http_status_category(status), ...), as the adapters do.
    • Without the fix: 5 failed (ci_infra). With the fix: 5 passed.
    • Round 3: the test is now test_a_status_that_pydantic_ai_names_by_its_category_keeps_the_class_of_its_stop, with two more cases, 400-context-window and 402-quota, that expect ci_infra. With the wide rule Model\w*Error: HTTP \d{3}: 2 failed, 5 passed. With the narrow rule: 7 passed.
  3. tool_retries text (rule 8). The description in config/settings.py, the comment in config/defaults.py and the generated docs/ENV_VARS.md say that a spent retry comes back to the model as a failed result, and that only arguments that break the schema of the tool end the run. The budgets spec has a MODIFIED delta in the archived change, equal to the main spec. The trace scenario also names the failed note and the refused repeat.
  4. Tests of the is_retry checks (rule 4). I removed each check of roadmap/agent_run.py in turn and ran the tests:
    • _retried_name: caught by test_the_stop_by_the_tools_retry_limit_names_the_tool_whose_call_was_retried.
    • The tool answers of the trace: caught by test_a_trace_keeps_no_retried_return_as_a_tool_answer.
    • _add_violations: caught by test_a_trace_keeps_the_violations_of_the_last_retry_after_the_output_succeeds.
    • _match_lines: no test can catch it, because model_response_str() (with wrap_if_error at its default, true) wraps a retried or failed answer in one {"error": ...} object, so no line of its text starts with a path. The check is removed, and test_a_retried_search_gives_no_match_lines locks the behavior.

Checks on the new head

Head bcfd1e9c9, which holds origin/main 0d14844d2.

  • uv run devops ci --check --only lint,format,typecheck: pass.
  • uv run devops ci test tests/roadmap/stage tests/roadmap/implement tests/roadmap/test_roadmap_alternatives.py tests/roadmap/refine tests/ai tests/core/test_renovate_config.py tests/roadmap/test_roadmap_failure.py tests/config: 10158 passed, 1 skipped.
  • uv run devops docs generate --check: up to date. uv run devops openspec check: pass. uv lock --check: pass.
  • The comment with the change list above is corrected: change 1 names the ToolFailed fix, and change 8 names the HTTP status classes.
  • CI results follow in the check-results comment.

pydantic-ai 2.59 named ModelContextWindowExceededError and
ModelQuotaExceededError already, and their stops were ci_infra. The provider
rule takes only the class names that 2.71 adds. The match-lines docstrings name
the {"error": ...} wrap of model_response_str().

Refs #5098
@dan-petty

Copy link
Copy Markdown
Owner Author

Review round 3

Head 8623c1d85, which holds origin/main 952ac24cb by a merge.

  1. Parity of the provider rule (minor). The rule matched ModelContextWindowExceededError: HTTP 400 and ModelQuotaExceededError: HTTP 402 too. pydantic-ai 2.59 named both already, and their stops were ci_infra on main. The rule is now Model(?!ContextWindowExceeded|QuotaExceeded)\w*Error: HTTP \d{3}, and the comment of the rules says why.
    • test_a_status_that_pydantic_ai_names_by_its_category_keeps_the_class_of_its_stop has two more cases, 400-context-window (built with ModelContextWindowExceededError) and 402-quota (built with http_status_category(402)), that expect ci_infra.
    • With the wide rule: 2 failed, 5 passed. With the narrow rule: 7 passed.
  2. Docstrings (nit). The docstring of _match_lines and of test_a_retried_search_gives_no_match_lines now say that model_response_str() wraps a retried or failed answer in one {"error": ...} object. They no longer say that the model always gets that object.

The change-list comment (change 8), the round 2 comment, the archived proposal, design and tasks, and the body now give the narrow scope. Body: 953 characters, 870 before Closes.

Local checks on 280aaf880 (before the merge of main):

  • uv run devops ci --check --only lint,format,typecheck: pass.
  • uv run devops ci test tests/roadmap/implement tests/roadmap/test_roadmap_failure.py tests/ai/client tests/roadmap/stage tests/roadmap/refine tests/roadmap/test_roadmap_alternatives.py: 6413 passed, 1 skipped.
  • uv run devops openspec check: pass.
  • After the merge of feat(deps): merge minor, patch and digest Renovate updates #6550: the Renovate config validator passes, and tests/core/test_renovate_config.py passes.

@dan-petty
dan-petty marked this pull request as ready for review November 20, 2026 19:07
@dan-petty
dan-petty merged commit 52f7231 into main Nov 20, 2026
37 checks passed
@dan-petty
dan-petty deleted the fix/5098-pydantic-ai-2-71 branch November 20, 2026 19:10
dan-petty pushed a commit that referenced this pull request Nov 20, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.184.0](v0.183.2...v0.184.0)
(2026-11-20)


### Features

* **deps:** merge minor, patch and digest Renovate updates
([#6550](#6550))
([952ac24](952ac24)),
closes [#6547](#6547)


### Bug Fixes

* **deps:** move pydantic-ai to 2.71 and the harness to 0.71
([#6524](#6524))
([52f7231](52f7231)),
closes [#5098](#5098)
* **openspec:** pin OpenSpec and Style Dictionary in the root npm
lockfile ([#6536](#6536))
([299e050](299e050))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/deps Dependency pins, upgrades and the supply chain type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant