feat: 支持 agent 运行取消功能
This commit is contained in:
@@ -206,6 +206,28 @@ void main() {
|
||||
expect(bloc.state.error, 'runtime execution failed');
|
||||
});
|
||||
|
||||
test('run canceled error clears error and marks tool as canceled', () {
|
||||
service.emitEvent(
|
||||
ToolCallStartEvent(
|
||||
toolCallId: 'tool-cancel',
|
||||
toolCallName: 'ocr_image',
|
||||
),
|
||||
);
|
||||
service.emitEvent(ToolCallEndEvent(toolCallId: 'tool-cancel'));
|
||||
|
||||
service.emitEvent(
|
||||
RunErrorEvent(message: 'run canceled by user', code: 'RUN_CANCELED'),
|
||||
);
|
||||
|
||||
final toolItem = bloc.state.items.whereType<ToolCallItem>().single;
|
||||
expect(toolItem.status, ToolCallStatus.error);
|
||||
expect(toolItem.errorMessage, '本次运行已取消');
|
||||
expect(bloc.state.error, isNull);
|
||||
expect(bloc.state.isWaitingFirstToken, isFalse);
|
||||
expect(bloc.state.isStreaming, isFalse);
|
||||
expect(bloc.state.isCancelling, isFalse);
|
||||
});
|
||||
|
||||
test('text event with ui schema is rendered into chat items', () {
|
||||
service.emitEvent(RunStartedEvent(threadId: 'thread-1', runId: 'run-1'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user