Skip to content

History processor replaces message history #2324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AlexEnrique
Copy link

This PR closes #2095

Summary

  • [BREAKING CHANGE]: history_processor's now replaces the message history with its result.
  • Updates docs with warnings about new behavior and issues related to slicing the message history
  • Added tests to test new behavior

Concerns

The new behavior also processes/replaces the current ModelRequest being sent to the LLM. This may lead to unexpected behaviors for users of the library, for example, the following history_processor must prepend the messages[-1:] in order to not remove the model request being sent.

def process_previous_answers(messages: list[ModelMessage]) -> list[ModelMessage]:
        # Keep the last message (last question) and add a new system prompt
        return messages[-1:] + [ModelRequest(parts=[SystemPromptPart(content='Processed answer')])]

Although this may be unexpected, changing it to keep the last model request as is may also be a surprise for users. This was in conflict with exiting tests and I though it would be better to keep in this way and let the library user handle this.

I've added a warning to the docs, but maybe I need to emphasize this more.

c.c: @Kludex

Copy link
Contributor

hyperlint-ai bot commented Jul 26, 2025

PR Change Summary

Updated the message history processing behavior in the library, introducing breaking changes and enhanced documentation to address potential user concerns.

  • Replaced message history with results from the history processor, introducing a breaking change.
  • Updated documentation with warnings about new behavior and issues related to message history slicing.
  • Added tests to validate the new message history processing behavior.

Modified Files

  • docs/message-history.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

Copy link
Contributor

@Wh1isper Wh1isper left a comment

Choose a reason for hiding this comment

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

LGTM

@DouweM DouweM assigned DouweM and Kludex and unassigned DouweM Jul 28, 2025
@DouweM
Copy link
Contributor

DouweM commented Jul 28, 2025

@AlexEnrique Thanks Alex! The code looks good to me but I'd like for @Kludex to have a look at the concern you mention in the description as he built the feature. He's out this week though, so expect a more careful review of the implications early next week!

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.

Save history_processors's result for next round model request
4 participants