adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Importing Agent from ADK in a notebook takes 29 seconds?

Open jexp opened this issue 1 year ago • 8 comments

Not sure what the reason is but I have a notebook demonstrating ADK, where the import of Agent from ADK just took 29s seconds

Image

All the other imports and operations were instant?

jexp avatar Apr 13 '25 22:04 jexp

Thanks for reporting. We are looking into it.

cc: @Jacksunwei

hangfei avatar Apr 14 '25 23:04 hangfei

I can reproduce. It took me about 10~20 seconds.

boyangsvl avatar May 03 '25 00:05 boyangsvl

Thank you for filing this issue. We are doing some housekeeping, and since there has been no recent activity on this thread, we will be closing it as stale.

If this is still an issue for you with the latest version of the library, please feel free to comment, and we will be happy to reopen it.

Thanks again for your contribution!

jwiejulie avatar Aug 08 '25 22:08 jwiejulie

as of versions 1.14.1 , (Tried couple of previous versions too), the import time is atrocious, experiencing anywhere between 15 to 30 seconds of import time. Tried it in notebook, and integration in a Django Project.

JokingLemon avatar Sep 16 '25 10:09 JokingLemon

Hi @jexp Thanks for reporting! There have been several performance updates in recent releases.Please try importing the Agent using the latest available version and check if the import time has improved.

klateefa avatar Oct 14 '25 05:10 klateefa

@klateefa , here is a crude test I did between 1.14.1 and 1.16

TLDR: No change, similar results to OP


import time
t1 = time.time()
from google.adk import agents
print("Import took", time.time() - t1, "seconds")

Results were within margin of error in each case

Running with just python - 4.5-5s Running with Debugger - 14-16s

I ran this in a venv environment, running in conda and notebook environments usually takes upto 2x longer for me, Can do more AB testing later if you want

JokingLemon avatar Oct 14 '25 06:10 JokingLemon

Thanks for reporting this issue - this was actually the earliest report of the ADK import performance problem (April 2025)!

This issue is a duplicate of #2433, which has identified the root cause: eager imports in ADK's __init__.py files causing 8-20+ second import overhead. While #157 was reported first, #2433 has accumulated more comprehensive root cause analysis and community discussion, so we're consolidating tracking there.

Key timeline:

  • April 13, 2025: This issue (#157) first reported 29s import time
  • August 8, 2025: #2433 identified root cause (eager __init__.py imports)
  • October 14, 2025: @JokingLemon confirmed still present in v1.16 (4.5-5s in venv, 14-16s with debugger)

As @JokingLemon's recent testing shows, this hasn't been resolved yet despite the team's efforts. Please follow #2433 for updates on the fix. The team has created a Colab notebook to track optimization targets.

Duplicate of #2433

Jacksunwei avatar Oct 28 '25 03:10 Jacksunwei

Closing as duplicate of #2433

Jacksunwei avatar Oct 28 '25 03:10 Jacksunwei