mirror of
https://github.com/lotsoftick/openclaw_client.git
synced 2026-08-14 00:48:07 +00:00
Merge pull request #2 from bcude/fix/jsonl-parser-string-content
fix(jsonl): handle string-form message.content to prevent assistant turn coalescing
This commit is contained in:
@@ -201,12 +201,22 @@ export function parseMessagesFromJsonl(jsonlPath: string): OpenClawMessage[] {
|
||||
.map((entry): OpenClawMessage | null => {
|
||||
const message = entry.message!;
|
||||
const { role } = message;
|
||||
// `message.content` may arrive as a bare string (plain user prompts)
|
||||
// or a ContentPart[]. Without the string branch, those user entries
|
||||
// were filtered to empty by the `!text && !thinking && !toolSteps`
|
||||
// guard below, leaving consecutive assistant entries with no user
|
||||
// separator. The reduce at the bottom of this function then
|
||||
// coalesced every assistant turn into one cumulative bubble.
|
||||
// Mirrors the same handling in `readFirstUserMessage` above.
|
||||
const content = Array.isArray(message.content) ? message.content : [];
|
||||
const rawText = content
|
||||
.filter(isTextPart)
|
||||
.map((c) => c.text)
|
||||
.join('\n')
|
||||
.trim();
|
||||
const rawText =
|
||||
typeof message.content === 'string'
|
||||
? message.content.trim()
|
||||
: content
|
||||
.filter(isTextPart)
|
||||
.map((c) => c.text)
|
||||
.join('\n')
|
||||
.trim();
|
||||
const text = role === 'user' ? extractUserText(rawText) : extractAssistantText(rawText);
|
||||
const inlineThinkMatch = rawText.match(
|
||||
/<(?:think|thinking)>([\s\S]*?)<\/(?:think|thinking)>/i
|
||||
|
||||
Reference in New Issue
Block a user