Repository navigation
fix(server): ACP agents keep the kept conversation after Edit from here #30188
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
+463
−68
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5205ff5
test(server): reproduce #30136, rewound ACP conversation after Edit f…
juliusmarminge c2370d9
fix(server): ACP agents keep the kept conversation after Edit from here
juliusmarminge 4a8d632
fix(server): ACP rollback recovery survives legacy attempts and forks
juliusmarminge c4fa57c
fix(server): ACP rollback recovery covers fork baselines and id-less …
juliusmarminge e117e78
Merge remote-tracking branch 'origin/main' into fix/issue-30136
juliusmarminge 38e626c
test(server): drop ACP rollback scenarios covered by the remaining cases
juliusmarminge 690f7dc
test(server): give the resume-fallback session mock its provider session
juliusmarminge f2dbe7a
docs: ACP rollback keeps the conversation before the checkpoint
juliusmarminge a435ce2
Merge remote-tracking branch 'origin/main' into fix/issue-30136
juliusmarminge bbf6078
fix(server): ACP rollback recovery stops at the latest fresh-context …
juliusmarminge c5c7169
Merge remote-tracking branch 'origin/main' into fix/issue-30136
juliusmarminge 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
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
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
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
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
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,39 @@ | ||
| import type { OrchestrationV2Run, OrchestrationV2ThreadProjection } from "@t3tools/contracts"; | ||
|
|
||
| import { cancelledBeforeStart } from "./RestartBackgroundNote.ts"; | ||
|
|
||
| /** A fresh-session schedule run starts a side conversation; the thread's own one continues past it. */ | ||
| export function isScheduledFreshRun( | ||
| run: Pick<OrchestrationV2Run, "freshContext" | "userMessageId">, | ||
| turnItems: OrchestrationV2ThreadProjection["turnItems"], | ||
| ): boolean { | ||
| // Turn items, unlike messages, are not narrowed to the runs since the latest compaction. | ||
| return ( | ||
| run.freshContext === true && | ||
| turnItems.some( | ||
| (item) => | ||
| item.type === "user_message" && | ||
| item.messageId === run.userMessageId && | ||
| item.scheduledTaskId !== undefined, | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| /** Ordinal of the latest started fresh-context run. Runs before it never reach a provider again. */ | ||
| export function contextBoundaryOrdinal( | ||
| projection: Pick<OrchestrationV2ThreadProjection, "runs" | "turnItems">, | ||
| ): number { | ||
| let boundary = 0; | ||
| for (const run of projection.runs) { | ||
| if ( | ||
| run.freshContext === true && | ||
| run.status !== "queued" && | ||
| !cancelledBeforeStart(run) && | ||
| run.ordinal > boundary && | ||
| !isScheduledFreshRun(run, projection.turnItems) | ||
| ) { | ||
| boundary = run.ordinal; | ||
| } | ||
| } | ||
| return boundary; | ||
| } |
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.
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.
Legacy ACP threads can lose kept turns when only never-accepted runs are rolled back.
runsToRollbackincludes every later run with statuscompleted,interrupted,failed, orcancelled, whether or not the provider accepted it. A rollback that includes only such a run still calls ACProllbackThread, which starts an empty replacement session.For a thread whose newest accepted attempt is a completed run with no
nativeThreadId,nativeSessionMissesKeptTurnsreturns false. Its rolled-back check fails, and its native-ID check is skipped. The resume gate then callssession.resumeThreadon the empty replacement session. The turn can run without the kept conversation, and no recovery handoff is sent.Detection needs a reset signal that does not depend on the newest accepted attempt's
nativeThreadIdor its rolled-back status. Without one, this state stays undetected.