-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Handle local agent connection recovery #2853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0796088
Local agent retry codex
wwwillchen cefe711
tests
wwwillchen 6ca24a3
retry
wwwillchen 1583cc1
fix
wwwillchen 9246547
fix
wwwillchen 8593b7c
posthog!
wwwillchen ba49d25
fix
wwwillchen 47623be
fix
wwwillchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import type { LocalAgentFixture } from "../../../../testing/fake-llm-server/localAgentTypes"; | ||
|
|
||
| /** | ||
| * Tests automatic retry after connection drop (e.g., TCP terminated mid-stream). | ||
| * This fixture drops the connection on the first attempt of turn 1 (the | ||
| * post-tool text turn), which is more realistic than dropping before any | ||
| * tool activity. The local agent handler should automatically retry and | ||
| * continue without re-running completed work. | ||
| */ | ||
| export const fixture: LocalAgentFixture = { | ||
| description: "Automatic retry after connection drop", | ||
| dropConnectionByTurn: [{ turnIndex: 1, attempts: [1] }], | ||
| turns: [ | ||
| { | ||
| text: "I'll create a file for you.", | ||
| toolCalls: [ | ||
| { | ||
| name: "write_file", | ||
| args: { | ||
| path: "src/recovered.ts", | ||
| content: `export const recovered = true;\n`, | ||
| description: "File created after connection recovery", | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| text: "Successfully created the file after automatic retry.", | ||
| }, | ||
| ], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { expect } from "@playwright/test"; | ||
| import { testSkipIfWindows } from "./helpers/test_helper"; | ||
|
|
||
| /** | ||
| * E2E test for local-agent connection retry resilience. | ||
| * Verifies that the agent automatically recovers from transient connection | ||
| * drops (e.g., TCP terminated mid-stream) by retrying the stream. | ||
| */ | ||
|
|
||
| testSkipIfWindows( | ||
| "local-agent - recovers from connection drop", | ||
| async ({ po }) => { | ||
| await po.setUpDyadPro({ localAgent: true }); | ||
| await po.importApp("minimal"); | ||
| await po.chatActions.selectLocalAgentMode(); | ||
|
|
||
| // The connection-drop fixture drops on turn 1 (after a tool turn already | ||
| // completed) to simulate a realistic interrupted follow-up request. | ||
| await po.sendPrompt("tc=local-agent/connection-drop"); | ||
|
|
||
| // Verify the turn still completed and no error box leaked to the UI. | ||
| await expect(po.page.getByTestId("chat-error-box")).toHaveCount(0); | ||
| await expect( | ||
| po.page.getByText("Successfully created the file after automatic retry."), | ||
| ).toBeVisible(); | ||
|
|
||
| // Verify exactly one recovered.ts edit card is shown in chat. | ||
| await expect( | ||
| po.page.getByRole("button", { | ||
| name: /recovered\.ts .*src\/recovered\.ts.*Edit/, | ||
| }), | ||
| ).toHaveCount(1); | ||
|
|
||
| // Snapshot end state for chat + filesystem. | ||
| await po.snapshotMessages(); | ||
| await po.snapshotAppFiles({ | ||
| name: "after-connection-retry", | ||
| files: ["src/recovered.ts"], | ||
| }); | ||
| }, | ||
| ); | ||
2 changes: 2 additions & 0 deletions
2
e2e-tests/snapshots/local_agent_connection_retry.spec.ts_after-connection-retry.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| === src/recovered.ts === | ||
| export const recovered = true; |
48 changes: 48 additions & 0 deletions
48
...cal_agent_connection_retry.spec.ts_local-agent---recovers-from-connection-drop-1.aria.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| - paragraph: /Generate an AI_RULES\.md file for this app\. Describe the tech stack in 5-\d+ bullet points and describe clear rules about what libraries to use for what\./ | ||
| - button "file1.txt file1.txt Edit": | ||
| - img | ||
| - text: "" | ||
| - button "Edit": | ||
| - img | ||
| - text: "" | ||
| - img | ||
| - paragraph: More EOM | ||
| - button "Copy": | ||
| - img | ||
| - img | ||
| - text: Approved | ||
| - img | ||
| - text: claude-opus-4-5 | ||
| - img | ||
| - text: less than a minute ago | ||
| - img | ||
| - text: (1 files changed) | ||
| - button "Copy Request ID": | ||
| - img | ||
| - text: "" | ||
| - paragraph: tc=local-agent/connection-drop | ||
| - paragraph: I'll create a file for you. | ||
| - 'button "recovered.ts src/recovered.ts Edit Summary: File created after connection recovery"': | ||
| - img | ||
| - text: "" | ||
| - button "Edit": | ||
| - img | ||
| - text: "" | ||
| - img | ||
| - text: "" | ||
| - paragraph: Successfully created the file after automatic retry. | ||
| - button "Copy": | ||
| - img | ||
| - img | ||
| - text: claude-opus-4-5 | ||
| - img | ||
| - text: less than a minute ago | ||
| - button "Copy Request ID": | ||
| - img | ||
| - text: "" | ||
| - button "Undo": | ||
| - img | ||
| - text: "" | ||
| - button "Retry": | ||
| - img | ||
| - text: "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The conversation-order check is layout-dependent (
boundingBox().y) and can become flaky across environments; assert DOM/message sequence instead of pixel coordinates.Prompt for AI agents