mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-03 06:00:49 +00:00
Fix SDK message event pairing and improve content block handling
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
eea92fc8db
commit
79083ffd50
8 changed files with 545 additions and 102 deletions
|
|
@ -282,12 +282,12 @@ export abstract class BaseJsonOutputAdapter {
|
|||
return;
|
||||
}
|
||||
|
||||
if (lastBlock.type === 'text') {
|
||||
const index = state.blocks.length - 1;
|
||||
this.onBlockClosed(state, index, actualParentToolUseId);
|
||||
this.closeBlock(state, index);
|
||||
} else if (lastBlock.type === 'thinking') {
|
||||
const index = state.blocks.length - 1;
|
||||
const index = state.blocks.length - 1;
|
||||
if (!state.openBlocks.has(index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastBlock.type === 'text' || lastBlock.type === 'thinking') {
|
||||
this.onBlockClosed(state, index, actualParentToolUseId);
|
||||
this.closeBlock(state, index);
|
||||
}
|
||||
|
|
@ -392,7 +392,9 @@ export abstract class BaseJsonOutputAdapter {
|
|||
}
|
||||
|
||||
const message = this.buildMessage(parentToolUseId);
|
||||
this.emitMessageImpl(message);
|
||||
if (state.messageStarted) {
|
||||
this.emitMessageImpl(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
|
|
@ -656,12 +658,7 @@ export abstract class BaseJsonOutputAdapter {
|
|||
parentToolUseId: string,
|
||||
): CLIAssistantMessage {
|
||||
const state = this.getMessageState(parentToolUseId);
|
||||
const message = this.finalizeAssistantMessageInternal(
|
||||
state,
|
||||
parentToolUseId,
|
||||
);
|
||||
this.updateLastAssistantMessage(message);
|
||||
return message;
|
||||
return this.finalizeAssistantMessageInternal(state, parentToolUseId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue