-
Notifications
You must be signed in to change notification settings - Fork 363
fix(desktop): offer safe resume after completed tool timeout #4075
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
Open
liugddx
wants to merge
4
commits into
apache:main
Choose a base branch
from
liugddx:fix/post-tool-timeout-recovery-pr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+119
−4
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
85bcd0a
fix(desktop): offer safe resume after completed tool timeout
liugddx 63b7606
chore: add ASF header to recovery test
liugddx 367aaf5
fix(desktop): gate timeout resume on settled tools
liugddx 1eb6ab0
test(desktop): cover mixed tool timeout recovery
liugddx 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
104 changes: 104 additions & 0 deletions
104
apps/desktop/src/main/__tests__/interrupted-resume.test.ts
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,104 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import assert from 'node:assert/strict'; | ||
| import { describe, it } from 'node:test'; | ||
| import { materializeTurns } from '@maka/ui'; | ||
| import { latestInterruptedResumeTurnId } from '../../renderer/interrupted-resume.js'; | ||
|
|
||
| describe('latest interrupted resume candidate', () => { | ||
| it('recognizes a timeout after a completed tool result', () => { | ||
| assert.equal( | ||
| latestInterruptedResumeTurnId([ | ||
| { | ||
| turnId: 'turn-1', | ||
| status: 'failed', | ||
| errorClass: 'timeout', | ||
| tools: [{ status: 'completed' }], | ||
| }, | ||
| ]), | ||
| 'turn-1', | ||
| ); | ||
| }); | ||
|
|
||
| it('does not offer continuation for an incomplete or errored tool', () => { | ||
| assert.equal( | ||
| latestInterruptedResumeTurnId([ | ||
| { | ||
| turnId: 'turn-1', | ||
| status: 'failed', | ||
| errorClass: 'timeout', | ||
| tools: [{ status: 'running' }], | ||
| }, | ||
| ]), | ||
| undefined, | ||
| ); | ||
| assert.equal( | ||
| latestInterruptedResumeTurnId([ | ||
| { | ||
| turnId: 'turn-1', | ||
| status: 'failed', | ||
| errorClass: 'timeout', | ||
| tools: [{ status: 'completed' }, { status: 'interrupted' }], | ||
| }, | ||
| ]), | ||
| undefined, | ||
| ); | ||
| assert.equal( | ||
| latestInterruptedResumeTurnId([ | ||
| { | ||
| turnId: 'turn-1', | ||
| status: 'failed', | ||
| errorClass: 'timeout', | ||
| tools: [{ status: 'errored' }], | ||
| }, | ||
| ]), | ||
| undefined, | ||
| ); | ||
| }); | ||
|
|
||
| it('rejects the mixed shape produced by materializeTurns', () => { | ||
| const [turn] = materializeTurns([ | ||
| { type: 'user', id: 'user-1', turnId: 'turn-1', ts: 1, text: 'inspect' }, | ||
| { | ||
| type: 'turn_state', | ||
| id: 'state-1', | ||
| turnId: 'turn-1', | ||
| ts: 2, | ||
| status: 'failed', | ||
| errorClass: 'timeout', | ||
| partialOutputRetained: false, | ||
| }, | ||
| { type: 'tool_call', id: 'call-1', turnId: 'turn-1', ts: 3, toolName: 'Read', args: {} }, | ||
| { | ||
| type: 'tool_result', | ||
| id: 'result-1', | ||
| turnId: 'turn-1', | ||
| ts: 4, | ||
| toolUseId: 'call-1', | ||
| isError: false, | ||
| content: { kind: 'text', text: 'ok' }, | ||
| }, | ||
| { type: 'tool_call', id: 'call-2', turnId: 'turn-1', ts: 5, toolName: 'Read', args: {} }, | ||
| ]); | ||
|
|
||
| assert.deepEqual(turn?.tools.map((tool) => tool.status), ['completed', 'interrupted']); | ||
| assert.equal(latestInterruptedResumeTurnId(turn ? [turn] : []), undefined); | ||
| }); | ||
| }); |
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 |
|---|---|---|
|
|
@@ -94,4 +94,5 @@ describe('failed turn execution state', () => { | |
| /部分回答/, | ||
| ); | ||
| }); | ||
|
|
||
| }); | ||
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
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] Do not offer timeout recovery when Safe Resume is disabled
Safe-boundary resume is off by default unless
MAKA_RUNTIME_SAFE_BOUNDARY_RESUME=1is set. I could not find a production Desktop startup path that enables it, but this branch now exposes the action for its normal target case: a timeout after completed tools. Clicking it in the default configuration always parks withresume_feature_disabled.Runtime still fails closed, so this is not a safety problem. It is a UX problem: the button promises a recovery action that cannot run. Could we either hide it when the Runtime capability is disabled, or make enabling the capability part of this rollout?
简体中文
Safe Resume 默认关闭,只有设置
MAKA_RUNTIME_SAFE_BOUNDARY_RESUME=1才能使用,但这里会在默认 Desktop 中为“工具已完成后超时”的情况显示恢复按钮。用户点击后只会得到resume_feature_disabled。Runtime 仍会安全地拒绝执行,所以这不是安全问题,但按钮在默认配置下无法完成它承诺的操作。可以在能力未开启时隐藏按钮,或者把开启该能力纳入这次发布。