(messages: list[dict[str, Any]], idx: int, tool_call_id: str)
| 601 | |
| 602 | |
| 603 | def _infer_tool_name(messages: list[dict[str, Any]], idx: int, tool_call_id: str) -> str: |
| 604 | if not tool_call_id: |
| 605 | return "" |
| 606 | for prev in reversed(messages[:idx]): |
| 607 | if not isinstance(prev, dict): |
| 608 | continue |
| 609 | tool_calls = prev.get("tool_calls") or [] |
| 610 | if not isinstance(tool_calls, list): |
| 611 | continue |
| 612 | for call in tool_calls: |
| 613 | if not isinstance(call, dict): |
| 614 | continue |
| 615 | if call.get("id") != tool_call_id: |
| 616 | continue |
| 617 | fn = call.get("function") or {} |
| 618 | name = fn.get("name", "") |
| 619 | return str(name) |
| 620 | return "" |
| 621 | |
| 622 | |
| 623 | def _build_artifact_stub(text: str, record: Any, policy: CompositionPolicy) -> str: |
no test coverage detected