-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: preserve GPT-5 conversation continuity after subtask completion #8403
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
Closed
Closed
Changes from all commits
Commits
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
Submodule pr-8274
added at
e46929
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 |
|---|---|---|
|
|
@@ -1776,4 +1776,127 @@ describe("Cline", () => { | |
| consoleErrorSpy.mockRestore() | ||
| }) | ||
| }) | ||
|
|
||
| describe("GPT-5 Subtask Completion", () => { | ||
| it("should NOT skip previous_response_id for GPT-5 models after subtask completion", async () => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Completeness. Add a test that, after completeSubtask() with GPT‑5, the subsequent attemptApiRequest() includes metadata.previousResponseId (and omits suppressPreviousResponseId). This validates the continuity chain beyond just the flag. |
||
| // Create a mock GPT-5 API configuration | ||
| const gpt5ApiConfig = { | ||
| apiProvider: "openai-native" as const, | ||
| apiModelId: "gpt-5-codex", | ||
| openAiNativeApiKey: "test-key", | ||
| } | ||
|
|
||
| // Create parent task with GPT-5 model | ||
| const parentTask = new Task({ | ||
| provider: mockProvider, | ||
| apiConfiguration: gpt5ApiConfig, | ||
| task: "parent task", | ||
| startTask: false, | ||
| }) | ||
|
|
||
| // Mock the API model to return GPT-5 | ||
| vi.spyOn(parentTask.api, "getModel").mockReturnValue({ | ||
| id: "gpt-5-codex", | ||
| info: { | ||
| contextWindow: 128000, | ||
| maxTokens: 4096, | ||
| inputPrice: 0.25, | ||
| outputPrice: 0.75, | ||
| } as any, | ||
| }) | ||
|
|
||
| // Spy on say and addToApiConversationHistory | ||
| const saySpy = vi.spyOn(parentTask, "say").mockResolvedValue(undefined) | ||
| const addToApiSpy = vi.spyOn(parentTask as any, "addToApiConversationHistory").mockResolvedValue(undefined) | ||
|
|
||
| // Call completeSubtask | ||
| await parentTask.completeSubtask("Subtask completed successfully") | ||
|
|
||
| // Verify the subtask result was added | ||
| expect(saySpy).toHaveBeenCalledWith("subtask_result", "Subtask completed successfully") | ||
| expect(addToApiSpy).toHaveBeenCalledWith({ | ||
| role: "user", | ||
| content: [{ type: "text", text: "[new_task completed] Result: Subtask completed successfully" }], | ||
| }) | ||
|
|
||
| // Verify skipPrevResponseIdOnce is NOT set for GPT-5 models | ||
| expect((parentTask as any).skipPrevResponseIdOnce).toBe(false) | ||
| }) | ||
|
|
||
| it("should skip previous_response_id for non-GPT-5 models after subtask completion", async () => { | ||
| // Create a mock non-GPT-5 API configuration | ||
| const claudeApiConfig = { | ||
| apiProvider: "anthropic" as const, | ||
| apiModelId: "claude-3-5-sonnet-20241022", | ||
| apiKey: "test-key", | ||
| } | ||
|
|
||
| // Create parent task with Claude model | ||
| const parentTask = new Task({ | ||
| provider: mockProvider, | ||
| apiConfiguration: claudeApiConfig, | ||
| task: "parent task", | ||
| startTask: false, | ||
| }) | ||
|
|
||
| // Mock the API model to return Claude | ||
| vi.spyOn(parentTask.api, "getModel").mockReturnValue({ | ||
| id: "claude-3-5-sonnet-20241022", | ||
| info: { | ||
| contextWindow: 200000, | ||
| maxTokens: 4096, | ||
| inputPrice: 0.25, | ||
| outputPrice: 0.75, | ||
| } as any, | ||
| }) | ||
|
|
||
| // Spy on say and addToApiConversationHistory | ||
| const saySpy = vi.spyOn(parentTask, "say").mockResolvedValue(undefined) | ||
| const addToApiSpy = vi.spyOn(parentTask as any, "addToApiConversationHistory").mockResolvedValue(undefined) | ||
|
|
||
| // Call completeSubtask | ||
| await parentTask.completeSubtask("Subtask completed successfully") | ||
|
|
||
| // Verify the subtask result was added | ||
| expect(saySpy).toHaveBeenCalledWith("subtask_result", "Subtask completed successfully") | ||
| expect(addToApiSpy).toHaveBeenCalledWith({ | ||
| role: "user", | ||
| content: [{ type: "text", text: "[new_task completed] Result: Subtask completed successfully" }], | ||
| }) | ||
|
|
||
| // Verify skipPrevResponseIdOnce IS set for non-GPT-5 models | ||
| expect((parentTask as any).skipPrevResponseIdOnce).toBe(true) | ||
| }) | ||
|
|
||
| it("should handle edge case where model ID is undefined", async () => { | ||
| // Create task with minimal configuration | ||
| const parentTask = new Task({ | ||
| provider: mockProvider, | ||
| apiConfiguration: mockApiConfig, | ||
| task: "parent task", | ||
| startTask: false, | ||
| }) | ||
|
|
||
| // Mock the API model to return undefined ID | ||
| vi.spyOn(parentTask.api, "getModel").mockReturnValue({ | ||
| id: undefined as any, | ||
| info: { | ||
| contextWindow: 200000, | ||
| maxTokens: 4096, | ||
| inputPrice: 0.25, | ||
| outputPrice: 0.75, | ||
| } as any, | ||
| }) | ||
|
|
||
| // Spy on say and addToApiConversationHistory | ||
| const saySpy = vi.spyOn(parentTask, "say").mockResolvedValue(undefined) | ||
| const addToApiSpy = vi.spyOn(parentTask as any, "addToApiConversationHistory").mockResolvedValue(undefined) | ||
|
|
||
| // Call completeSubtask | ||
| await parentTask.completeSubtask("Subtask completed") | ||
|
|
||
| // When model ID is undefined, should default to skipping (non-GPT-5 behavior) | ||
| expect((parentTask as any).skipPrevResponseIdOnce).toBe(true) | ||
| }) | ||
| }) | ||
| }) | ||
Submodule pr-8287-Roo-Code
added at
88a473
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.
[P1] GPT‑5 detection robustness. Model ids can be prefixed or vary in case across providers. Suggest normalizing and using includes:\n\n
suggestion\n\t\t\tconst modelId = this.api.getModel().id\n\t\t\tconst isGpt5Model = typeof modelId === \"string\" && modelId.toLowerCase().includes(\"gpt-5\")\n\n\nAlso consider centralizing this in a small helper to keep parity with other call sites.