a2aproject / a2aproject/a2a-samples

Using variable 'task' before assignment

Aperta
#52 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Jupyter Notebook
Stelle
1.8k
Fork
751
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

When running the demo UI with agents created via https://mozilla-ai.github.io/any-agent/serving/#__tabbed_1_2, I ran into the following exception.

https://github.com/google-a2a/a2a-samples/blob/08dde55c070f43be3fc2abf9ff976b689891991f/samples/python/hosts/multiagent/host_agent.py#L179

```
xception in thread Thread-1 ():
Traceback (most recent call last):
File "/Users/nbrake/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
self.run()
File "/Users/nbrake/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/lib/python3.12/threading.py", line 1012, in run
self._target(*self._args, **self._kwargs)
File "/Users/nbrake/scm/a2a-samples/demo/ui/service/server/server.py", line 98, in
target=lambda: asyncio.run(self.manager.process_message(message))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nbrake/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Users/nbrake/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nbrake/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 686, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/nbrake/scm/a2a-samples/demo/ui/service/server/adk_host_manager.py", line 186, in process_message
async for event in self._host_runner.run_async(
File "/Users/nbrake/scm/a2a-samples/demo/ui/.venv/lib/python3.12/site-packages/google/adk/runners.py", line 196, in run_async
async for event in invocation_context.agent.run_async(invocation_context):
File "/Users/nbrake/scm/a2a-samples/demo/ui/.venv/lib/python3.12/site-packages/google/adk/agents/base_agent.py", line 147, in run_async
async for event in self._run_async_impl(ctx):
File "/Users/nbrake/scm/a2a-samples/demo/ui/.venv/lib/python3.12/site-packages/google/adk/agents/llm_agent.py", line 278, in _run_async_impl
async for event in self._llm_flow.run_async(ctx):
File "/Users/nbrake/scm/a2a-samples/demo/ui/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 279, in run_async
async for event in self._run_one_step_async(invocation_context):
File "/Users/nbrake/scm/a2a-samples/demo/ui/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 309, in _run_one_step_async
async for event in self._postprocess_async(
File "/Users/nbrake/scm/a2a-samples/demo/ui/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 381, in _postprocess_async
async for event in self._postprocess_handle_function_calls_async(
File "/Users/nbrake/scm/a2a-samples/demo/ui/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 456, in _postprocess_handle_function_calls_async
if function_response_event := await functions.handle_function_calls_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nbrake/scm/a2a-samples/demo/ui/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 166, in handle_function_calls_async
function_response = await __call_tool_async(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nbrake/scm/a2a-samples/demo/ui/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 431, in __call_tool_async
return await tool.run_async(args=args, tool_context=tool_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nbrake/scm/a2a-samples/demo/ui/.venv/lib/python3.12/site-packages/google/adk/tools/function_tool.py", line 80, in run_async
return await self.func(**args_to_call) or {}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nbrake/scm/a2a-samples/samples/python/hosts/multiagent/host_agent.py", line 179, in send_message
return await convert_parts(task.parts, tool_context)
^^^^
UnboundLocalError: cannot access local variable 'task' where it is not associated with a value
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.