The resolved self.tools field as a list of BaseTool based on the context. This method is only for use by Agent Development Kit.
(
self, ctx: Optional[ReadonlyContext] = None
)
| 692 | return global_instruction, True |
| 693 | |
| 694 | async def canonical_tools( |
| 695 | self, ctx: Optional[ReadonlyContext] = None |
| 696 | ) -> list[BaseTool]: |
| 697 | """The resolved self.tools field as a list of BaseTool based on the context. |
| 698 | |
| 699 | This method is only for use by Agent Development Kit. |
| 700 | """ |
| 701 | # We may need to wrap some built-in tools if there are other tools |
| 702 | # because the built-in tools cannot be used together with other tools. |
| 703 | # TODO(b/448114567): Remove once the workaround is no longer needed. |
| 704 | multiple_tools = len(self.tools) > 1 |
| 705 | model = self.canonical_model |
| 706 | |
| 707 | results = await asyncio.gather(*( |
| 708 | _convert_tool_union_to_tools(tool_union, ctx, model, multiple_tools) |
| 709 | for tool_union in self.tools |
| 710 | )) |
| 711 | |
| 712 | resolved_tools = [] |
| 713 | for tools in results: |
| 714 | resolved_tools.extend(tools) |
| 715 | |
| 716 | return resolved_tools |
| 717 | |
| 718 | @property |
| 719 | def canonical_before_model_callbacks( |