feat(agent): move mobile ask to unified agent

This commit is contained in:
2026-07-24 22:36:14 +08:00
parent 6ba4e06a2f
commit 5b7c5613f5
12 changed files with 368 additions and 62 deletions
@@ -38,7 +38,7 @@ public class AihrAgentActionService {
index.set(draftId, DRAFT_TTL);
}
redissonClient.<Long>getBucket(PREFIX + "draft:" + draftId).set(candidate.id(), DRAFT_TTL);
return new ActionDraft(draftId, candidate.targetDomain(), candidate.version(), candidate.draft());
return new ActionDraft(draftId, candidate.targetDomain(), candidate.version(), candidate);
}
public ConfirmMemoryResponse confirm(String draftId, ConfirmMemoryRequest request) {
@@ -134,13 +134,19 @@ public class AihrAgentOrchestrator {
: AgentStatus.NEEDS_INPUT;
sourceType = "MEMORY_DRAFT";
}
String sourceLabel = response.citations().isEmpty() ? sourceType
: response.citations().get(0).title();
List<SourceSummary> sources = response.citations().isEmpty()
&& "ENTERPRISE_KNOWLEDGE".equals(sourceType)
? List.of()
: List.of(new SourceSummary(
sourceType,
response.citations().isEmpty() ? sourceType : response.citations().get(0).title(),
OffsetDateTime.now().toString()
));
String answer = actionDraft == null ? response.answer()
: "已整理为待确认记录,请核对后保存。";
return new AgentResponse(
runId(), response.conversationId(), response.contextVersion(), plan.intent(), status, answer,
List.of(new SourceSummary(sourceType, sourceLabel, OffsetDateTime.now().toString())),
sources,
response.citations(), response.resources(), response.data(), actionDraft, null, List.of()
);
}
@@ -52,6 +52,14 @@ public class AihrAgentPlanner {
return plan(Intent.RESOURCE_DELIVERY, request, Tool.KNOWLEDGE_RESOURCE, false, false,
ResponseStyle.GROUNDED);
}
if (containsAny(request, "团队训练概况", "团队训练情况", "团队完训情况")) {
return plan(Intent.LIVE_TEAM_WORK, request, Tool.TEAM_PRACTICE_SUMMARY, false, false,
ResponseStyle.FACT);
}
if (containsAny(request, "我的训练概况", "我的训练情况", "我的练习概况", "我练得怎么样")) {
return plan(Intent.PRACTICE_COACHING, request, Tool.MY_PRACTICE_SUMMARY, false, false,
ResponseStyle.FACT);
}
if (containsAny(request, "我今天有什么待办", "我有什么待办", "我的待办", "我的任务",
"我今天该做什么", "我现在该做什么", "今天要做什么", "当前待办")) {
return plan(Intent.LIVE_MY_WORK, request, Tool.MY_CURRENT_TASKS, false, false, ResponseStyle.FACT);
@@ -38,6 +38,7 @@ class AihrAgentActionServiceTest {
var result = service.confirm(draft.draftId(), request);
assertEquals(candidate, draft.payload());
assertEquals("ASSISTANT_CAPTURE", result.targetDomain());
assertEquals(88L, result.targetId());
verify(memory).confirm(7L, request);
@@ -21,6 +21,7 @@ import static org.dromara.aihr.agent.AihrAgentDto.Intent.KNOWLEDGE_QA;
import static org.dromara.aihr.agent.AihrAgentDto.Intent.LIVE_MY_WORK;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("dev")
class AihrAgentOrchestratorTest {
@@ -52,6 +53,16 @@ class AihrAgentOrchestratorTest {
assertEquals(AgentStatus.COMPLETED, result.status());
}
@Test
void knowledgeNoEvidenceDoesNotInventASource() {
var query = new CapturingQueryService(response("当前授权资料中没有明确依据。", null, true));
var result = orchestrator(query).handle(request("装修人员怎么进场?"));
assertEquals(AgentStatus.NO_EVIDENCE, result.status());
assertTrue(result.sourceSummary().isEmpty());
}
@Test
void socialAndClarificationDoNotInvokeKnowledge() {
var query = new CapturingQueryService(response("unused", null, false));
@@ -11,7 +11,9 @@ import static org.dromara.aihr.agent.AihrAgentDto.Intent.CAPTURE_FACT;
import static org.dromara.aihr.agent.AihrAgentDto.Intent.CLARIFY;
import static org.dromara.aihr.agent.AihrAgentDto.Intent.KNOWLEDGE_QA;
import static org.dromara.aihr.agent.AihrAgentDto.Intent.LIVE_MY_WORK;
import static org.dromara.aihr.agent.AihrAgentDto.Intent.LIVE_TEAM_WORK;
import static org.dromara.aihr.agent.AihrAgentDto.Intent.MEDIA_UNDERSTANDING;
import static org.dromara.aihr.agent.AihrAgentDto.Intent.PRACTICE_COACHING;
import static org.dromara.aihr.agent.AihrAgentDto.Intent.RESOURCE_DELIVERY;
import static org.dromara.aihr.agent.AihrAgentDto.Intent.SOCIAL;
import static org.dromara.aihr.agent.AihrAgentDto.Tool.CAPTURE_MEMORY_DRAFT;
@@ -19,7 +21,9 @@ import static org.dromara.aihr.agent.AihrAgentDto.Tool.KNOWLEDGE_RESOURCE;
import static org.dromara.aihr.agent.AihrAgentDto.Tool.KNOWLEDGE_SEARCH;
import static org.dromara.aihr.agent.AihrAgentDto.Tool.MEDIA_ANALYZE;
import static org.dromara.aihr.agent.AihrAgentDto.Tool.MY_CURRENT_TASKS;
import static org.dromara.aihr.agent.AihrAgentDto.Tool.MY_PRACTICE_SUMMARY;
import static org.dromara.aihr.agent.AihrAgentDto.Tool.NONE;
import static org.dromara.aihr.agent.AihrAgentDto.Tool.TEAM_PRACTICE_SUMMARY;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -38,6 +42,22 @@ class AihrAgentPlannerTest {
assertFalse(plan.requiresConfirmation());
}
@Test
void routesOwnTrainingSummaryToLivePracticeData() {
var plan = planner.plan("查询我的训练概况", false);
assertEquals(PRACTICE_COACHING, plan.intent());
assertEquals(MY_PRACTICE_SUMMARY, plan.tool());
}
@Test
void routesTeamTrainingSummaryToSupervisorData() {
var plan = planner.plan("查询我的团队训练概况", false);
assertEquals(LIVE_TEAM_WORK, plan.intent());
assertEquals(TEAM_PRACTICE_SUMMARY, plan.tool());
}
@Test
void routesExplicitCaptureToConfirmationDraft() {
var plan = planner.plan("记一下,3栋1201要回访", false);