mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-15 11:58:34 +08:00
fix(team): keep task runs in team workspace (#596)
This commit is contained in:
parent
071fff76ab
commit
438d8d26ae
@ -164,8 +164,9 @@ public class TeamDispatchService {
|
|||||||
String childConvId = "team-task-" + IdUtil.fastSimpleUUID();
|
String childConvId = "team-task-" + IdUtil.fastSimpleUUID();
|
||||||
ScheduledFuture<?> heartbeat = null;
|
ScheduledFuture<?> heartbeat = null;
|
||||||
try {
|
try {
|
||||||
|
AgentTeamEntity team = teamService.getTeam(teamId);
|
||||||
conversationService.createChildConversation(childConvId, memberId, "system",
|
conversationService.createChildConversation(childConvId, memberId, "system",
|
||||||
null, task.getLeadConversationId());
|
team == null ? null : team.getWorkspaceId(), task.getLeadConversationId());
|
||||||
taskService.attachConversation(task.getId(), childConvId);
|
taskService.attachConversation(task.getId(), childConvId);
|
||||||
// Track the child run so graph nodes honor requestStop() — without a
|
// Track the child run so graph nodes honor requestStop() — without a
|
||||||
// registered RunState, cancelling the task could never interrupt the
|
// registered RunState, cancelling the task could never interrupt the
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import org.junit.jupiter.api.DisplayName;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import vip.mate.agent.AgentService;
|
import vip.mate.agent.AgentService;
|
||||||
import vip.mate.channel.web.ChatStreamTracker;
|
import vip.mate.channel.web.ChatStreamTracker;
|
||||||
|
import vip.mate.team.model.AgentTeamEntity;
|
||||||
import vip.mate.team.model.TeamTaskEntity;
|
import vip.mate.team.model.TeamTaskEntity;
|
||||||
import vip.mate.team.model.TeamTaskStatus;
|
import vip.mate.team.model.TeamTaskStatus;
|
||||||
import vip.mate.workspace.conversation.ConversationService;
|
import vip.mate.workspace.conversation.ConversationService;
|
||||||
@ -28,6 +29,7 @@ import static org.mockito.Mockito.*;
|
|||||||
class TeamDispatchServiceTest {
|
class TeamDispatchServiceTest {
|
||||||
|
|
||||||
private static final Long TEAM_ID = 10L;
|
private static final Long TEAM_ID = 10L;
|
||||||
|
private static final Long WORKSPACE_ID = 77L;
|
||||||
private static final Long MEMBER_A = 2L;
|
private static final Long MEMBER_A = 2L;
|
||||||
private static final Long MEMBER_B = 3L;
|
private static final Long MEMBER_B = 3L;
|
||||||
|
|
||||||
@ -190,6 +192,33 @@ class TeamDispatchServiceTest {
|
|||||||
verify(conversationService).saveMessage(startsWith("team-task-"), eq("assistant"), eq("all done"));
|
verify(conversationService).saveMessage(startsWith("team-task-"), eq("assistant"), eq("all done"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("member child conversation inherits the team's workspace")
|
||||||
|
void runTaskCreatesChildConversationInTeamWorkspace() {
|
||||||
|
AgentTeamEntity team = new AgentTeamEntity();
|
||||||
|
team.setId(TEAM_ID);
|
||||||
|
team.setWorkspaceId(WORKSPACE_ID);
|
||||||
|
when(teamService.getTeam(TEAM_ID)).thenReturn(team);
|
||||||
|
|
||||||
|
TeamTaskEntity assigned = task(1L, MEMBER_A);
|
||||||
|
assigned.setStatus(TeamTaskStatus.IN_PROGRESS);
|
||||||
|
TeamTaskEntity done = task(1L, MEMBER_A);
|
||||||
|
done.setStatus(TeamTaskStatus.COMPLETED);
|
||||||
|
when(taskService.getTask(1L)).thenReturn(assigned, done, done);
|
||||||
|
when(taskService.completeTask(eq(1L), isNull(), anyString())).thenReturn(List.of());
|
||||||
|
when(agentService.chatWithUsage(eq(MEMBER_A), anyString(), anyString()))
|
||||||
|
.thenReturn(AgentService.ChatResult.contentOnly("all done"));
|
||||||
|
|
||||||
|
service.runTask(TEAM_ID, assigned);
|
||||||
|
|
||||||
|
verify(conversationService).createChildConversation(
|
||||||
|
startsWith("team-task-"),
|
||||||
|
eq(MEMBER_A),
|
||||||
|
eq("system"),
|
||||||
|
eq(WORKSPACE_ID),
|
||||||
|
eq("lead-conv"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("an interrupted run whose task was cancelled produces no failed event")
|
@DisplayName("an interrupted run whose task was cancelled produces no failed event")
|
||||||
void interruptedCancelledRunStaysSilent() {
|
void interruptedCancelledRunStaysSilent() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user