illuma-agents 1.0.77 → 1.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -432,30 +432,11 @@ class StandardGraph extends Graph {
432
432
  }
433
433
  const stream$1 = await model.stream(finalMessages, config);
434
434
  let finalChunk;
435
- let lastChunkMeta;
436
435
  for await (const chunk of stream$1) {
437
436
  await events.safeDispatchCustomEvent(_enum.GraphEvents.CHAT_MODEL_STREAM, { chunk, emitted: true }, config);
438
- // Capture the last chunk's response_metadata before concat merges (and possibly
439
- // loses) the stop reason. Bedrock streams send stopReason only on the final chunk,
440
- // but LangChain's concat can overwrite it with null from earlier chunks.
441
- if (chunk.response_metadata && Object.keys(chunk.response_metadata).length > 0) {
442
- const meta = chunk.response_metadata;
443
- if (meta.stopReason || meta.stop_reason || meta.finish_reason || meta.finishReason) {
444
- lastChunkMeta = meta;
445
- }
446
- }
447
437
  finalChunk = finalChunk ? stream.concat(finalChunk, chunk) : chunk;
448
438
  }
449
439
  finalChunk = core.modifyDeltaProperties(provider, finalChunk);
450
- // Restore the stop reason if concat lost it during streaming merge
451
- if (finalChunk && lastChunkMeta) {
452
- const mergedMeta = (finalChunk.response_metadata ?? {});
453
- const hasStopReason = mergedMeta.stopReason || mergedMeta.stop_reason
454
- || mergedMeta.finish_reason || mergedMeta.finishReason;
455
- if (!hasStopReason) {
456
- finalChunk.response_metadata = { ...mergedMeta, ...lastChunkMeta };
457
- }
458
- }
459
440
  return { messages: [finalChunk] };
460
441
  }
461
442
  else {
@@ -1229,10 +1210,13 @@ If I seem to be missing something we discussed earlier, just give me a quick rem
1229
1210
  const finalMsg = result.messages?.[0];
1230
1211
  if (finalMsg && 'response_metadata' in finalMsg) {
1231
1212
  const meta = finalMsg.response_metadata;
1213
+ // Bedrock streaming nests stopReason inside messageStop: { stopReason: '...' }
1214
+ const messageStop = meta.messageStop;
1232
1215
  this.lastFinishReason =
1233
1216
  meta.finish_reason ?? // OpenAI/Azure
1234
1217
  meta.stop_reason ?? // Anthropic direct API
1235
- meta.stopReason ?? // Bedrock (Anthropic/Amazon)
1218
+ meta.stopReason ?? // Bedrock invoke (non-streaming)
1219
+ messageStop?.stopReason ?? // Bedrock streaming
1236
1220
  meta.finishReason ?? // VertexAI/Google
1237
1221
  undefined;
1238
1222
  }