refactor(ActionExecutor): update type of history field in ActionData

This commit is contained in:
2026-01-28 21:16:51 +08:00
parent cd641ac8dd
commit dce8825e58
2 changed files with 12 additions and 4 deletions

View File

@@ -1,9 +1,9 @@
package work.slhaf.partner.core.action.entity; package work.slhaf.partner.core.action.entity;
import cn.hutool.json.JSONObject;
import lombok.Data; import lombok.Data;
import work.slhaf.partner.module.modules.action.dispatcher.executor.entity.HistoryAction;
import java.util.ArrayList; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -37,7 +37,7 @@ public abstract class ActionData {
* 行动结果 * 行动结果
*/ */
protected String result; protected String result;
protected List<JSONObject> history = new ArrayList<>(); protected Map<Integer, List<HistoryAction>> history = new HashMap<>();
/** /**
* 修复上下文 * 修复上下文
*/ */

View File

@@ -112,6 +112,7 @@ public class ActionExecutor extends AgentRunningSubModule<ActionExecutorInput, V
private Runnable buildMataActionTask(MetaAction metaAction, PhaserRecord phaserRecord, String userId) { private Runnable buildMataActionTask(MetaAction metaAction, PhaserRecord phaserRecord, String userId) {
return () -> { return () -> {
val actionKey = metaAction.getKey();
try { try {
val result = metaAction.getResult(); val result = metaAction.getResult();
do { do {
@@ -124,6 +125,13 @@ public class ActionExecutor extends AgentRunningSubModule<ActionExecutorInput, V
if (extractorResult.isOk()) { if (extractorResult.isOk()) {
metaAction.setParams(extractorResult.getParams()); metaAction.setParams(extractorResult.getParams());
runnerClient.submit(metaAction); runnerClient.submit(metaAction);
val historyAction = new HistoryAction();
historyAction.setActionKey(actionKey);
historyAction.setDescription(actionCapability.loadMetaActionInfo(actionKey).getDescription());
historyAction.setResult(metaAction.getResult().getData());
actionData.getHistory()
.computeIfAbsent(actionData.getExecutingStage(), integer -> new ArrayList<>())
.add(historyAction);
} else { } else {
val repairerInput = assemblyHelper.buildRepairerInput(historyActionResults, metaAction, userId); val repairerInput = assemblyHelper.buildRepairerInput(historyActionResults, metaAction, userId);
val repairerResult = actionRepairer.execute(repairerInput); val repairerResult = actionRepairer.execute(repairerInput);
@@ -150,7 +158,7 @@ public class ActionExecutor extends AgentRunningSubModule<ActionExecutorInput, V
// 内部的行动池已经足以承担这个功能,但这也就意味着行动池或许需要考虑特殊的序列化形式避免内存占用过高, // 内部的行动池已经足以承担这个功能,但这也就意味着行动池或许需要考虑特殊的序列化形式避免内存占用过高,
// 同时也需要在某些模块执行时加上行动结果的挑取作为输入内容 // 同时也需要在某些模块执行时加上行动结果的挑取作为输入内容
} catch (Exception e) { } catch (Exception e) {
log.error("Action executing failed: {}", metaAction.getKey(), e); log.error("Action executing failed: {}", actionKey, e);
} finally { } finally {
phaserRecord.phaser().arriveAndDeregister(); phaserRecord.phaser().arriveAndDeregister();
} }