fix: stabilize complex openclaw artifact tasks
This commit is contained in:
parent
c2e675f390
commit
dc6a4103e7
@ -461,9 +461,13 @@ extension AppControllerDesktopThreadActions on AppController {
|
||||
localAttachments,
|
||||
);
|
||||
final taskLoadClass = classifyGatewayTaskLoadInternal(message);
|
||||
final expectedArtifactExtensions =
|
||||
expectedGatewayArtifactExtensionsInternal(message);
|
||||
final taskMetadata = Map<String, dynamic>.unmodifiable(<String, dynamic>{
|
||||
...dispatch.metadata,
|
||||
'taskLoadClass': taskLoadClass,
|
||||
if (expectedArtifactExtensions.isNotEmpty)
|
||||
'expectedArtifactExtensions': expectedArtifactExtensions,
|
||||
});
|
||||
final executionWorkingDirectory = gatewayExecutionWorkingDirectoryInternal(
|
||||
target: currentTarget,
|
||||
@ -764,6 +768,42 @@ extension AppControllerDesktopThreadActions on AppController {
|
||||
return 'short_task';
|
||||
}
|
||||
|
||||
List<String> expectedGatewayArtifactExtensionsInternal(String requestText) {
|
||||
final normalized = requestText.trim().toLowerCase();
|
||||
final result = <String>[];
|
||||
|
||||
void add(String value) {
|
||||
final normalizedValue = value.trim().toLowerCase().replaceFirst(
|
||||
RegExp(r'^\.'),
|
||||
'',
|
||||
);
|
||||
if (normalizedValue.isEmpty || result.contains(normalizedValue)) {
|
||||
return;
|
||||
}
|
||||
result.add(normalizedValue);
|
||||
}
|
||||
|
||||
for (final match in RegExp(
|
||||
r'\.([a-z0-9]{2,5})\b',
|
||||
caseSensitive: false,
|
||||
).allMatches(normalized)) {
|
||||
add(match.group(1) ?? '');
|
||||
}
|
||||
for (final match in RegExp(
|
||||
r'\b([a-z0-9]{2,5})\s*(?:格式|文件|产物|artifact|file|output)',
|
||||
caseSensitive: false,
|
||||
).allMatches(normalized)) {
|
||||
add(match.group(1) ?? '');
|
||||
}
|
||||
for (final match in RegExp(
|
||||
r'(?:输出|导出|生成|制作)\s*([a-z0-9]{2,5})',
|
||||
caseSensitive: false,
|
||||
).allMatches(normalized)) {
|
||||
add(match.group(1) ?? '');
|
||||
}
|
||||
return List<String>.unmodifiable(result);
|
||||
}
|
||||
|
||||
bool usesOpenClawGatewayQueueInternal(
|
||||
AssistantExecutionTarget target,
|
||||
SingleAgentProvider provider,
|
||||
|
||||
@ -2,9 +2,9 @@ name: xworkmate
|
||||
description: "XWorkmate desktop-first AI workspace shell."
|
||||
publish_to: 'none'
|
||||
|
||||
version: 1.1.3+1
|
||||
build-date: 2026-05-28
|
||||
build-id: 82d46f5
|
||||
version: 1.1.4
|
||||
build-date: 2026-05-30
|
||||
build-id: 94405c9
|
||||
|
||||
environment:
|
||||
sdk: ^3.11.0
|
||||
|
||||
@ -1186,6 +1186,31 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'sendChatMessage declares expected artifacts for complex PDF chains',
|
||||
() async {
|
||||
final fakeGoTaskService = _RecordingGoTaskServiceClient();
|
||||
final controller = _connectedGatewayController(fakeGoTaskService);
|
||||
addTearDown(controller.dispose);
|
||||
|
||||
await controller.ensureActiveAssistantThreadInternal();
|
||||
await controller.setAssistantExecutionTarget(
|
||||
AssistantExecutionTarget.gateway,
|
||||
);
|
||||
await controller.sendChatMessage(
|
||||
'围绕\n\n'
|
||||
'从单机权限 → 网络边界 → Web安全 → 云身份 → Zero Trust → AI Agent 身份 → AI模型与知识保护 演进 800-1500字\n'
|
||||
'拆章节 -> 每章调用 Codex -> 每章 GPT images2 生成图 -> 汇总排版 ->\n\n'
|
||||
'最后 输出 PDF文件',
|
||||
);
|
||||
|
||||
expect(fakeGoTaskService.requests, hasLength(1));
|
||||
final request = fakeGoTaskService.requests.single;
|
||||
expect(request.metadata['taskLoadClass'], 'complex_long_chain_task');
|
||||
expect(request.metadata['expectedArtifactExtensions'], <String>['pdf']);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'sendChatMessage classifies simple Gateway prompts as short tasks',
|
||||
() async {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user