Skip to content

fix: fixing get last N message from session - #511

Merged
aludwiko merged 1 commit into
agent-devfrom
session-history-fix
Jun 4, 2025
Merged

aludwiko merged 1 commit into
agent-devfrom
session-history-fix

Conversation

@aludwiko

@aludwiko aludwiko commented Jun 3, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@aludwiko
aludwiko requested a review from efgpinto June 3, 2025 16:28

@efgpinto efgpinto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but a bit annoying to have so many formatting changes.. maybe we need to adjust the auto-formatting sbt plugin? Otherwise we will just be overriding each other..

List<SessionMessage> messages = currentState().messages();
if (cmd.lastNMessages != null
&& cmd.lastNMessages.isPresent()
&& messages.size() > cmd.lastNMessages.get()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch 👍

Comment on lines -146 to +154
.persist(
new Event.UserMessageAdded(ts, cmd.componentId, cmd.userMessage.text(), cmd.userMessage.tokens(), totalTokensUser),
new Event.AiMessageAdded(ts, cmd.componentId, cmd.aiMessage.text(),cmd.aiMessage.tokens(), totalTokensAi, toolInteractions))
.thenReply(__ -> Done.done());
.persist(
new Event.UserMessageAdded(ts, cmd.componentId, cmd.userMessage.text(), cmd.userMessage.tokens(), totalTokensUser),
new Event.AiMessageAdded(ts, cmd.componentId, cmd.aiMessage.text(), cmd.aiMessage.tokens(), totalTokensAi, toolInteractions))
.thenReply(__ -> Done.done());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might need some formatting tool adjustment.. not sure why javafmtAll is not catching these but we have several places where we actually do double spacing for breaking long lines (see JsonSupport, ModelProvider,etc.).
I prefer as is but I'm fine if we agree on this new rule but probably makes sense to reach a consensus first, otherwise we will just be changing formatting every time one of us touches a file.

Comment on lines +191 to +198
case Event.LimitedWindowSet limitedWindowSet -> currentState().withMaxSize(limitedWindowSet.maxSizeInBytes);
case Event.UserMessageAdded userMsg -> currentState()
.addMessage(new UserMessage(userMsg.message(), userMsg.tokens()))
.withTotalTokenUsage(userMsg.totalTokenUsage());
case Event.AiMessageAdded aiMsg -> currentState()
.addMessage(new AiMessage(aiMsg.message(), aiMsg.tokens(), aiMsg.toolCallInteraction))
.withTotalTokenUsage(aiMsg.totalTokenUsage());
case Event.Deleted __ -> currentState().clear();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a matter of taste here? or just IDE auto-formatting?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoformatting, I think, it is more aggressive after the recent IntelliJ update

@aludwiko
aludwiko merged commit 07a0695 into agent-dev Jun 4, 2025
@aludwiko
aludwiko deleted the session-history-fix branch June 4, 2025 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants