Skip to content

Lazily exported classes such as Gemini and App are missing from dir() and the API reference #8373

In review

Description

@chrikrah

🔴 Required Information

Describe the Bug

The Python API reference has no entry for Gemini, Claude, LiteLlm, App, InMemoryMemoryService or InMemoryArtifactService, while the eagerly imported BaseLlm and BaseMemoryService are there. Eight packages resolve these names in a module __getattr__ with no __dir__, so dir() and autodoc never see them. This is #4331 again: sessions got a __dir__ for it, and 9fd6b33 gave plugins one yesterday.

Steps to Reproduce

  1. pip install google-adk==2.15.1 (same at 03725e8 on main)
  2. Run the script under Minimal Reproduction Code.

Expected Behavior

Every name in a package's __all__ appears in dir(package), as test_lazy_packages_support_star_imports asserts for the _lazy.accessors packages.

Observed Behavior

$ python repro.py
2.15.1
google.adk.models: AnthropicGenerateContentConfig, ApigeeLlm, Claude, FallbackModel, Gemini, Gemma, Gemma3Ollama, LiteLlm
google.adk.memory: InMemoryMemoryService, SqliteMemoryService, VertexAiMemoryBankService, VertexAiRagMemoryService
google.adk.artifacts: FileArtifactService, GcsArtifactService, InMemoryArtifactService
google.adk.code_executors: AgentEngineSandboxCodeExecutor, BuiltInCodeExecutor, CodeExecutorContext, ContainerCodeExecutor, GkeCodeExecutor, VertexAiCodeExecutor
google.adk.apps: App, ResumabilityConfig
google.adk.tools.retrieval: FilesRetrieval, LlamaIndexRetrieval, VertexAiRagRetrieval
google.adk.a2a.agent: A2AClientError, A2aCardRequestConfig, A2aRemoteAgentConfig, AgentCardResolutionError, CardRequestInterceptor, ParametersConfig, RemoteA2aAgent, RequestInterceptor
google.adk.evaluation.simulation: LlmAudioUserSimulatorConfig
# not run: the Sphinx build; the missing entries were read off the published page

Environment Details

  • ADK Library Version (pip show google-adk): 2.15.1
  • Desktop OS: Linux
  • Python Version (python -V): Python 3.12.14

Model Information

  • Are you using LiteLLM: No
  • Which model is being used: N/A, no model is called

🟡 Optional Information

Minimal Reproduction Code

import importlib

import google.adk

print(google.adk.__version__)
for name in (
    "models", "memory", "artifacts", "code_executors", "apps",
    "tools.retrieval", "a2a.agent", "evaluation.simulation",
):
  package = importlib.import_module(f"google.adk.{name}")
  missing = sorted(set(package.__all__) - set(dir(package)))
  print(f"{package.__name__}: {', '.join(missing)}")

How often has this issue occurred?

  • Always (100%)

Additional Context

I'd add the __dir__ that _lazy.accessors builds, sorted(set(globals()) | set(__all__)), to each package. The freezegun guard in plugins is there for pandas, and resolving all 35 names above loads no pandas, so I left it out. The change and its tests are ready, and I'll open the pull request against this issue.

Activity

  1. surajksharma07 commented on Nov 27, 2026

    @surajksharma07
    Collaborator

    @chrikrah. Reproduced on main and on the 2.15.1 wheel from PyPI: the same 35 names across the same 8 packages. I also checked for other packages with this gap and found none beyond your eight (skills only hides the deprecated DEFAULT_SKILL_SYSTEM_INSTRUCTION, so that's fine to leave out).

    Adding a dir that returns sorted(set(globals()) | set(all)) worked for me as a workaround. dir() then lists everything and it doesn't import anything new.

    Since #8374 is already up, could you test two more things before review? First, help() and inspect.getmembers() on an install without the extras. Second, a quick freeze_time test, since dir() now pulls in litellm/anthropic there.

    If you can also run the Sphinx build locally and confirm Gemini and App show up on the page, that would help the reviewers a lot.

  2. chrikrah commented on Nov 27, 2026

    @chrikrah
    Author

    @surajksharma07 good call: with anthropic installed, freeze_time raised inside pydantic. b7f899e adds the plugins guard to all eight.

    Your first check found a regression of ours: without extras, help() and getmembers() now raise ImportError in four packages, as main does in agents and tools. I'd fix all of them later. Should it block #8374?

    # 7a020183cf21 = #8374 before the fix, b7f899e1b250 = #8374 now, 03725e8 = base, Python 3.12.14
    # freeze_time("2026-01-01") after importing the eight packages, anthropic 2.14.0 + litellm 1.106.2 installed
    base 03725e8    frozen ok, 0 litellm/anthropic modules loaded
    #8374 7a02018   pydantic.errors.PydanticSchemaGenerationError: ... <class 'freezegun.api.FakeDatetime'>
                    (freezegun/api.py:112 -> models/__init__.py:144 __getattr__ -> anthropic_llm.py:41)
    #8374 b7f899e   frozen ok, 0 litellm/anthropic modules loaded
    
    $ pytest -q tests/unittests/test_import_loading.py -k freezegun   # new test, __dir__ reverted to 7a02018
    8 failed, 38 deselected
    $ pytest -q tests/unittests/test_import_loading.py -k hand_written   # at b7f899e
    16 passed, 30 deselected
    
    # core install (no extras): inspect.getmembers() / help() line count
                      base 03725e8                 #8374 b7f899e
    models            36 members / 1715 lines      ImportError (AnthropicGenerateContentConfig) / 2 lines
    a2a.agent, code_executors, tools.retrieval: same ImportError at #8374; apps, artifacts, memory, simulation: fine
    agents, tools, sessions, plugins at base:   already 2 lines (missing mcp, sqlalchemy, bigquery)
    
    # Sphinx 8 autodoc, automodule google.adk.models/apps/memory :members:
    base 03725e8    models.BaseLlm LLMRegistry LlmCapabilities ServiceTier, memory.BaseMemoryService, no apps entry
    #8374 b7f899e   adds models.Gemini Claude LiteLlm Gemma ApigeeLlm FallbackModel, apps.App ResumabilityConfig, memory.InMemoryMemoryService and 3 more
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions