Skip to content

Commit 092a61d

Browse files
DeanChensjcopybara-github
authored andcommitted
refactor(flows): relocate tool execution components into flows/llm_flows/tools
Relocate internal tool execution, batch dispatch, confirmation, error handling, and rearranging from flows/llm_flows into a dedicated flows/llm_flows/tools subpackage, updating functions.py and contents.py, while preserving backward compatibility shims for public APIs (such as request_confirmation). Co-authored-by: Shangjie Chen <[email protected]> PiperOrigin-RevId: 982109677
1 parent e9e3b97 commit 092a61d

16 files changed

Lines changed: 545 additions & 451 deletions

‎src/google/adk/flows/llm_flows/contents.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
from ._fencing import _is_other_agent_reply
3535
from ._fencing import _present_other_agent_message
3636
from ._invocation_utils import as_llm_agent
37-
from ._tool_call_rearranger import _drop_orphaned_function_responses
38-
from ._tool_call_rearranger import _rearrange_events_for_async_function_responses_in_history
39-
from ._tool_call_rearranger import _rearrange_events_for_latest_function_response
40-
from ._tool_call_rearranger import drop_orphaned_function_calls
4137
from .functions import AF_FUNCTION_CALL_ID_PREFIX
4238
from .functions import REQUEST_CONFIRMATION_FUNCTION_CALL_NAME
4339
from .functions import REQUEST_EUC_FUNCTION_CALL_NAME
40+
from .tools._rearranger import _drop_orphaned_function_responses
41+
from .tools._rearranger import _rearrange_events_for_async_function_responses_in_history
42+
from .tools._rearranger import _rearrange_events_for_latest_function_response
43+
from .tools._rearranger import drop_orphaned_function_calls
4444

4545
logger = logging.getLogger('google_adk.' + __name__)
4646

‎src/google/adk/flows/llm_flows/functions.py‎

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,51 +24,51 @@
2424
from google.adk.platform import uuid as platform_uuid
2525
from google.genai import types
2626

27-
from . import _batch_tool_executor
2827
from ...auth.auth_tool import AuthConfig
2928
from ...auth.auth_tool import AuthToolArguments
3029
from ...events.event import Event
3130
from ...tools.base_tool import BaseTool
3231
from ...tools.tool_confirmation import ToolConfirmation
33-
# Re-export definitions from submodules for full backward compatibility
34-
from ._batch_tool_executor import _execute_prepared_function_calls_async as _execute_prepared_function_calls_async
35-
from ._batch_tool_executor import _execute_prepared_function_calls_live as _execute_prepared_function_calls_live
36-
from ._batch_tool_executor import _gather_or_cancel as _gather_or_cancel
37-
from ._batch_tool_executor import _is_non_blocking_tool as _is_non_blocking_tool
38-
from ._batch_tool_executor import _launch_non_blocking_call_live as _launch_non_blocking_call_live
39-
from ._batch_tool_executor import _merge_and_trace_function_response_events as _merge_and_trace_function_response_events
40-
from ._batch_tool_executor import _prepare_function_calls as _prepare_function_calls
41-
from ._batch_tool_executor import deep_merge_dicts as deep_merge_dicts
42-
from ._batch_tool_executor import merge_parallel_function_response_events as merge_parallel_function_response_events
32+
# Re-export definitions from tools submodules for full backward compatibility
4333
from ._invocation_utils import require_agent_name as _require_agent_name
44-
from ._tool_caller import _as_callback_result as _as_callback_result
45-
from ._tool_caller import _as_function_response_part as _as_function_response_part
46-
from ._tool_caller import _build_function_response_content as _build_function_response_content
47-
from ._tool_caller import _build_response_event as _build_response_event
48-
from ._tool_caller import _call_tool_async as _call_tool_async
49-
from ._tool_caller import _call_tool_in_thread_pool as _call_tool_in_thread_pool
50-
from ._tool_caller import _create_tool_context as _create_tool_context
51-
from ._tool_caller import _emit_streaming_tool_event as _emit_streaming_tool_event
52-
from ._tool_caller import _execute_single_prepared_call as _execute_single_prepared_call
53-
from ._tool_caller import _execute_single_prepared_call_async as _execute_single_prepared_call_async
54-
from ._tool_caller import _execute_single_prepared_call_live as _execute_single_prepared_call_live
55-
from ._tool_caller import _extract_media_from_entry as _extract_media_from_entry
56-
from ._tool_caller import _extract_multimodal_parts as _extract_multimodal_parts
57-
from ._tool_caller import _get_tool as _get_tool
58-
from ._tool_caller import _get_tool_and_context as _get_tool_and_context
59-
from ._tool_caller import _get_tool_thread_pool as _get_tool_thread_pool
60-
from ._tool_caller import _is_live_request_queue_annotation as _is_live_request_queue_annotation
61-
from ._tool_caller import _is_sync_tool as _is_sync_tool
62-
from ._tool_caller import _MAX_MEDIA_CONTAINER_DEPTH as _MAX_MEDIA_CONTAINER_DEPTH
63-
from ._tool_caller import _message_content_for_user as _message_content_for_user
64-
from ._tool_caller import _MESSAGE_EVENT_FIELDS as _MESSAGE_EVENT_FIELDS
65-
from ._tool_caller import _normalize_tool_result as _normalize_tool_result
66-
from ._tool_caller import _prepare_single as _prepare_single
67-
from ._tool_caller import _PreparedFunctionCall as _PreparedFunctionCall
68-
from ._tool_caller import _process_function_live_helper as _process_function_live_helper
69-
from ._tool_caller import _TOOL_THREAD_POOL_LOCK as _TOOL_THREAD_POOL_LOCK
70-
from ._tool_caller import _TOOL_THREAD_POOLS as _TOOL_THREAD_POOLS
71-
from ._tool_caller import _try_decode_computer_use_image as _try_decode_computer_use_image
34+
from .tools import _batch_executor as _batch_tool_executor
35+
from .tools._batch_executor import _execute_prepared_function_calls_async as _execute_prepared_function_calls_async
36+
from .tools._batch_executor import _execute_prepared_function_calls_live as _execute_prepared_function_calls_live
37+
from .tools._batch_executor import _gather_or_cancel as _gather_or_cancel
38+
from .tools._batch_executor import _is_non_blocking_tool as _is_non_blocking_tool
39+
from .tools._batch_executor import _launch_non_blocking_call_live as _launch_non_blocking_call_live
40+
from .tools._batch_executor import _merge_and_trace_function_response_events as _merge_and_trace_function_response_events
41+
from .tools._batch_executor import _prepare_function_calls as _prepare_function_calls
42+
from .tools._batch_executor import deep_merge_dicts as deep_merge_dicts
43+
from .tools._batch_executor import merge_parallel_function_response_events as merge_parallel_function_response_events
44+
from .tools._caller import _as_callback_result as _as_callback_result
45+
from .tools._caller import _as_function_response_part as _as_function_response_part
46+
from .tools._caller import _build_function_response_content as _build_function_response_content
47+
from .tools._caller import _build_response_event as _build_response_event
48+
from .tools._caller import _call_tool_async as _call_tool_async
49+
from .tools._caller import _call_tool_in_thread_pool as _call_tool_in_thread_pool
50+
from .tools._caller import _create_tool_context as _create_tool_context
51+
from .tools._caller import _emit_streaming_tool_event as _emit_streaming_tool_event
52+
from .tools._caller import _execute_single_prepared_call as _execute_single_prepared_call
53+
from .tools._caller import _execute_single_prepared_call_async as _execute_single_prepared_call_async
54+
from .tools._caller import _execute_single_prepared_call_live as _execute_single_prepared_call_live
55+
from .tools._caller import _extract_media_from_entry as _extract_media_from_entry
56+
from .tools._caller import _extract_multimodal_parts as _extract_multimodal_parts
57+
from .tools._caller import _get_tool as _get_tool
58+
from .tools._caller import _get_tool_and_context as _get_tool_and_context
59+
from .tools._caller import _get_tool_thread_pool as _get_tool_thread_pool
60+
from .tools._caller import _is_live_request_queue_annotation as _is_live_request_queue_annotation
61+
from .tools._caller import _is_sync_tool as _is_sync_tool
62+
from .tools._caller import _MAX_MEDIA_CONTAINER_DEPTH as _MAX_MEDIA_CONTAINER_DEPTH
63+
from .tools._caller import _message_content_for_user as _message_content_for_user
64+
from .tools._caller import _MESSAGE_EVENT_FIELDS as _MESSAGE_EVENT_FIELDS
65+
from .tools._caller import _normalize_tool_result as _normalize_tool_result
66+
from .tools._caller import _prepare_single as _prepare_single
67+
from .tools._caller import _PreparedFunctionCall as _PreparedFunctionCall
68+
from .tools._caller import _process_function_live_helper as _process_function_live_helper
69+
from .tools._caller import _TOOL_THREAD_POOL_LOCK as _TOOL_THREAD_POOL_LOCK
70+
from .tools._caller import _TOOL_THREAD_POOLS as _TOOL_THREAD_POOLS
71+
from .tools._caller import _try_decode_computer_use_image as _try_decode_computer_use_image
7272

7373
if TYPE_CHECKING:
7474
from ...agents.invocation_context import InvocationContext

0 commit comments

Comments
 (0)