Case Files

Reliability and error handling / P2

Pydantic AI: From Finding to Fix PR

The bug

When loading failed, the agent continued with a fresh session. Saving it could overwrite the conversation's valid state.

The proposed repair

The proposed change skips saving after a failed load, except after an explicit restart. It adds a state-preservation test and updates the documentation.

Focused Early finding-list row for Failed load still overwrites saved REPL, with the Fix action highlighted, P2, category, BUG type and ACTIVE status

Step 1

Find the bug

Spot the finding, inspect its evidence, then initiate a fix.

Focused screenshot excerpts of Early's saved REPL finding, showing P2, Reliability and error handling, the Fix action and Before/Now evidence

Step 2

Create the Fix PR

The user confirms the repository and target branch before initiating the repair.

Focused screenshot excerpts of Early's Create a fix Pull Request dialog, showing the saved REPL finding, fork, main branch, Create button and review control

Step 3

Review the draft PR

Early opens draft PR #3 with the proposed code change, test, and repair explanation. Engineering controls the merge.

Focused screenshot excerpts of GitHub draft PR 3 created by Early for preserving CodeMode REPL state, showing the title, Draft status and four changed files

Step 4

Illustrative next step

Review and merge the PR

Engineering reviews the proposed code and tests, then merges the approved fix. This illustrates the next step, not this case's current outcome: PR #3 is still a draft.

Illustrative engineer-controlled review and merge workflow, showing a Merge pull request action followed by Merged status, not PR 3's actual outcome
Bug
When loading failed, the agent continued with a fresh session. Saving it could overwrite the conversation's valid state.
Files changed
4
Patch
+41 / −11
Result

A proposed repair on Early's fork. Not merged upstream. Engineering reviews and controls the merge.

Verification and remaining evidence

The fork PR reports a passing Python compilation check. Upstream automation reports reproducing the original state-loss failure, not verifying this repair. Behavioral tests for the proposed fix have not yet been executed. The explicit restart exception still needs dedicated test coverage. GitHub currently reports no CI checks for this proposal.

python3 -m py_compile src/pydantic_ai_harness/pydantic_ai_harness/code_mode/_repl_store.py tests/harness/code_mode/test_repl_store.py
Proposed fix ced2bfd

Prepared by Early Technologies using its own open-source analysis and fork. Pydantic AI is not presented as an Early customer or endorser.

Explore more