Skip to content

fix: use default SQLite path in tool registry#96

Merged
QueryPlanner merged 2 commits into
mainfrom
fix/sqlite-path-default-in-registry
May 24, 2026
Merged

fix: use default SQLite path in tool registry#96
QueryPlanner merged 2 commits into
mainfrom
fix/sqlite-path-default-in-registry

Conversation

@QueryPlanner
Copy link
Copy Markdown
Owner

What

Fixes tool registry to use the default SQLite path when SQLITE_PATH env var is not set.

Why

After migrating from Postgres to SQLite, the storage layer correctly uses a default path ({AGENT_DIR}/.adk/tools.db), but the tool registry was returning None for sqlite_path when the env var wasn't set. This caused reminder/calorie/workout tools to never be registered with the agent.

The logs showed:

  • SQLITE_PATH: None
  • Storage schemas initialized correctly
  • But tools like schedule_reminder, log_meal, etc. were missing from Available Tools

How

  • Update build_tool_config_from_env() in registry.py to compute and use the same default SQLite path as server.py
  • Update test to expect the default path behavior

Tests

  • All 828 tests pass with 100% coverage
  • ruff format passes
  • ruff check passes
  • mypy typecheck passes

- Update build_tool_config_from_env to use default SQLite path
  when SQLITE_PATH env var is not set
- Match behavior of server.py lifespan which already uses default
- Update test to expect default path instead of None
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a default path for the SQLite database, ensuring it defaults to a .adk/tools.db file within the agent directory if no environment variable is provided. The tests have been updated to reflect this change. Review feedback suggests that the default path calculation for the agent directory might be off by one level, pointing to 'src/' instead of the project root, and recommends simplifying the logic for fetching the SQLite path environment variable.

Comment thread src/blacki/registry.py
import os

skills_dir = Path(__file__).parent / "skills"
agent_dir = os.getenv("AGENT_DIR", str(Path(__file__).resolve().parent.parent))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The default path calculation for agent_dir appears to point to the src/ directory instead of the project root. Given the file is located at src/blacki/registry.py, Path(__file__).resolve().parent.parent resolves to src/. Typically, configuration and data directories like .adk should reside in the project root. Consider going up one more level to reach the root.

Suggested change
agent_dir = os.getenv("AGENT_DIR", str(Path(__file__).resolve().parent.parent))
agent_dir = os.getenv("AGENT_DIR", str(Path(__file__).resolve().parent.parent.parent))

Comment thread src/blacki/registry.py Outdated
Comment on lines +238 to +239
sqlite_path_env = os.getenv("SQLITE_PATH", "").strip() or None
sqlite_path = sqlite_path_env or default_sqlite_path
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for determining sqlite_path can be simplified by removing the intermediate sqlite_path_env variable and using the fallback directly.

Suggested change
sqlite_path_env = os.getenv("SQLITE_PATH", "").strip() or None
sqlite_path = sqlite_path_env or default_sqlite_path
sqlite_path = os.getenv("SQLITE_PATH", "").strip() or default_sqlite_path

- Collapse sqlite_path assignment to single line
- Add comment explaining path calculation matches server.py
Copy link
Copy Markdown
Owner Author

@QueryPlanner QueryPlanner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Response to Review Comments

Comment 1: Path Calculation (Not Applied)

The suggestion to use parent.parent.parent to reach project root is incorrect.

This implementation deliberately matches server.py:128:

AGENT_DIR = os.getenv("AGENT_DIR", str(Path(__file__).resolve().parent.parent))

Evidence from user's logs confirms .adk lives in src/, not project root:

SQLite connection opened: /app/src/.adk/tools.db (WAL mode)

The AGENT_DIR points to src/ because that's where ADK expects agent modules to live, and the .adk directory is created there.

I've added a clarifying comment to make this explicit.

Comment 2: Simplify sqlite_path Logic (Applied)

Valid suggestion. Simplified to single-line assignment.

@QueryPlanner QueryPlanner merged commit 3bb360b into main May 24, 2026
1 check passed
@QueryPlanner QueryPlanner deleted the fix/sqlite-path-default-in-registry branch May 24, 2026 03:33
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

Successfully merging this pull request may close these issues.

1 participant