refactor(perceive): return Instant in showLastInteract

This commit is contained in:
2026-03-19 23:16:02 +08:00
parent ccb7041093
commit 3cc6e8df99
3 changed files with 6 additions and 4 deletions

View File

@@ -2,9 +2,11 @@ package work.slhaf.partner.core.perceive;
import work.slhaf.partner.api.agent.factory.capability.annotation.Capability; import work.slhaf.partner.api.agent.factory.capability.annotation.Capability;
import java.time.Instant;
@Capability(value = "perceive") @Capability(value = "perceive")
public interface PerceiveCapability { public interface PerceiveCapability {
String refreshInteract(); String refreshInteract();
long showLastInteract(); Instant showLastInteract();
} }

View File

@@ -37,8 +37,8 @@ public class PerceiveCore extends PartnerCore<PerceiveCore> {
} }
@CapabilityMethod @CapabilityMethod
public long showLastInteract() { public Instant showLastInteract() {
return lastInteractTime.toEpochMilli(); return lastInteractTime;
} }
@Override @Override

View File

@@ -95,7 +95,7 @@ public class MemoryUpdater extends AbstractAgentModule.Running<PartnerRunningFlo
private void tryAutoUpdate() { private void tryAutoUpdate() {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
int chatCount = cognationCapability.snapshotChatMessages().size(); int chatCount = cognationCapability.snapshotChatMessages().size();
if (currentTime - perceiveCapability.showLastInteract() > UPDATE_TRIGGER_INTERVAL && chatCount > 1) { if (currentTime - perceiveCapability.showLastInteract().toEpochMilli() > UPDATE_TRIGGER_INTERVAL && chatCount > 1) {
triggerMemoryUpdate(true); triggerMemoryUpdate(true);
log.info("[MemoryUpdater] 记忆更新: 自动触发"); log.info("[MemoryUpdater] 记忆更新: 自动触发");
} }