Skip to content

fix(ai-prompt): preserve all original messages in decorateBody#6343

Open
eye-gu wants to merge 3 commits into
apache:masterfrom
eye-gu:fix-6342
Open

fix(ai-prompt): preserve all original messages in decorateBody#6343
eye-gu wants to merge 3 commits into
apache:masterfrom
eye-gu:fix-6342

Conversation

@eye-gu
Copy link
Copy Markdown
Contributor

@eye-gu eye-gu commented May 15, 2026

close #6342

AiPromptPlugin#decorateBody used messages.get(0) which only kept the first message, silently dropping all remaining conversation history (multi-turn dialogue messages).

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

moremind
moremind previously approved these changes May 16, 2026
@moremind moremind added this to the 2.7.1 milestone May 16, 2026
@moremind moremind added the AI label May 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes AiPromptPlugin#decorateBody so it preserves the full incoming messages array (multi-turn conversation history) instead of only keeping the first entry, aligning behavior with expected AI chat request semantics (issue #6342).

Changes:

  • Update decorateBody to append all original messages via decoratedMessages.addAll(messages).
  • Add unit tests covering decoration behavior (no messages, empty messages, prepend/append, multi-message preservation, and preservation of other JSON fields).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-prompt/src/main/java/org/apache/shenyu/plugin/ai/prompt/AiPromptPlugin.java Fixes message decoration to preserve all original conversation messages.
shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-prompt/src/test/java/org/apache/shenyu/plugin/ai/prompt/AiPromptPluginTest.java Adds coverage to validate correct body decoration and multi-message preservation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

[BUG] AiPromptPlugin decorateBody drops all messages except the first one

3 participants