Skip to content

when i try to run it i get module 'multi_tool_agent.agent' has no attribute 'root_agent' #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ub1979 opened this issue Apr 11, 2025 · 10 comments

Comments

@ub1979
Copy link

ub1979 commented Apr 11, 2025

i am running it on mac m4
python = 3.11
here is the log
(adk) u@us-MacBook-Pro adk % adk run multi_tool_agent
Log setup complete: /var/folders/fq/k9567j_n5tz59hz7_whwfdtm0000gn/T/agents_log/agent.20250411_080357.log
To access latest log: tail -F /var/folders/fq/k9567j_n5tz59hz7_whwfdtm0000gn/T/agents_log/agent.latest.log
Traceback (most recent call last):
File "/opt/anaconda3/envs/adk/bin/adk", line 8, in
sys.exit(main())
^^^^^^
File "/opt/anaconda3/envs/adk/lib/python3.11/site-packages/click/core.py", line 1161, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/adk/lib/python3.11/site-packages/click/core.py", line 1082, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/adk/lib/python3.11/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/adk/lib/python3.11/site-packages/click/core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/adk/lib/python3.11/site-packages/click/core.py", line 788, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/adk/lib/python3.11/site-packages/google/adk/cli/cli_tools_click.py", line 78, in cli_run
asyncio.run(
File "/opt/anaconda3/envs/adk/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/adk/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/adk/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/adk/lib/python3.11/site-packages/google/adk/cli/cli.py", line 127, in run_cli
root_agent = agent_module.agent.root_agent
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'multi_tool_agent.agent' has no attribute 'root_agent'

@Harshith-techo
Copy link

as of yet, the root agent should be named as root_agent, there's something wrong with the sample codes that google have documented. That's how I was able to rectify this issue.

@seanmwalker
Copy link

seanmwalker commented Apr 11, 2025

I found this solution noted above to resolve the issue as well.
Image

@seanmwalker
Copy link

I've opened a PR to help with this documentation in the adk-docs repo:

google/adk-docs#42

@ub1979
Copy link
Author

ub1979 commented Apr 11, 2025

Image Image Image

I did what you said and now i am getting this error

"cannot import name 'root_agent' from 'multi_tool_agent.agent' (/Users/u/funcoding/adk/multi_tool_agent/agent.py)"

@seanmwalker
Copy link

seanmwalker commented Apr 11, 2025

In the screen shot it looks like you have one called agent_ollama_gemma. the agent variable you reference in the init.py file needs to have the same name as the agent.py file has.

In the sample app that we were using, the exported agent was called root_agent. In your case it looks to be agent_ollama_gemma, unless you have another agent you are trying to use.

@ub1979
Copy link
Author

ub1979 commented Apr 11, 2025

Thanks its working now :) , one more Question , why its soo slow , like i am running it on my M4 Pro mac book , i am running small model to test , and its taking ages to reply ? is it common ? is there a way to make it respond fast ?

@seanmwalker
Copy link

I haven't run your model so I can't say. I have noted the configuration and driver setup on a machine can impact how it uses your GPU or only runs on CPU. You can try searching for how to optimize running local models. https://www.arsturn.com/blog/tips-for-speeding-up-ollama-performance may help. Otherwise look at the other notes on ollama's site for help.

@hangfei
Copy link
Collaborator

hangfei commented Apr 12, 2025

I think the original issue is resolved. Closing now. Feel free to re-open.

@hangfei hangfei closed this as completed Apr 12, 2025
@laeeqsiddique
Copy link

I'm getting a circular import error in this which is strange. Any idea what could be wrong?

\laeeq\vscode_projects\multi_tool_agent\__init__.py) Traceback (most recent call last): File "C:\Users\laeeq\.venv\Lib\site-packages\google\adk\cli\fast_api.py", line 604, in event_generator runner = _get_runner(req.app_name) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\laeeq\.venv\Lib\site-packages\google\adk\cli\fast_api.py", line 756, in _get_runner root_agent = _get_root_agent(app_name) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\laeeq\.venv\Lib\site-packages\google\adk\cli\fast_api.py", line 747, in _get_root_agent agent_module = importlib.import_module(app_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\laeeq\anaconda3\Lib\importlib\__init__.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1387, in _gcd_import File "<frozen importlib._bootstrap>", line 1360, in _find_and_load File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 935, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 995, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "C:\Users\laeeq\vscode_projects\multi_tool_agent\__init__.py", line 1, in <module> from . import root_agent as root_agent ImportError: cannot import name 'root_agent' from partially initialized module 'multi_tool_agent' (most likely due to a circular import) (C:\Users\laeeq\vscode_projects\multi_tool_agent\__init__.py) ←[32mINFO←[0m: 127.0.0.1:60874 - "←[1mGET /apps/multi_tool_agent/users/user/sessions/8e0c2bb3-91ec-4dae-a204-9451a900c584 HTTP/1.1←[0m" ←[32m200 OK←[0m

@vzegna
Copy link

vzegna commented Apr 28, 2025

I fixed the circular import by using an absolute import:

from src.agent import root_agent

Instead of a relative import:

from . import root_agent

Note that my agent.py is inside the src/ folder in my repo root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants