Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/blacki/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,15 @@ def build_tool_config_from_env() -> ToolConfig:
import os

skills_dir = Path(__file__).parent / "skills"
# Match server.py AGENT_DIR calculation (points to src/, not project root)
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))

default_sqlite_path = str(Path(agent_dir) / ".adk" / "tools.db")

sqlite_path = os.getenv("SQLITE_PATH", "").strip() or default_sqlite_path

return ToolConfig(
brave_search_api_key=os.getenv("BRAVE_SEARCH_API_KEY", "").strip() or None,
sqlite_path=os.getenv("SQLITE_PATH", "").strip() or None,
sqlite_path=sqlite_path,
sandbox_enabled=os.getenv("SANDBOX_ENABLED", "false").strip().lower()
in ("true", "1", "yes"),
skills_dir=skills_dir,
Expand Down
5 changes: 3 additions & 2 deletions tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ class TestBuildToolConfigFromEnv:
"""Tests for build_tool_config_from_env function."""

def test_empty_env(self) -> None:
"""Should return default config with empty env."""
"""Should return default config with default sqlite path."""
with patch.dict("os.environ", {}, clear=True):
config = build_tool_config_from_env()

assert config.brave_search_api_key is None
assert config.sqlite_path is None
assert config.sqlite_path is not None
assert config.sqlite_path.endswith(".adk/tools.db")
assert config.sandbox_enabled is False
assert config.skills_dir is not None

Expand Down
Loading