Repository navigation
Commit 885c8b8
authored
fix(langchain): record dict-form assistant messages on workflow and agent spans (#881)
* fix(langchain): record dict-form assistant messages on workflow and agent spans
to_output_messages kept only AIMessage instances, so role/content dicts
and (role, content) tuples returned in a workflow or agent's `messages`
were dropped from gen_ai.output.messages, or an earlier AIMessage was
reported as the final output instead.
Convert entries with convert_to_messages one at a time in a shared
helper used for both inputs and outputs, so a single unconvertible entry
no longer drops the other convertible ones.
Fixes #388
Assisted-by: Claude Opus 5.5
* Add changelog fragment for #881
Assisted-by: Claude Opus 5.5
* fix(langchain): convert messages in one batch before falling back per entry
Try convert_to_messages on the whole list first and only convert entries
one at a time when that fails. In the fallback, BaseMessage instances are
kept as they are instead of going through convert_to_messages again.
Assisted-by: Claude Opus 5.51 parent 0e15925 commit 885c8b8
3 files changed
Lines changed: 101 additions & 26 deletions
File tree
- instrumentation/opentelemetry-instrumentation-genai-langchain
- .changelog
- src/opentelemetry/instrumentation/genai/langchain
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
337 | 338 | | |
338 | 339 | | |
339 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
340 | 361 | | |
341 | | - | |
| 362 | + | |
342 | 363 | | |
343 | 364 | | |
344 | 365 | | |
345 | 366 | | |
346 | 367 | | |
347 | 368 | | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | 369 | | |
358 | | - | |
| 370 | + | |
359 | 371 | | |
360 | 372 | | |
361 | 373 | | |
| |||
370 | 382 | | |
371 | 383 | | |
372 | 384 | | |
373 | | - | |
| 385 | + | |
374 | 386 | | |
375 | 387 | | |
376 | 388 | | |
377 | | - | |
| 389 | + | |
378 | 390 | | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
383 | 394 | | |
384 | 395 | | |
385 | 396 | | |
386 | 397 | | |
387 | 398 | | |
388 | | - | |
| 399 | + | |
389 | 400 | | |
390 | 401 | | |
391 | 402 | | |
| |||
476 | 487 | | |
477 | 488 | | |
478 | 489 | | |
479 | | - | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
480 | 493 | | |
481 | 494 | | |
482 | 495 | | |
| |||
500 | 513 | | |
501 | 514 | | |
502 | 515 | | |
503 | | - | |
| 516 | + | |
504 | 517 | | |
505 | 518 | | |
506 | 519 | | |
| |||
518 | 531 | | |
519 | 532 | | |
520 | 533 | | |
521 | | - | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
522 | 537 | | |
523 | 538 | | |
524 | 539 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
342 | 348 | | |
343 | | - | |
| 349 | + | |
344 | 350 | | |
345 | 351 | | |
346 | 352 | | |
| |||
364 | 370 | | |
365 | 371 | | |
366 | 372 | | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
371 | 377 | | |
372 | 378 | | |
373 | 379 | | |
| |||
1453 | 1459 | | |
1454 | 1460 | | |
1455 | 1461 | | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
1456 | 1475 | | |
1457 | 1476 | | |
1458 | 1477 | | |
| |||
1548 | 1567 | | |
1549 | 1568 | | |
1550 | 1569 | | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
1551 | 1600 | | |
1552 | 1601 | | |
1553 | 1602 | | |
| |||
1626 | 1675 | | |
1627 | 1676 | | |
1628 | 1677 | | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
1629 | 1688 | | |
1630 | 1689 | | |
1631 | 1690 | | |
| |||
0 commit comments