mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 04:00:36 +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
|
|
@ -390,6 +390,16 @@ export async function runNonInteractive(
|
|||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// Ensure message_start / message_stop (and content_block events) are
|
||||
// properly paired even when an error aborts the turn mid-stream.
|
||||
// The call is safe when no message was started (throws → caught) or
|
||||
// when already finalized (idempotent guard inside the adapter).
|
||||
try {
|
||||
adapter.finalizeAssistantMessage();
|
||||
} catch {
|
||||
// Expected when no message was started or already finalized
|
||||
}
|
||||
|
||||
// For JSON and STREAM_JSON modes, compute usage from metrics
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
const metrics = uiTelemetryService.getMetrics();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue