AIX: ContentReassembler: verbose post termination issues

This commit is contained in:
Enrico Ros
2026-05-03 22:32:40 -07:00
parent 14be134ef2
commit acdbb2fbaf
@@ -907,6 +907,12 @@ export class ContentReassembler {
* Stores raw termination data from the wire - classification deferred to finalizeReassembly()
*/
private onCGEnd({ terminationReason, tokenStopReason, tokenStopError }: Extract<AixWire_Particles.ChatGenerateOp, { cg: 'end' }>): void {
// Diagnostic: detect late 'end' particles overriding a prior termination (parser bug, replayed wire, or upstream advisory after a clean end).
// Behavior unchanged - we still apply the override - but the warning makes the override visible client-side, mirroring the server-side
// 'setDialectEnded ... (overriding)' warning in ChatGenerateTransmitter and the existing setClientAborted/setClientExcepted warnings here.
if (this.S.terminationReason)
console.warn(`[DEV] [ContentReassembler] onCGEnd: overriding prior termination '${this.S.terminationReason}' with '${terminationReason}' (wire stop: ${this.S.dialectStopReason ?? 'none'} -> ${tokenStopReason ?? 'none'})`);
this.S.terminationReason = terminationReason;
this.S.dialectStopReason = tokenStopReason;
// Vendor-composed stop error, surfaced as a complementary error fragment alongside the generic classification message
@@ -993,6 +999,11 @@ export class ContentReassembler {
}
private onCGIssue({ issueId: _issueId /* Redundant as we add an Error Fragment already */, issueText, issueHint }: Extract<AixWire_Particles.ChatGenerateOp, { cg: 'issue' }> & { issueHint?: DMessageErrorPart['hint'] }): void {
// Diagnostic: detect issue particles arriving after a clean termination (e.g. OpenAI rate-limit advisory after response.completed).
// Behavior unchanged - the issue is still appended - but the warning surfaces that we are mutating a finished message.
if (this.S.terminationReason && this.S.terminationReason === 'done-dialect')
console.warn(`[DEV] [ContentReassembler] onCGIssue: appending issue after clean '${this.S.terminationReason}' (wire stop: ${this.S.dialectStopReason ?? 'none'}): ${issueText}`);
// NOTE: not sure I like the flow at all here
// there seem to be some bad conditions when issues are raised while the active part is not text
if (MERGE_ISSUES_INTO_TEXT_PART_IF_OPEN) {