[Bug]: agent name contains space resulting gpt model bad request error
Describe the bug
When use ReActAgent or HarnessAgent use GPT Model(Test with gpt-5.4), if Agent name contains space, llm will return error, as the picture belows.
To Reproduce As bug described.
Expected behavior
Error messages As picture describes.
Environment (please complete the following information):
-
AgentScope-Java Version: [e.g. 1.0.12, check your pom.xml dependency version or run
mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)] 1.1.0-RC2 -
Java Version: [e.g. 17]
-
OS: [e.g. macos, windows] windows、macos、linux
Additional context Cause: ReActAgent using agent name as the assistant msg name. ReActAgent:
ReasoningContext context = new ReasoningContext(getName());
return checkInterruptedAsync()
.then(notifyPreReasoningEvent(memory.getMessages()))
.flatMapMany(
event -> {
GenerateOptions options =
event.getEffectiveGenerateOptions() != null
? event.getEffectiveGenerateOptions()
: buildGenerateOptions();
List<Msg> modelInput =
prependSystemMsg(
event.getInputMessages(), event.getSystemMessage());
return model.stream(modelInput, toolkit.getToolSchemas(), options)
.concatMap(chunk -> checkInterruptedAsync().thenReturn(chunk));
})
.doOnNext(
chunk -> {
List<Msg> chunkMsgs = context.processChunk(chunk);
// Notify streaming hooks for each chunk message
for (Msg msg : chunkMsgs) {
notifyReasoningChunk(msg, context).subscribe();
}
})
.then(Mono.defer(() -> Mono.justOrEmpty(context.buildFinalMessage()))) // error cause
ReasoninContext:
public Msg buildFinalMessage() {
List<ContentBlock> blocks = new ArrayList<>();
// Add thinking content if present
if (thinkingAcc.hasContent()) {
blocks.add(thinkingAcc.buildAggregated());
}
// Add text content if present
if (textAcc.hasContent()) {
blocks.add(textAcc.buildAggregated());
}
// Add all tool calls
List<ToolUseBlock> toolCalls = toolCallsAcc.buildAllToolCalls();
blocks.addAll(toolCalls);
// If no content at all, return null
if (blocks.isEmpty()) {
return null;
}
// Build metadata with accumulated ChatUsage
Map<String, Object> metadata = new HashMap<>();
if (inputTokens > 0 || outputTokens > 0 || time > 0) {
ChatUsage chatUsage =
ChatUsage.builder()
.inputTokens(inputTokens)
.outputTokens(outputTokens)
.time(time)
.build();
metadata.put(MessageMetadataKeys.CHAT_USAGE, chatUsage);
}
return Msg.builder()
.id(messageId)
.name(agentName) // error cause
.role(MsgRole.ASSISTANT)
.content(blocks)
.metadata(metadata)
.build();
}
Hi, i would like to work on this issue.
为啥会有四个关联的 PR ??(2361、2352、2347、2346) [捂脸]
为啥会有四个关联的 PR ??(2361、2352、2347、2346) [捂脸]
我这边就是2346,其他的是后面同学提交的吧