a2aproject / a2aproject/a2a-samples
Using variable 'task' before assignment
- Linguagem predominante
- Jupyter Notebook
- Estrelas
- 1.8k
- Forks
- 751
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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
```
Guia de contribuição
Direção de pesquisa
The error occurs in samples/python/hosts/multiagent/host_agent.py at line 179, where 'task' is referenced before assignment. Examine the function 'send_message' to see how 'task' is defined and used. Look at the surrounding code to understand the flow and ensure 'task' is properly initialized before line 179. Run the demo UI with the agents to reproduce and verify the fix.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- ai, backend
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 45/100