fix: missing whitespaces for stream-json/json output format via GLM 4.7 model

This commit is contained in:
LaZzyMan 2025-12-29 16:59:09 +08:00
parent e27e9a5f18
commit 61aad5a162
3 changed files with 135 additions and 3 deletions

View file

@ -816,9 +816,18 @@ export abstract class BaseJsonOutputAdapter {
parentToolUseId?: string | null,
): void {
const actualParentToolUseId = parentToolUseId ?? null;
const fragment = [subject?.trim(), description?.trim()]
.filter((value) => value && value.length > 0)
.join(': ');
// Build fragment without trimming to preserve whitespace in streaming content
// Only filter out null/undefined/empty values
const parts: string[] = [];
if (subject && subject.length > 0) {
parts.push(subject);
}
if (description && description.length > 0) {
parts.push(description);
}
const fragment = parts.join(': ');
if (!fragment) {
return;
}