Skip to content

Conversation

@NyxJae
Copy link
Contributor

@NyxJae NyxJae commented May 9, 2025

Related GitHub Issue

Closes: #2706

Description

This PR modifies the getMessageContent function in src/api/providers/human-relay.ts to ensure that <model>...</model> tags are removed from message content.

A new helper function, removeModelTags, has been introduced in src/api/providers/human-relay.ts to handle the stripping of these tags. The getMessageContent function now utilizes this helper to process both string content and text content within arrays of message parts. This change ensures that downstream consumers of the message content receive cleaner text, free of model-specific tags.

Test Procedure

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above). (假设已链接)
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates. (由于函数行为改变,建议创建)
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A (Backend logic change)

Documentation Updates

  • No documentation updates are required.

Additional Notes

None.


Important

getMessageContent in human-relay.ts now removes <model>...</model> tags using the new removeModelTags function for cleaner message content.

  • Behavior:
    • getMessageContent in human-relay.ts now removes <model>...</model> tags from message content.
    • Introduces removeModelTags function to strip model tags from strings.
    • Processes both string content and text content within arrays of message parts.
  • Functions:
    • Adds removeModelTags to handle tag removal.
    • Updates getMessageContent to use removeModelTags for cleaner text output.

This description was created by Ellipsis for db95abee1057943021b419f0b00e315c6f340c55. You can customize this summary. It will automatically update as commits are pushed.

@NyxJae NyxJae requested review from cte and mrubens as code owners May 9, 2025 08:57
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels May 9, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

The filtering on line 109 already ensures only items with type "text" pass through, making the ternary check in the map redundant. Consider simplifying it to simply map item => removeModelTags(item.text).

Suggested change
.map((item) => (item.type === "text" ? removeModelTags(item.text) : ""))
.map((item) => removeModelTags(item.text))

This comment was generated because it violated a code review rule: mrule_aQsEnH8jWdOfHq2Z.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add unit tests covering both removeModelTags and getMessageContent functions. Tests should cover cases with multiple, nested, or absent <model> tags to ensure robust functionality.

This comment was generated because it violated a code review rule: mrule_oAUXVfj5l9XxF01R.

@adamhill
Copy link
Contributor

adamhill commented May 9, 2025

🚀 (pending consideration of the comments)

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 10, 2025
@mrubens
Copy link
Collaborator

mrubens commented May 13, 2025

Any idea why the apiModelId is getting set to a random other model? It seems like the ideal approach would be to unset it for this provider and then only output it in the environment details if it's actually present.

@NyxJae NyxJae closed this May 13, 2025
@NyxJae NyxJae force-pushed the fix-human-relay branch from db95abe to 302dc2d Compare May 13, 2025 03:44
@github-project-automation github-project-automation bot moved this from PR [Pre Approval Review] to Done in Roo Code Roadmap May 13, 2025
@changeset-bot
Copy link

changeset-bot bot commented May 13, 2025

⚠️ No Changeset found

Latest commit: 302dc2d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In human relay mode, the model in every xml prompt is always set to claude-3-7-sonnet-20250219

3 participants