Adapters
Adapters transform framework-specific traces into a canonical AgentTrace. Usage and
custom schema mapping: Adapters guide.
uaef.adapters.base
Base adapter interface for framework-specific trace transformation.
AdapterTransformationError
Bases: Exception
Exception raised when adapter transformation fails.
This exception should be raised when: - Required fields are missing from the raw data - Data format is invalid or unexpected - Transformation logic encounters an error
Source code in uaef/adapters/base.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
BaseAdapter
Bases: ABC
Abstract base class for framework-specific trace adapters.
All adapters must implement this interface to transform framework-specific traces into the canonical UAEF AgentTrace format. This ensures consistent evaluation across different agent frameworks.
The transformation process should: 1. Extract all messages from the framework-specific trace 2. Extract all tool calls with their arguments and results 3. Extract metadata (tokens, latency, cost) 4. Construct a canonical AgentTrace object 5. Preserve all information from the original trace (no data loss)
Source code in uaef/adapters/base.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
name
abstractmethod
property
Return the name of this adapter.
Returns:
| Type | Description |
|---|---|
str
|
Adapter name (e.g., "langgraph", "bedrock", "langchain") |
extract_messages(raw_data)
abstractmethod
Extract messages from framework-specific trace data.
Messages should be extracted in chronological order and include: - User messages (inputs) - Assistant messages (agent responses) - System messages (if present) - Tool messages (if present)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Framework-specific trace data |
required |
Returns:
| Type | Description |
|---|---|
List[Message]
|
List of Message objects in chronological order |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If message extraction fails |
Source code in uaef/adapters/base.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
extract_metadata(raw_data)
abstractmethod
Extract metadata from framework-specific trace data.
Metadata should include (when available): - input_tokens: Number of input tokens consumed - output_tokens: Number of output tokens generated - latency: Total execution time in seconds - cost: Estimated cost in USD - model: Model name/identifier - framework_version: Version of the framework - Any other framework-specific metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Framework-specific trace data |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary of metadata key-value pairs |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If metadata extraction fails |
Source code in uaef/adapters/base.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
extract_tool_calls(raw_data)
abstractmethod
Extract tool calls from framework-specific trace data.
Tool calls should include: - Tool name - Arguments passed to the tool - Result returned by the tool (if available) - Timestamp of the call - Execution time (if available) - Error information (if the call failed)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Framework-specific trace data |
required |
Returns:
| Type | Description |
|---|---|
List[ToolCall]
|
List of ToolCall objects in chronological order |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If tool call extraction fails |
Source code in uaef/adapters/base.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
supports_session_transform()
Whether transform_to_canonical accepts a list of per-turn payloads
and returns one session dict per conversation.
Multi-turn evaluation needs a whole conversation assembled into
{"session_id", "per_turn_traces", "full_trace"}. Only adapters that
implement that list form can produce it; the rest take a single payload
and know nothing about turns.
Concrete (not abstract) and defaulting to False so existing adapters
keep working untouched and simply opt out. Callers must check this before
handing a list to :meth:transform_to_canonical — passing one to an
adapter that expects a dict fails in whatever way that adapter happens to
fail, which is not a useful error.
Returns:
| Type | Description |
|---|---|
bool
|
True if list/session input is supported, False otherwise. |
Source code in uaef/adapters/base.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
transform_to_canonical(raw_data)
abstractmethod
Transform framework-specific trace data to canonical format.
Returns AgentTrace for single-agent traces, or MultiAgentTrace when multiple agent nodes are detected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Framework-specific trace data as a dictionary |
required |
Returns:
| Type | Description |
|---|---|
Union[AgentTrace, MultiAgentTrace]
|
AgentTrace or MultiAgentTrace |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If transformation fails |
Source code in uaef/adapters/base.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
validate_raw_data(raw_data, required_keys)
Validate that raw data contains required keys.
This is a helper method that adapters can use to validate input data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Framework-specific trace data |
required |
required_keys
|
List[str]
|
List of required keys that must be present |
required |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If any required key is missing |
Source code in uaef/adapters/base.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
uaef.adapters.registry
Adapter registry and factory for managing framework adapters.
AdapterRegistry
Registry for managing framework-specific adapters.
This registry allows: - Registration of built-in adapters - Registration of custom adapters - Retrieval of adapters by framework name - Validation of adapter implementations
Source code in uaef/adapters/registry.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
get_adapter(name, adapter_config=None)
Get an adapter instance by framework name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Framework name (e.g., "langgraph", "bedrock") |
required |
adapter_config
|
Optional[Dict[str, Any]]
|
Optional configuration for adapter initialization |
None
|
Returns:
| Type | Description |
|---|---|
BaseAdapter
|
Adapter instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If adapter is not registered |
Source code in uaef/adapters/registry.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
is_registered(name)
Check if an adapter is registered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Framework name |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if adapter is registered, False otherwise |
Source code in uaef/adapters/registry.py
155 156 157 158 159 160 161 162 163 164 165 | |
list_adapters()
List all registered adapter names.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of adapter names |
Source code in uaef/adapters/registry.py
146 147 148 149 150 151 152 153 | |
register(name, adapter_class, override=False)
Register an adapter class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Framework name (e.g., "langgraph", "bedrock") |
required |
adapter_class
|
Type[BaseAdapter]
|
Adapter class that implements BaseAdapter |
required |
override
|
bool
|
If True, allow overriding existing adapters |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If adapter is already registered and override is False |
TypeError
|
If adapter_class does not implement BaseAdapter |
Source code in uaef/adapters/registry.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
unregister(name)
Unregister an adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Framework name |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If adapter is not registered |
Source code in uaef/adapters/registry.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
get_adapter(name, adapter_config=None)
Get an adapter instance from the global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Framework name (e.g., "langgraph", "bedrock") |
required |
adapter_config
|
Optional[Dict[str, Any]]
|
Optional configuration for adapter initialization |
None
|
Returns:
| Type | Description |
|---|---|
BaseAdapter
|
Adapter instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If adapter is not registered |
Source code in uaef/adapters/registry.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
get_registry()
Get the global adapter registry instance.
Returns:
| Type | Description |
|---|---|
AdapterRegistry
|
Global AdapterRegistry instance |
Source code in uaef/adapters/registry.py
253 254 255 256 257 258 259 260 | |
is_adapter_registered(name)
Check if an adapter is registered in the global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Framework name |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if adapter is registered, False otherwise |
Source code in uaef/adapters/registry.py
240 241 242 243 244 245 246 247 248 249 250 | |
list_adapters()
List all registered adapter names in the global registry.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of adapter names |
Source code in uaef/adapters/registry.py
230 231 232 233 234 235 236 237 | |
register_adapter(name, adapter_class, override=False)
Register an adapter in the global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Framework name (e.g., "langgraph", "bedrock") |
required |
adapter_class
|
Type[BaseAdapter]
|
Adapter class that implements BaseAdapter |
required |
override
|
bool
|
If True, allow overriding existing adapters |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If adapter is already registered and override is False |
TypeError
|
If adapter_class does not implement BaseAdapter |
Source code in uaef/adapters/registry.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
uaef.adapters.langgraph
LangGraph adapter for transforming LangGraph traces to canonical format.
LangGraphAdapter
Bases: BaseAdapter
Adapter for transforming LangGraph stream events to canonical AgentTrace format.
This adapter processes LangGraph execution traces that contain: - Stream events from graph.stream() calls - Messages with tool calls and responses - Token usage metadata - Agent and tool node outputs
The adapter reuses logic from the get_answers_detail_langgraph() function in agenticevaluationframework-main/frontend/evaluation.py.
Source code in uaef/adapters/langgraph.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | |
name
property
Return the adapter name.
extract_messages(raw_data)
Extract messages from LangGraph stream events.
Messages are extracted from agent node outputs in the stream events.
Each agent node output contains a message with content and optional tool calls.
Serialized (dict) messages from an HTTP-served agent are reconstructed
into LangChain message objects via :meth:_coerce_message first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
LangGraph trace data |
required |
Returns:
| Type | Description |
|---|---|
List[Message]
|
List of Message objects |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If message extraction fails |
Source code in uaef/adapters/langgraph.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | |
extract_metadata(raw_data)
Extract metadata from LangGraph stream events.
Metadata includes: - input_tokens: Total input tokens from usage_metadata - output_tokens: Total output tokens from usage_metadata - latency: Execution time (if provided) - model: Model name (if available)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
LangGraph trace data |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary of metadata |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If metadata extraction fails |
Source code in uaef/adapters/langgraph.py
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | |
extract_tool_calls(raw_data)
Extract tool calls from LangGraph stream events.
Tool calls are extracted from: 1. Agent node outputs (tool_calls field) 2. Tool node outputs (tool results)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
LangGraph trace data |
required |
Returns:
| Type | Description |
|---|---|
List[ToolCall]
|
List of ToolCall objects |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If tool call extraction fails |
Source code in uaef/adapters/langgraph.py
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | |
supports_session_transform()
This adapter accepts a list of per-turn payloads (see
:meth:_transform_sessions) and returns one session dict per
conversation, so multi-turn evaluation can use it.
Source code in uaef/adapters/langgraph.py
71 72 73 74 75 | |
transform_to_canonical(raw_data)
Transform LangGraph trace data to canonical format.
Supports two input shapes:
Single-turn (dict) — returns AgentTrace or MultiAgentTrace as before. Expected for single-agent: { "stream_events": [...], "agent_node_name": "agent", # optional; inferred if omitted "tool_node_name": "tools", }
Expected for multi-agent: { "stream_events": [...], "agent_node_names": ["researcher", "writer", "reviewer"], # optional; inferred if omitted "tool_node_name": "tools", "orchestrator_node_name": "orchestrator", # optional }
Multi-turn / multi-session (list) — returns a list of session dicts.
Input is a flat list of per-turn payloads. Turns are grouped by
session_id (preserving first-seen order) and sorted within each
session by turn_id. Each unique session_id produces one session
dict in the output.
Per-turn payload schema: [ { "session_id": "...", # required, used to group turns "turn_id": 1, # required, used to order turns within a session "stream_events": [...], # required, raw LangGraph events for this turn "latency": 1.23, # optional, per-turn latency in seconds "input_tokens": 100, # optional, per-turn input tokens "output_tokens": 200, # optional, per-turn output tokens "cost_usd": 0.0015, # optional, per-turn cost in USD }, ... ]
Returns a list with one entry per unique session_id: [ { "session_id": "session_a", "per_turn_traces": [AgentTrace, AgentTrace, ...], # one per turn in this session "full_trace": AgentTrace, # concatenated across all turns }, { "session_id": "session_b", "per_turn_traces": [AgentTrace], # single-turn session is a list of 1 "full_trace": AgentTrace, }, ... ]
Mixed-cardinality batches (some sessions with one turn, others with many) are handled uniformly — single-turn sessions just produce a per_turn_traces list of length 1.
Multi-agent runs follow the same shape: if a session's events involve
more than one agent node, both per_turn_traces entries and
full_trace come back as MultiAgentTrace instead of AgentTrace,
which lets multi-agent metrics score on top of multi-turn metrics.
Mixing single-agent and multi-agent turns within the same session
raises an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Union[Dict[str, Any], List[Dict[str, Any]]]
|
LangGraph trace data (dict for single-turn, list for multi-turn / multi-session) |
required |
Returns:
| Type | Description |
|---|---|
Union[AgentTrace, MultiAgentTrace, Dict[str, Any]]
|
AgentTrace or MultiAgentTrace for dict input, or list of session |
Union[AgentTrace, MultiAgentTrace, Dict[str, Any]]
|
dicts for list input. |
Source code in uaef/adapters/langgraph.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
uaef.adapters.langchain
LangChain adapter for transforming LangChain traces to canonical format.
LangChainAdapter
Bases: BaseAdapter
Adapter for transforming LangChain callback data to canonical AgentTrace format.
This adapter processes LangChain execution traces that contain: - Callback handler data from LangChain runs - Messages from chat models and agents - Tool invocations and results - Token usage metadata - Run information and metadata
LangChain provides callback handlers that capture execution details. This adapter transforms that data into the canonical UAEF format.
Source code in uaef/adapters/langchain.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | |
name
property
Return the adapter name.
extract_messages(raw_data)
Extract messages from LangChain callback data.
Messages can come from: 1. Direct "messages" field (list of message objects) 2. "runs" field containing run data with inputs/outputs 3. "inputs" and "outputs" fields in a single run
LangChain messages may have different formats: - HumanMessage, AIMessage, SystemMessage, ToolMessage - Dict with "role" and "content" keys - String content with role inferred from context
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
LangChain trace data |
required |
Returns:
| Type | Description |
|---|---|
List[Message]
|
List of Message objects |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If message extraction fails |
Source code in uaef/adapters/langchain.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
extract_metadata(raw_data)
Extract metadata from LangChain callback data.
Metadata includes: - input_tokens: Total input tokens from llm_output - output_tokens: Total output tokens from llm_output - latency: Execution time (if provided) - model: Model name (if available) - run_id: LangChain run identifier
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
LangChain trace data |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary of metadata |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If metadata extraction fails |
Source code in uaef/adapters/langchain.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | |
extract_tool_calls(raw_data)
Extract tool calls from LangChain callback data.
Tool calls can come from: 1. "actions" field in agent execution 2. "tool_calls" in messages 3. "intermediate_steps" in agent runs
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
LangChain trace data |
required |
Returns:
| Type | Description |
|---|---|
List[ToolCall]
|
List of ToolCall objects |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If tool call extraction fails |
Source code in uaef/adapters/langchain.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |
transform_to_canonical(raw_data)
Transform LangChain trace data to canonical AgentTrace format.
Expected raw_data structure: { "runs": [...], # List of run data from callback handlers "messages": [...], # Optional: Direct message list "session_id": "...", # Optional session identifier "trace_id": "...", # Optional trace identifier (UUID string) "metadata": {...}, # Optional additional metadata }
Alternative structure (single run): { "run_id": "...", "inputs": {...}, "outputs": {...}, "actions": [...], # Tool calls/actions "llm_output": {...}, # LLM response with token usage "messages": [...], # Chat messages "metadata": {...}, }
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
LangChain trace data |
required |
Returns:
| Type | Description |
|---|---|
AgentTrace
|
Canonical AgentTrace object |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If transformation fails |
Source code in uaef/adapters/langchain.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
uaef.adapters.bedrock
Bedrock Agent adapter for transforming Bedrock Agent traces to canonical format.
BedrockAgentAdapter
Bases: BaseAdapter
Adapter for transforming Bedrock Agent invoke_agent responses to canonical AgentTrace format.
This adapter processes Bedrock Agent execution traces that contain: - Event stream from invoke_agent response - Chunk events with response text - Trace events with orchestration information - Tool invocation details - Token usage metadata
The adapter reuses logic from the get_answers_detail_bedrock() function in agenticevaluationframework-main/frontend/evaluation.py.
Source code in uaef/adapters/bedrock.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
name
property
Return the adapter name.
extract_messages(raw_data)
Extract messages from Bedrock Agent event stream.
Messages are extracted from: 1. User input (if provided) 2. Chunk events containing response text
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Bedrock Agent response data |
required |
Returns:
| Type | Description |
|---|---|
List[Message]
|
List of Message objects |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If message extraction fails |
Source code in uaef/adapters/bedrock.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
extract_metadata(raw_data)
Extract metadata from Bedrock Agent trace events.
Metadata includes: - input_tokens: Total input tokens from modelInvocationOutput - output_tokens: Total output tokens from modelInvocationOutput - latency: Execution time (if provided) - agent_id: Bedrock agent ID - alias_id: Agent alias ID
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Bedrock Agent response data |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary of metadata |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If metadata extraction fails |
Source code in uaef/adapters/bedrock.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
extract_tool_calls(raw_data)
Extract tool calls from Bedrock Agent trace events.
Tool calls are extracted from orchestrationTrace events that contain invocationInput with actionGroupInvocationInput information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Bedrock Agent response data |
required |
Returns:
| Type | Description |
|---|---|
List[ToolCall]
|
List of ToolCall objects |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If tool call extraction fails |
Source code in uaef/adapters/bedrock.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
transform_to_canonical(raw_data)
Transform Bedrock Agent response data to canonical AgentTrace format.
Expected raw_data structure: { "event_stream": [...], # List of events from invoke_agent response "user_input": "...", # Original user input "session_id": "...", # Session identifier "trace_id": "...", # Optional trace identifier (UUID string) "agent_id": "...", # Bedrock agent ID "alias_id": "...", # Agent alias ID }
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Bedrock Agent response data |
required |
Returns:
| Type | Description |
|---|---|
AgentTrace
|
Canonical AgentTrace object |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If transformation fails |
Source code in uaef/adapters/bedrock.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
uaef.adapters.langfuse
Langfuse adapter for transforming Langfuse traces to canonical format.
LangfuseAdapter
Bases: BaseAdapter
Adapter for transforming Langfuse observation data to canonical AgentTrace format.
This adapter processes Langfuse traces that contain: - Hierarchical observation trees (spans, generations, events) - Messages from LLM generations - Tool calls from function/tool observations - Token usage and cost metadata from generations - Latency information from span durations
Langfuse uses a hierarchical structure where: - Trace: Top-level container for a single execution - Observations: Individual steps within a trace (spans, generations, events) - Spans: Units of work with duration - Generations: LLM calls with token counts and I/O - Events: Point-in-time occurrences
The adapter transforms this hierarchical structure into the flat canonical format.
Source code in uaef/adapters/langfuse.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 | |
name
property
Return the adapter name.
extract_messages(raw_data)
Extract messages from Langfuse observations.
Messages are extracted from: 1. Generation observations (LLM calls with input/output) 2. Trace-level input/output 3. Span observations with message content
Langfuse generations typically contain: - input: The prompt or messages sent to the LLM - output: The LLM's response
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Langfuse trace data |
required |
Returns:
| Type | Description |
|---|---|
List[Message]
|
List of Message objects in chronological order |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If message extraction fails |
Source code in uaef/adapters/langfuse.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
extract_metadata(raw_data)
Extract metadata from Langfuse observations.
Metadata includes: - input_tokens: Total input tokens from generation usage - output_tokens: Total output tokens from generation usage - latency: Total execution time from span durations - cost: Total cost from generation cost data - model: Model name from generations
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Langfuse trace data |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary of metadata |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If metadata extraction fails |
Source code in uaef/adapters/langfuse.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | |
extract_tool_calls(raw_data)
Extract tool calls from Langfuse observations.
Tool calls are extracted from: 1. Span observations with type "tool" or name containing "tool" 2. Event observations representing function calls 3. Generation observations with function_call metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Langfuse trace data |
required |
Returns:
| Type | Description |
|---|---|
List[ToolCall]
|
List of ToolCall objects in chronological order |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If tool call extraction fails |
Source code in uaef/adapters/langfuse.py
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |
transform_to_canonical(raw_data)
Transform Langfuse trace data to canonical AgentTrace format.
Expected raw_data structure: { "trace_id": "...", # Langfuse trace ID "session_id": "...", # Optional session identifier "observations": [...], # List of observation objects (spans, generations, events) "input": {...}, # Optional trace-level input "output": {...}, # Optional trace-level output "metadata": {...}, # Optional trace metadata "timestamp": "...", # ISO 8601 timestamp }
Alternative structure (from Observations API): { "data": [ { "id": "...", "trace_id": "...", "type": "generation|span|event", "name": "...", "input": {...}, "output": {...}, "metadata": {...}, "usage": {"input": 100, "output": 50, "total": 150}, "cost": 0.0025, "start_time": "...", "end_time": "...", "parent_observation_id": "...", }, ... ] }
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Langfuse trace data |
required |
Returns:
| Type | Description |
|---|---|
AgentTrace
|
Canonical AgentTrace object |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If transformation fails |
Source code in uaef/adapters/langfuse.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
uaef.adapters.strands
Strands Agents adapter for transforming Strands traces to canonical format.
Uses native Strands telemetry (EventLoopMetrics, AgentResult) rather than requiring manual cycle construction. Supports both single-agent and multi-agent traces.
StrandsAdapter
Bases: BaseAdapter
Adapter for transforming Strands Agents SDK traces to canonical AgentTrace format.
This adapter consumes the native telemetry objects produced by the Strands SDK:
- AgentResult.messages — the full conversation history
- AgentResult.metrics — an EventLoopMetrics instance with traces,
accumulated token usage, tool metrics, and per-cycle breakdowns
Expected raw_data for single-agent::
{
"messages": [...], # AgentResult.messages (list of message dicts)
"metrics_summary": {...}, # EventLoopMetrics.get_summary()
"stop_reason": "end_turn", # AgentResult.stop_reason (optional)
"session_id": "...", # Optional session identifier
"trace_id": "...", # Optional trace identifier (UUID string)
"model": "...", # Optional model identifier
"cost": 0.005, # Optional estimated cost in USD
}
Expected raw_data for multi-agent::
{
"agents": {
"research_agent": {
"messages": [...],
"metrics_summary": {...},
"stop_reason": "end_turn",
},
"responder_agent": {
"messages": [...],
"metrics_summary": {...},
"stop_reason": "end_turn",
},
},
"coordination_events": [...], # Optional; inferred from agent ordering
"session_id": "...",
"trace_id": "...",
}
Source code in uaef/adapters/strands.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | |
name
property
Return the adapter name.
extract_messages(raw_data)
Extract messages from the Strands conversation history.
Walks raw_data["messages"] (the native list stored on
AgentResult.messages). Each dict has role and content
(a list of content blocks).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Strands trace data. |
required |
Returns:
| Type | Description |
|---|---|
List[Message]
|
List of canonical Message objects. |
Source code in uaef/adapters/strands.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
extract_metadata(raw_data)
Extract metadata from the Strands metrics summary.
Reads accumulated_usage and accumulated_metrics from the
metrics_summary dict produced by EventLoopMetrics.get_summary().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Strands trace data. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary of metadata. |
Source code in uaef/adapters/strands.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
extract_tool_calls(raw_data)
Extract tool calls from the Strands conversation and metrics.
Tool invocations are found in two places:
1. toolUse content blocks inside assistant messages
2. tool_usage in metrics_summary for execution stats
The method walks the messages for call details and enriches them with duration/success info from the metrics summary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Strands trace data. |
required |
Returns:
| Type | Description |
|---|---|
List[ToolCall]
|
List of ToolCall objects. |
Source code in uaef/adapters/strands.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | |
transform_to_canonical(raw_data)
Transform Strands trace data to canonical format.
Returns MultiAgentTrace when raw_data contains an agents
dict with more than one entry. Otherwise returns a single
AgentTrace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Strands trace data. |
required |
Returns:
| Type | Description |
|---|---|
Union[AgentTrace, MultiAgentTrace]
|
AgentTrace for single-agent, MultiAgentTrace for multi-agent. |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If transformation fails. |
Source code in uaef/adapters/strands.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
uaef.adapters.agentcore
AgentCore adapter for transforming AgentCore traces to canonical format.
Supports two modes:
1. Pre-collected traces — pass raw_data with trace, final_response, etc.
2. Live invocation — use the invoke() helper to call an AgentCore-deployed
agent via bedrock-agentcore:invoke_agent_runtime and automatically
collect the streaming response.
Multi-agent auto-detection
When raw_data contains an "agents" key mapping agent names to their
individual response dicts, transform_to_canonical() automatically returns
a MultiAgentTrace with per-agent traces and inferred coordination events.
This mirrors the LangGraph adapter's auto-detect pattern.
AgentCoreAdapter
Bases: BaseAdapter
Adapter for transforming AgentCore invoke_agent_runtime responses to
canonical AgentTrace format.
AgentCore agents are identified by their runtime ARN (or runtime ID +
account ID). The adapter calls the bedrock-agentcore service client,
not the legacy bedrock-agent-runtime client.
Expected raw_data structure::
{
"user_input": "...",
"final_response": "..." | {...},
"latency": 1.234,
"trace": [...], # CloudWatch log entries (JSON strings, optional)
"response_chunks": [...], # Raw streaming chunks (optional)
"trace_id": "...",
"session_id": "...",
"agent_runtime_id": "...", # Runtime ARN or ID
}
Source code in uaef/adapters/agentcore.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 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 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 | |
name
property
Return the adapter name.
extract_messages(raw_data)
Extract messages from AgentCore response and logs.
Source code in uaef/adapters/agentcore.py
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 | |
extract_metadata(raw_data)
Extract metadata from AgentCore response.
Source code in uaef/adapters/agentcore.py
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 | |
extract_tool_calls(raw_data)
Extract tool calls from AgentCore trace events and CloudWatch logs.
Source code in uaef/adapters/agentcore.py
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 | |
extract_tools_info(log_entries)
classmethod
Extract tool calls, responses, and token metrics from otel-rt-logs.
Parses OpenTelemetry-formatted log entries (Strands/AgentCore format) to extract tool calls, their responses, and token usage.
Handles multiple formats found in otel-rt-logs: - gen_ai.assistant.message: contains toolUse items in body.content and/or body.tool_calls with function format - gen_ai.choice: contains body.message.tool_calls - gen_ai.tool.message: contains tool responses with body.id and body.content
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_entries
|
List[str]
|
List of JSON-encoded log message strings from CloudWatch. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict with tool_calls list and token_usage metrics. |
Source code in uaef/adapters/agentcore.py
1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 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 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 | |
generate_xray_trace_id()
classmethod
Generate a synthetic X-Ray trace ID.
Source code in uaef/adapters/agentcore.py
1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 | |
get_logs_by_session_id(session_id, log_group_names, region_name='us-east-1', log_stream_name=None, invocation_time=None)
classmethod
Run a CloudWatch Logs Insights query to find all logs for a given session ID.
Uses the session ID (runtimeSessionId) which is passed to the agent during invocation and appears in the otel logs, making it a reliable correlation key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
str
|
The runtime session ID used in the invocation. |
required |
log_group_names
|
List[str]
|
A list of CloudWatch log group names to search. |
required |
region_name
|
str
|
The AWS region where the log groups are located. |
'us-east-1'
|
log_stream_name
|
Optional[str]
|
Optional log stream name to scope the query to (e.g. "otel-rt-logs"). If None, searches all streams. |
None
|
invocation_time
|
Optional[float]
|
Unix timestamp of when the invocation started. If provided, searches from 1 minute before this time. If None, searches the last hour. |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List of log message strings matching the session ID. |
Source code in uaef/adapters/agentcore.py
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 | |
get_logs_by_time_window(log_group_names, invocation_time, region_name='us-east-1', log_stream_name=None)
classmethod
Fetch all otel logs from a narrow time window around an invocation.
Since the otel traceId is generated server-side and can't be predicted client-side, this method fetches all logs from the invocation time window and returns them. The caller can then filter/group by traceId if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_group_names
|
List[str]
|
CloudWatch log group names to search. |
required |
invocation_time
|
float
|
Unix timestamp of when the invocation started. |
required |
region_name
|
str
|
AWS region. |
'us-east-1'
|
log_stream_name
|
Optional[str]
|
Optional log stream name filter (e.g. "otel-rt-logs"). |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List of log message strings from the time window. |
Source code in uaef/adapters/agentcore.py
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 | |
get_logs_by_trace_id(trace_id, log_group_names, region_name='us-east-1', log_stream_name=None)
classmethod
Run a CloudWatch Logs Insights query to find all logs for a given trace ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_id
|
str
|
The X-Ray trace ID to search for. |
required |
log_group_names
|
List[str]
|
A list of CloudWatch log group names to search. |
required |
region_name
|
str
|
The AWS region where the log groups are located. |
'us-east-1'
|
log_stream_name
|
Optional[str]
|
Optional log stream name to scope the query to (e.g. "otel-rt-logs"). If None, searches all streams. |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List of log message strings matching the trace ID. |
Source code in uaef/adapters/agentcore.py
1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 | |
invoke(agent_runtime_arn, user_input, agent_version=None, *, region=None, session_id=None, qualifier=None, bearer_token=None, auto_detect_auth=True, payload_override=None, boto_session=None, log_stream_name=None, fetch_logs=True)
staticmethod
Invoke an AgentCore-deployed agent and collect its streaming response.
Supports both authentication modes:
- SigV4 (default) — uses the
bedrock-agentcoreboto3 client. Works when the agent runtime is configured for IAM auth. - OAuth / JWT bearer token — when bearer_token is provided the
adapter makes a raw HTTPS
POSTto the AgentCore data-plane endpoint instead, because the AWS SDK always signs with SigV4 which is rejected by OAuth-configured runtimes.
When auto_detect_auth is True (default) and no bearer_token is provided, the adapter will first try SigV4. If that fails with an authorization mismatch, it queries the runtime's authorizer config and attempts to auto-fetch a Cognito token via client_credentials grant before retrying with OAuth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_runtime_arn
|
str
|
The AgentCore Runtime ARN. |
required |
user_input
|
str
|
The prompt to send. |
required |
region
|
Optional[str]
|
AWS region (reads from UAEF config if not provided). |
None
|
session_id
|
Optional[str]
|
Optional runtime session ID (generated if omitted). |
None
|
qualifier
|
Optional[str]
|
Optional qualifier / endpoint name. |
None
|
bearer_token
|
Optional[str]
|
If the agent runtime uses OAuth/JWT inbound auth,
pass the access token here. When set, the invocation is made
via HTTPS with an |
None
|
auto_detect_auth
|
bool
|
If True and SigV4 fails with auth mismatch, automatically detect OAuth config and retry. Default True. |
True
|
payload_override
|
Optional[Dict[str, Any]]
|
Optional dict to use as the JSON payload instead
of the default |
None
|
boto_session
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A dict suitable for |
Source code in uaef/adapters/agentcore.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
transform_to_canonical(raw_data)
Transform AgentCore response data to canonical format.
Auto-detects multi-agent traces when raw_data contains an
"agents" key mapping agent names to their individual response
dicts. Otherwise returns a single AgentTrace.
This mirrors the LangGraph adapter's auto-detect pattern: the caller does not need to specify agent node names — the adapter infers the multi-agent structure from the data shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
AgentCore response data. For multi-agent, include:: {
"user_input": "...",
"agents": {
"agent_name": { |
required |
Returns:
| Type | Description |
|---|---|
Union[AgentTrace, MultiAgentTrace]
|
AgentTrace for single-agent, MultiAgentTrace for multi-agent. |
Source code in uaef/adapters/agentcore.py
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 | |
uaef.adapters.generic
Generic JSON adapter for transforming arbitrary JSON traces to canonical format.
GenericJSONAdapter
Bases: BaseAdapter
Adapter for transforming arbitrary JSON traces to canonical AgentTrace format.
This adapter uses schema mapping configuration to extract fields from JSON data with flexible structure. It supports JSONPath expressions for nested field extraction.
Schema mapping format: { "messages": { "path": "$.conversation.messages[]", "role_field": "sender", "content_field": "text", "timestamp_field": "created_at" }, "tool_calls": { "path": "$.execution.tools[]", "name_field": "tool_name", "arguments_field": "params", "result_field": "output", "timestamp_field": "executed_at" }, "metadata": { "input_tokens": "$.usage.input", "output_tokens": "$.usage.output", "latency": "$.performance.duration", "model": "$.config.model_name" }, "trace_id": "$.trace.id", "session_id": "$.session.id" }
Source code in uaef/adapters/generic.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | |
name
property
Return the adapter name.
extract_messages(raw_data)
Extract messages from generic JSON using schema mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Generic JSON trace data |
required |
Returns:
| Type | Description |
|---|---|
List[Message]
|
List of Message objects |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If message extraction fails |
Source code in uaef/adapters/generic.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
extract_metadata(raw_data)
Extract metadata from generic JSON using schema mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Generic JSON trace data |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary of metadata |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If metadata extraction fails |
Source code in uaef/adapters/generic.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
extract_tool_calls(raw_data)
Extract tool calls from generic JSON using schema mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Generic JSON trace data |
required |
Returns:
| Type | Description |
|---|---|
List[ToolCall]
|
List of ToolCall objects |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If tool call extraction fails |
Source code in uaef/adapters/generic.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
transform_to_canonical(raw_data)
Transform generic JSON data to canonical AgentTrace format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Dict[str, Any]
|
Generic JSON trace data |
required |
Returns:
| Type | Description |
|---|---|
AgentTrace
|
Canonical AgentTrace object |
Raises:
| Type | Description |
|---|---|
AdapterTransformationError
|
If transformation fails |
Source code in uaef/adapters/generic.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
uaef.adapters.invocation
Live agent-invocation helpers.
These helpers call live agents (HTTP endpoints, Bedrock agents, Langfuse traces) and package their raw responses for the matching framework adapter. They live in the library — alongside the adapters — so that every consumer (the demo backend, the service, notebooks) invokes live agents through the same code path instead of re-implementing this glue.
httpx is not part of the lean core dependency set, so the HTTP helpers import
it lazily and raise an actionable :class:ImportError when it is missing. boto3
is a core dependency and is imported lazily here only to keep this module importable
in environments where AWS credentials/clients are not configured.
invoke_agentcore_runtime(agent_runtime_arn, query, region='us-east-1', qualifier=None, session_id=None, payload_key='prompt')
Invoke a Bedrock AgentCore runtime and return packaged data for the adapter.
Calls the AgentCore data-plane InvokeAgentRuntime API with a JSON payload
{payload_key: query} (payload_key defaults to "prompt"; override
it if your runtime expects a different input key). The streaming response is
read fully and JSON-decoded when possible, then returned in the shape the
AgentCore adapter (get_adapter("agentcore")) expects to transform into a
canonical trace.
boto3 is imported lazily so this module stays importable where AWS is not
configured. Requires the caller's role to allow
bedrock-agentcore:InvokeAgentRuntime on the target runtime.
Source code in uaef/adapters/invocation.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
invoke_bedrock_agent(agent_id, alias_id, query, region='us-east-1')
Invoke a Bedrock agent and return packaged data for the adapter.
Source code in uaef/adapters/invocation.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
invoke_http_agent(endpoint, query, *, session_id=None, turn_id=None, timeout=120.0, field_map=None)
Call an HTTP agent endpoint with POST {"query": "..."} and return JSON.
Conversation continuity (both optional, omitted from the body when unset, so a
single-turn call posts exactly {"query": ...}):
session_id
Identifies the conversation. The endpoint is required to keep the
conversation state itself and key on this. Multi-turn evaluation is only
meaningful against such an endpoint: a dependent turn like "Book the
cheapest hotel." has no referent unless the agent remembers the turn that
listed them.
turn_id
1-based position of this turn within the session. Lets an agent
distinguish "start of conversation" from "continuation" — useful when
beginning a turn has side effects, such as resetting a scratch database.
field_map renames any request field (see :data:DEFAULT_REQUEST_FIELDS) for
endpoints that use their own names.
Source code in uaef/adapters/invocation.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
invoke_http_agent_for_framework(endpoint, query, framework, *, session_id=None, turn_id=None, field_map=None, payload_session_id=None)
Call an HTTP agent and package the response for the given framework adapter.
session_id is what the agent is told. payload_session_id, when given,
is what gets stamped on the returned payload instead — because those are
legitimately different values. Against a stateful agent the id sent must be
unique per run, or re-running a dataset continues the previous run's
conversation; but grouping and reporting want the dataset's own stable id.
Defaults to session_id when omitted, which is the single-identifier case.
session_id / turn_id are forwarded to the agent (see
:func:invoke_http_agent) and, when supplied, stamped onto the returned
payload. That stamping matters: the multi-turn path of
:meth:~uaef.adapters.langgraph.LangGraphAdapter.transform_to_canonical
groups a list of per-turn payloads by session_id and orders them by
turn_id, and raises if either is missing. A caller-supplied value always
wins over whatever the agent echoes back, so grouping reflects the dataset
rather than the agent's own bookkeeping.
Source code in uaef/adapters/invocation.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
invoke_langfuse_trace(query, expected, public_key, secret_key, host)
Fetch a real Langfuse trace matching the query, or simulate one.
Strategy: 1. Try to fetch traces from Langfuse that match the query text. 2. If a matching trace is found, return its observations in the format expected by LangfuseAdapter. 3. If no match or Langfuse SDK unavailable, fall back to a simulated trace using the ground truth expected answer.
Source code in uaef/adapters/invocation.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |