mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-14 09:51:25 -06:00
refactor: remove async root_agent handling as it no longer needed for MCP toolset
PiperOrigin-RevId: 759364382
This commit is contained in:
parent
01cf186299
commit
cb000e5a94
@ -228,7 +228,6 @@ def get_fast_api_app(
|
|||||||
|
|
||||||
trace.set_tracer_provider(provider)
|
trace.set_tracer_provider(provider)
|
||||||
|
|
||||||
exit_stacks = []
|
|
||||||
toolsets_to_close: set[BaseToolset] = set()
|
toolsets_to_close: set[BaseToolset] = set()
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
@ -237,9 +236,6 @@ def get_fast_api_app(
|
|||||||
async with lifespan(app) as lifespan_context:
|
async with lifespan(app) as lifespan_context:
|
||||||
yield
|
yield
|
||||||
|
|
||||||
if exit_stacks:
|
|
||||||
for stack in exit_stacks:
|
|
||||||
await stack.aclose()
|
|
||||||
for toolset in toolsets_to_close:
|
for toolset in toolsets_to_close:
|
||||||
await toolset.close()
|
await toolset.close()
|
||||||
else:
|
else:
|
||||||
@ -912,15 +908,6 @@ def get_fast_api_app(
|
|||||||
else:
|
else:
|
||||||
raise ValueError(f'Unable to find "root_agent" from {app_name}.')
|
raise ValueError(f'Unable to find "root_agent" from {app_name}.')
|
||||||
|
|
||||||
# Handle an awaitable root agent and await for the actual agent.
|
|
||||||
if inspect.isawaitable(root_agent):
|
|
||||||
try:
|
|
||||||
agent, exit_stack = await root_agent
|
|
||||||
exit_stacks.append(exit_stack)
|
|
||||||
root_agent = agent
|
|
||||||
except Exception as e:
|
|
||||||
raise RuntimeError(f"error getting root agent, {e}") from e
|
|
||||||
|
|
||||||
root_agent_dict[app_name] = root_agent
|
root_agent_dict[app_name] = root_agent
|
||||||
toolsets_to_close.update(_get_all_toolsets(root_agent))
|
toolsets_to_close.update(_get_all_toolsets(root_agent))
|
||||||
return root_agent
|
return root_agent
|
||||||
|
Loading…
Reference in New Issue
Block a user