Skip to content

fix(session): compare message positions instead of IDs in SessionPrompt.run#24544

Open
alfredocristofano wants to merge 1 commit intoanomalyco:devfrom
alfredocristofano:contrib/cristofano-session-prompt-fix
Open

fix(session): compare message positions instead of IDs in SessionPrompt.run#24544
alfredocristofano wants to merge 1 commit intoanomalyco:devfrom
alfredocristofano:contrib/cristofano-session-prompt-fix

Conversation

@alfredocristofano
Copy link
Copy Markdown

Issue for this PR

Closes #23490

Type of change

  • Bug fix

What does this PR do?

Replaces lexicographic message ID comparisons with array index comparisons in SessionPrompt.run. Custom message IDs broke loop exit logic because lastUser.id < lastAssistant.id does not reflect actual transcript order.

Changes:

  • Tracks lastUserIndex, lastAssistantIndex, and lastFinishedIndex while scanning messages from the end.
  • Replaces lastUser.id < lastAssistant.id with lastUserIndex < lastAssistantIndex.
  • Replaces the for...of loop that skipped messages via m.info.id <= lastFinished.id with a for loop starting from lastFinishedIndex + 1.

How did you verify your code works?

The logic correctly handles custom message IDs by relying on array positions, which always reflect the actual chronological order.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…pt.run

Replaces lexicographic message ID comparisons with array index
comparisons. Custom message IDs broke loop exit logic because
lastUser.id < lastAssistant.id does not reflect actual transcript
order.

Fixes anomalyco#23490
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #24379: fix(session): use transcript position instead of lexical ID compare in prompt loop

Why it's related: This PR appears to address the same issue - replacing lexical ID comparisons with transcript position/array index comparisons in the SessionPrompt loop logic. Both PRs are fixing the same problem where custom message IDs broke loop exit logic by not reflecting actual transcript order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SessionPrompt.run compares message IDs instead of transcript order/time, which breaks custom messageIDs accepted by the API

1 participant