Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.akka</groupId>
<artifactId>akka-javasdk-parent</artifactId>
<version>3.5.11</version>
<version>3.5.12</version>
</parent>

<groupId>io.akka.ai</groupId>
Expand Down
19 changes: 15 additions & 4 deletions src/main/java/demo/multiagent/application/ActivityView.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import akka.javasdk.view.TableUpdater;
import akka.javasdk.view.View;
import java.util.List;
import java.util.Optional;

@Component(id = "activity-view")
public class ActivityView extends View {
Expand Down Expand Up @@ -34,10 +35,20 @@ public static class Updater extends TableUpdater<ActivityEntry> {

public Effect<ActivityEntry> onStateChange(AgentTeamWorkflow.State state) {
var sessionId = updateContext().eventSubject().get(); // the workflow id
return effects()
.updateRow(
new ActivityEntry(state.userId(), sessionId, state.userQuery(), state.finalAnswer())
);
var currentAnswer = rowState() == null ? "" : rowState().finalAnswer;
if (currentAnswer.equals(state.finalAnswer())) { // avoid updating the state if no relevant changes
return effects().ignore();
} else {
return effects()
.updateRow(
new ActivityEntry(
state.userId(),
sessionId,
state.userQuery(),
state.finalAnswer()
)
);
}
}

@DeleteHandler
Expand Down
Loading