Skip to content

Commit 97c163b

Browse files
committed
commit
1 parent b12b7e6 commit 97c163b

File tree

7 files changed

+27
-10
lines changed

7 files changed

+27
-10
lines changed

ai-agent/src/main/java/io/sentrius/agent/analysis/agents/verbs/AgentVerbs.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import io.sentrius.sso.genai.Response;
4545
import io.sentrius.sso.genai.model.LLMRequest;
4646
import lombok.extern.slf4j.Slf4j;
47-
import org.checkerframework.checker.units.qual.A;
4847
import org.springframework.beans.factory.annotation.Value;
4948
import org.springframework.stereotype.Service;
5049

@@ -189,7 +188,7 @@ public String justifyAgent(AgentExecution execution, ZtatRequestDTO ztatRequest,
189188

190189
if (commsIds.size() > 1) {
191190
// get the first one
192-
throw new RuntimeException("have more than one");
191+
log.info("CommsIds is {}", commsIds);
193192
}
194193

195194

@@ -436,7 +435,7 @@ public List<ZtatAsessment> analyzeAtatRequests(AgentExecution execution, List<At
436435
log.info("We have a question");
437436
// ask a question of the user
438437
String payload = JsonUtil.MAPPER.writeValueAsString(ztat);
439-
var comm = agentClientService.askQuestion(execution,request,payload);
438+
var comm = agentClientService.askAgent(execution,request,payload);
440439
log.info("Question is {}", comm);
441440
var newComms = agentClientService.getResponse(execution,request,comm, 60,
442441
java.util.concurrent.TimeUnit.SECONDS);
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
[
2-
{
1+
{
32
"requestId": "<id>",
43
"justificationToAgent": "<Justification for why your operation should be approved, responding to the question asked by the agent>",
5-
}
6-
]
4+
}

api/src/main/java/io/sentrius/sso/controllers/api/AgentApiController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public ResponseEntity<?> getConnections(
306306
log.info("Received policy request from agent: {} {} {} {}",agent, aid, agentId, operatingUser);
307307

308308
var agents = agentService.getCommunications(operatingUser.getUsername(), start, end, pageable);
309-
return ResponseEntity.ok(agents);
309+
return ResponseEntity.ok(agents.map(AgentCommunication::toDTO));
310310
}
311311

312312
@GetMapping("/policy")

core/src/main/java/io/sentrius/sso/core/services/agents/AgentClientService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,19 @@ public List<AgentCommunicationDTO> getResponse(AgentExecution execution, ZtatReq
140140
return List.of();
141141
}
142142

143-
public AgentCommunicationDTO askQuestion(AgentExecution execution, AtatRequest atatRequest, String payload)
143+
public AgentCommunicationDTO askAgent(AgentExecution execution, AtatRequest atatRequest, String payload)
144144
throws ZtatException, TimeoutException, JsonProcessingException {
145145
// pose a question to the user and then wait for a response a reasonable amount of time.
146146
String ask = "/agent/chat/atat/send";
147147

148+
148149
AgentCommunicationDTO myQuestion = AgentCommunicationDTO.builder()
149150
.payload(payload)
150151
.messageType("atat_chat_ask")
151152
.sourceAgent(execution.getUser().getUsername())
152153
.targetAgent(atatRequest.getUserName())
153154
.build();
155+
log.info("My question is {}",myQuestion);
154156
var acommResponse = zeroTrustClientService.callPostOnApi(execution, ask, myQuestion,
155157
Maps.immutableEntry("requestId", List.of(atatRequest.getRequestId())));
156158
return JsonUtil.MAPPER.readValue(acommResponse, AgentCommunicationDTO.class);

core/src/main/java/io/sentrius/sso/core/services/agents/ZeroTrustClientService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ public void approveZtat(AgentExecution execution, String requestId) throws JsonP
517517

518518
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
519519

520-
if (response.getStatusCode().is2xxSuccessful() && response.getBody() != null) {
520+
if (response.getStatusCode().is2xxSuccessful()) {
521521
log.info("successfully approved ZTAT: {}", requestId);
522522
} else {
523523
throw new RuntimeException("Failed to obtain ZTAT: " + response.getStatusCode());

dataplane/src/main/java/io/sentrius/sso/core/model/chat/AgentCommunication.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import java.util.List;
66
import java.util.UUID;
7+
import com.fasterxml.jackson.annotation.JsonManagedReference;
8+
import io.sentrius.sso.core.dto.AgentCommunicationDTO;
79
import io.sentrius.sso.core.model.zt.RequestCommunicationLink;
810
import jakarta.persistence.Basic;
911
import jakarta.persistence.CascadeType;
@@ -55,5 +57,19 @@ public class AgentCommunication {
5557
private java.time.Instant createdAt = java.time.Instant.now();
5658

5759
@OneToMany(mappedBy = "communication", cascade = CascadeType.ALL, orphanRemoval = true)
60+
@JsonManagedReference // <-- ADD THIS
5861
private List<RequestCommunicationLink> linkedRequests;
62+
63+
public AgentCommunicationDTO toDTO(){
64+
return AgentCommunicationDTO.builder()
65+
.id(this.id)
66+
.sourceAgent(this.sourceAgent)
67+
.targetAgent(this.targetAgent)
68+
.messageType(this.messageType)
69+
.communicationId(this.communicationId)
70+
.payload(this.payload)
71+
.createdAt(this.createdAt)
72+
.linkedRequests(linkedRequests.stream().map(RequestCommunicationLink::getId).toList())
73+
.build();
74+
}
5975
}

dataplane/src/main/java/io/sentrius/sso/core/model/zt/RequestCommunicationLink.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.annotation.JsonBackReference;
44
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.annotation.JsonManagedReference;
56
import io.sentrius.sso.core.model.chat.AgentCommunication;
67
import jakarta.persistence.Column;
78
import jakarta.persistence.Entity;
@@ -49,6 +50,7 @@ public class RequestCommunicationLink {
4950

5051
@ManyToOne(fetch = FetchType.LAZY, optional = false)
5152
@JoinColumn(name = "communication_id", nullable = false)
53+
@JsonManagedReference // <-- ADD THIS
5254
private AgentCommunication communication;
5355

5456
@Column(name = "created_at", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")

0 commit comments

Comments
 (0)