-
Notifications
You must be signed in to change notification settings - Fork 6k
feat: use acp for desktop chat prompt (feature toggle off) #9802
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 17 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
013c5d9
created feature toggle for acpChatSession hook
lifeizhou-ap bb08952
created notification listeners
lifeizhou-ap 4d6d4b3
added message adapter to handle acp notifications
lifeizhou-ap 0be94d6
added acp prompt call
lifeizhou-ap 2b90fd8
wire acp prompt for simple messages
lifeizhou-ap becfbc3
wire prompt cancel
lifeizhou-ap cdd3319
added tool call parsing
lifeizhou-ap aaa3247
error handling
lifeizhou-ap c9186c4
handling custom status notification
lifeizhou-ap cb07a84
added adapter tests
lifeizhou-ap c4d90ac
refactor to group adapter into a folder
lifeizhou-ap cdb8171
more refactor
lifeizhou-ap 0d36bb7
address comments
lifeizhou-ap 678dbd5
Merge branch 'main' into lifei/acp-session-load-feature-toggle
lifeizhou-ap e7dd14b
added feature toggle for fallback
lifeizhou-ap a4c0d11
turn of acp chat feature toggle
lifeizhou-ap 26bb389
fixed test
lifeizhou-ap b1269eb
fix: address codex P2s in ACP desktop chat
cee62de
Merge branch 'main' into lifei/acp-session-load-feature-toggle
lifeizhou-ap 401c96c
fixed merge issue
lifeizhou-ap 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { parseAcpCreditsExhaustedError } from '../errors'; | ||
|
|
||
| describe('parseAcpCreditsExhaustedError', () => { | ||
| it('parses structured ACP credits exhausted errors', () => { | ||
| expect( | ||
| parseAcpCreditsExhaustedError({ | ||
| code: -32603, | ||
| message: 'Please add credits to your account, then resend your message to continue.', | ||
| data: { | ||
| reason: 'credits_exhausted', | ||
| url: 'https://router.tetrate.ai/billing', | ||
| }, | ||
| }) | ||
| ).toEqual({ | ||
| message: 'Please add credits to your account, then resend your message to continue.', | ||
| url: 'https://router.tetrate.ai/billing', | ||
| }); | ||
| }); | ||
|
|
||
| it('parses wrapped JSON-RPC errors', () => { | ||
| expect( | ||
| parseAcpCreditsExhaustedError({ | ||
| error: { | ||
| code: -32603, | ||
| message: 'Add credits to continue.', | ||
| data: { | ||
| reason: 'credits_exhausted', | ||
| }, | ||
| }, | ||
| }) | ||
| ).toEqual({ | ||
| message: 'Add credits to continue.', | ||
| }); | ||
| }); | ||
|
|
||
| it('ignores non-credits-exhausted errors', () => { | ||
| expect( | ||
| parseAcpCreditsExhaustedError({ | ||
| code: -32603, | ||
| message: 'Something failed.', | ||
| data: { | ||
| reason: 'provider_error', | ||
| }, | ||
| }) | ||
| ).toBeNull(); | ||
| }); | ||
| }); |
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,42 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import type { Message } from '../../api'; | ||
| import { messageToAcpPromptContent } from '../prompt'; | ||
|
|
||
| describe('messageToAcpPromptContent', () => { | ||
| it('converts text and image content into ACP prompt blocks', () => { | ||
| const message: Message = { | ||
| id: 'message-1', | ||
| role: 'user', | ||
| created: 123, | ||
| content: [ | ||
| { type: 'text', text: 'Describe this' }, | ||
| { type: 'image', data: 'abc123', mimeType: 'image/png' }, | ||
| ], | ||
| metadata: { userVisible: true, agentVisible: true }, | ||
| }; | ||
|
|
||
| expect(messageToAcpPromptContent(message)).toEqual([ | ||
| { type: 'text', text: 'Describe this' }, | ||
| { type: 'image', data: 'abc123', mimeType: 'image/png' }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('omits empty text content and unsupported content blocks', () => { | ||
| const message: Message = { | ||
| id: 'message-1', | ||
| role: 'user', | ||
| created: 123, | ||
| content: [ | ||
| { type: 'text', text: ' ' }, | ||
| { | ||
| type: 'toolResponse', | ||
| id: 'tool-1', | ||
| toolResult: { status: 'success', value: [] }, | ||
| }, | ||
| ], | ||
| metadata: { userVisible: true, agentVisible: true }, | ||
| } as Message; | ||
|
|
||
| expect(messageToAcpPromptContent(message)).toEqual([]); | ||
| }); | ||
| }); |
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.
In the desktop ACP path, sessions are loaded via the existing
resumeAgentflow and the firstclient.promptcan reach this lazyget_session_agentactivation beforestart_active_runstores thecancel_token. If the user presses Stop while that activation is still loading the agent/extensions,on_cancelhas no token/session run to cancel, so the prompt continues as soon as activation finishes. Register the run or otherwise store the cancellation token before the awaitable activation work.Useful? React with 👍 / 👎.
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.
This is planned to handle in a separate PR