Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/prerna/reactor/agent/AgentRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ private static AgentHarnessResult run(String roomId, String input, String engine
AgentConfig agentConfig = AgentConfigLoader.load(room, filePath, modelId, params, agentParams, maxTurns,
maxReflections, explicitWorkspaceId);

// List a room this run starts under its workspace, as CreateRoom does.
if (!resumeMode) {
persistWorkspaceOnEmptyRoom(room, insight, explicitWorkspaceId);
}

try {
if (target.isInsight() && CollaborationUtils.isCollaborationRoom(room)
&& agentConfig.getSkills().stream().noneMatch(ref -> ref != null
Expand Down Expand Up @@ -418,6 +423,33 @@ private static final class WorkspaceOverlay {
}
}

/**
* Sets {@code ROOM.WORKSPACE_ID} on a room with no messages yet so it shows in
* GetWorkspaceRooms, matching {@code CreateRoom(workspaceId)}. Options are not
* touched, so later runs can pick another agent or none. Skipped when the
* workspace is missing, disabled, or not viewable by the user.
*/
private static void persistWorkspaceOnEmptyRoom(Room room, Insight insight, String workspaceId) {
if (workspaceId == null || workspaceId.trim().isEmpty()) {
return;
}
List<?> messages = room.getMessages();
if (messages != null && !messages.isEmpty()) {
return;
}
try {
Map<String, Object> ws = ModelInferenceLogsUtils.getWorkspaceEntry(workspaceId);
if (ws == null || !Boolean.TRUE.equals(ws.get("is_active")) || insight.getUser() == null
|| !SecurityProjectUtils.userCanViewProject(insight.getUser(), workspaceId)) {
return;
}
ModelInferenceLogsUtils.setRoomWorkspaceId(room.getId(), room.getUserId(), workspaceId);
} catch (Exception e) {
logger.warn("AgentRunner: could not set workspace '{}' on room '{}': {}", workspaceId, room.getId(),
e.getMessage(), e);
}
}

/**
* Applies an in-memory workspace override for one run when needed.
*/
Expand Down
Loading