Skip to content

fix: sanitize agent names for OpenAI messages#2361

Open
DevanshuRawal wants to merge 1 commit into
agentscope-ai:mainfrom
DevanshuRawal:fix-agent-name-space-2345
Open

fix: sanitize agent names for OpenAI messages#2361
DevanshuRawal wants to merge 1 commit into
agentscope-ai:mainfrom
DevanshuRawal:fix-agent-name-space-2345

Conversation

@DevanshuRawal

Copy link
Copy Markdown

AgentScope-Java Version

2.0.1-SNAPSHOT

Description

This PR fixes an issue where agent/message names containing spaces or other special characters could be rejected by OpenAI-compatible APIs.

The message name is now sanitized before being assigned to the OpenAI message DTO. Characters other than letters, numbers, underscores, and hyphens are replaced with underscores. This sanitization is applied to both user and assistant messages.

Changes

  • Added sanitizeMessageName helper method.
  • Sanitized message names for user messages.
  • Sanitized message names for assistant messages.

Testing

  • mvn spotless:apply
  • mvn -pl agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-openai -am -DskipTests compile
  • mvn -pl agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-openai -am test ⚠️

The targeted build and compilation pass successfully. The full test command is currently blocked by two existing Windows symlink permission errors in DangerousPathBypassTest (A required privilege is not held by the client).

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test) — 2 Windows symlink permission errors occurred
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (not applicable)
  • Code is ready for review

@CLAassistant

CLAassistant commented Jul 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@oss-maintainer

Copy link
Copy Markdown
Collaborator

CLA Not Signed

The Contributor License Agreement (CLA) check is currently pending on this PR (license/cla: Contributor License Agreement is not signed yet.). This PR cannot be merged until the CLA is signed.

@DevanshuRawal please sign the CLA via the CLA assistant badge in the comment above, or visit https://cla-assistant.io/agentscope-ai/agentscope-java. Once signed, the license/cla status will turn green.


Automated check by github-manager-bot

@DevanshuRawal

Copy link
Copy Markdown
Author

Hi maintainers, just following up on this PR when you get a chance. All CI checks and the CLA check are passing. Thank you for your time and review!

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.

3 participants