Adds Google ADK (Agent Development Kit) support to Semantica. `semantica_kg_tools()` and `semantica_decision_tools()` expose entity/relation extraction, graph updates, and decision recording as ADK `FunctionTool`s. `SemanticaSessionService` implements ADK session storage on top of a Semantica `ContextGraph`, so session state, events, and knowledge graph data can live in the same graph instead of keeping sessions in memory. There were also a number of dependency and CI fixes needed to get the integration working reliably. `google-adk` is pinned to a range that avoids the CI `websockets` conflict, the deprecated `pinecone-client` dependency was replaced with `pinecone`, Windows-only dependencies now have the appropriate platform markers, and `requirements-ci.txt` was regenerated to match. A `pip-audit` pass also required updates to `google-adk` and `starlette` for known CVEs. Some unrelated `pyproject.toml` changes had slipped in during rebases, so the previous version, dependency bounds, `ingest-sap`/LangChain entries, and package-data settings were restored. A few bugs in the initial ADK implementation were fixed during review: * `extract_relations()` was calling `RelationExtractor.extract_entities()`, which doesn't exist on that extractor. The failure was being caught and returned in the tool's `error` field, leaving callers with an empty relation list. It now calls the correct extraction path. * The repo's top-level `mcp/` package shadowed the third-party `mcp` package imported by `google.adk`, causing `google.adk` imports to fail from a normal repo checkout. The local package was moved to `semantica_mcp/mcp/`. The MCP move needed a follow-up as well. `semantica/cli.py` and four existing tests were still importing from `mcp.*`, and the modules under `semantica_mcp/mcp/` still used the old absolute imports internally. `semantica_mcp` was also missing from the setuptools package include list and had no `__init__.py`, so it wouldn't have been included in an installed package. Those imports and packaging settings are fixed now. The session service and ADK tools also had a few other problems: * `list_sessions()` returned a plain list instead of ADK's `ListSessionsResponse`. The original import for that type doesn't work against the installed `google-adk` package, so it was silently falling back to a stub. `user_id` was also incorrectly required instead of being optional. * Session node IDs were built by joining `app_name`, `user_id`, and `session_id` with unescaped colons, which allowed different identities to produce the same graph node ID. Each component is now encoded before joining. * `kg_tools.py` and `decision_tools.py` each had their own lock registry and default graph instance. Sharing a graph between the two modules therefore didn't share the lock, and using both factories without an explicit graph produced two different defaults. The shared state now lives in one module used by both. * `add_to_graph` had a `TypeError` compatibility fallback that couldn't succeed with the current `RelationExtractor` API and could hide the original extraction error. That fallback was removed. * `append_event` persisted partial streaming events even though ADK's base session service skips them. * `get_session()` ignored its `config` argument, so `num_recent_events` and `after_timestamp` had no effect. * The async session-service methods performed synchronous graph scans while holding a `threading.RLock` on the event loop thread. That work now runs in worker threads with `asyncio.to_thread()` so a slow or contended graph operation doesn't block the loop. --- Co-authored-by: Zohaib Hassnain [109234410+ZohaibHassan16@users.noreply.github.com](mailto:109234410+ZohaibHassan16@users.noreply.github.com)
Semantica Google ADK Integration
Google ADK integration for Semantica.
This integration provides:
- Google ADK
FunctionToolwrappers for Semantica's knowledge graph - Decision recording and querying tools
- A graph-backed Google ADK
BaseSessionService - Shared
ContextGraphstate across ADK agents and sub-agents
Google ADK is an optional dependency.
Installation
Install Semantica with the Google ADK integration:
pip install semantica[google-adk]
Or install Google ADK separately:
pip install google-adk
Knowledge Graph Tools
Create a shared ContextGraph and expose it through ADK tools:
from google.adk.agents import Agent
from semantica.context import ContextGraph
from integrations.google_adk import semantica_kg_tools
graph = ContextGraph()
agent = Agent(
name="researcher",
model="gemini-2.0-flash",
tools=semantica_kg_tools(graph),
)
The tool factory provides:
extract_entitiesextract_relationsadd_to_shared_graphquery_shared_graph
The graph passed to semantica_kg_tools() is shared by all returned tools.
Decision Tools
Decision intelligence can use the same graph:
from integrations.google_adk import semantica_decision_tools
decision_tools = semantica_decision_tools(graph)
agent = Agent(
name="decision_agent",
model="gemini-2.0-flash",
tools=decision_tools,
)
The returned tools provide:
record_shared_decisionquery_shared_decisions
This allows decisions made by one agent to be queried later by another agent using the same ContextGraph.
Combining Knowledge and Decision Tools
Both tool groups can be supplied to the same ADK agent:
from google.adk.agents import Agent
from semantica.context import ContextGraph
from integrations.google_adk import (
semantica_kg_tools,
semantica_decision_tools,
)
graph = ContextGraph()
tools = (
semantica_kg_tools(graph)
+ semantica_decision_tools(graph)
)
agent = Agent(
name="researcher",
model="gemini-2.0-flash",
tools=tools,
)
This gives the agent access to both the shared knowledge graph and decision history.
Graph-Backed Session Service
SemanticaSessionService implements Google ADK's session service interface while storing session information in a Semantica ContextGraph.
from semantica.context import ContextGraph
from integrations.google_adk import SemanticaSessionService
graph = ContextGraph()
session_service = SemanticaSessionService(graph)
The same graph can be shared with the KG and decision tools:
from google.adk.agents import Agent
from semantica.context import ContextGraph
from integrations.google_adk import (
SemanticaSessionService,
semantica_kg_tools,
semantica_decision_tools,
)
graph = ContextGraph()
session_service = SemanticaSessionService(graph)
tools = (
semantica_kg_tools(graph)
+ semantica_decision_tools(graph)
)
agent = Agent(
name="researcher",
model="gemini-2.0-flash",
tools=tools,
)
Session information and tool-generated knowledge can therefore share the same graph-backed context store.
Optional Dependency
Importing the integration does not require Google ADK to be installed:
from integrations.google_adk import ADK_AVAILABLE
print(ADK_AVAILABLE)
If Google ADK is unavailable, attempting to construct ADK-specific tools or the session service raises an informative ImportError.
Shared ContextGraph
A major purpose of this integration is allowing multiple ADK agents or sub-agents to share one Semantica graph:
ContextGraph
|
+--------------+--------------+
| | |
Researcher Planner Reviewer
Agent Agent Agent
| | |
+--------------+--------------+
|
Shared knowledge
+ decisions
+ session state
This makes information extracted during an earlier stage of an agent workflow available to later stages without requiring the information to be extracted again.
Example Workflow
from google.adk.agents import SequentialAgent, Agent
from semantica.context import ContextGraph
from integrations.google_adk import (
semantica_kg_tools,
semantica_decision_tools,
)
graph = ContextGraph()
researcher = Agent(
name="researcher",
model="gemini-2.0-flash",
tools=semantica_kg_tools(graph),
)
planner = Agent(
name="planner",
model="gemini-2.0-flash",
tools=(
semantica_kg_tools(graph)
+ semantica_decision_tools(graph)
),
)
workflow = SequentialAgent(
name="research_workflow",
sub_agents=[
researcher,
planner,
],
)
The researcher can add entities and relationships to the graph. The planner can then query the same graph and record decisions against it.
API
semantica_kg_tools(graph=None)
Returns Google ADK FunctionTool instances for Semantica knowledge graph operations.
semantica_decision_tools(graph=None)
Returns Google ADK FunctionTool instances for recording and querying decisions.
SemanticaSessionService(graph=None)
Creates a Google ADK-compatible session service backed by a Semantica ContextGraph.
ADK_AVAILABLE
Boolean indicating whether Google ADK is installed.
__version__
Version of the Semantica Google ADK integration.
Development
Run the Google ADK integration tests with:
pytest tests/integrations/google_adk -v
Tests that require Google ADK should use:
import pytest
pytest.importorskip("google.adk")
This keeps the integration optional for environments that do not install Google ADK.
License
This integration follows the license of the Semantica project.