Python extension APIs
Extensions use the runtime context for plugin settings, models, and clients. See the tool guide for a minimal implementation.
Tool runtime context (AgentContext)
Access through runtime.context.
| Member | Meaning |
|---|---|
get_model(name=None) |
Configured model, default dataagent.model; unknown aliases raise ValueError |
semantic_client |
Configured client or None |
session.outputs |
Current session output directory |
home |
Resolved Home for shared resources |
get_plugin_config(plugin_id) |
Copy of effective plugin config. Disabled plugins raise ValueError |
get_plugin_state(plugin_id) |
Private in-memory dictionary for an enabled plugin within the session graph. Not checkpointed; plugin owns concurrency |
Model streams and compiled subagent factories
| Name | Purpose |
|---|---|
collect_model_stream(model, messages, **kwargs) |
Stream and collect a complete model message, retaining tool calls, reasoning, and usage |
SubagentServices |
Compiled factory services get_model, semantic_client, outputs_dir, and run_hooks |
SemanticLayer client
Import SemanticServiceClient from dataagent. It is a standalone synchronous HTTP client, separate from the host and low-level graph APIs. For connection setup, certificates, and natural-language verification, see SemanticLayer integration.
Construction and ownership
| Usage | Creation and cleanup |
|---|---|
| REST Server | Creates one shared client from semantic for the process lifespan, injects it into each Agent's AgentContext, and owns cleanup |
create_agent(runtime) |
The SDK creates a client when semantic is configured and no semantic_client is supplied; Agent.close() / aclose() closes it |
create_agent(runtime, semantic_client=client) |
Borrows the caller's client; closing the Agent leaves it open. The caller owns cleanup |
runtime.context.semantic_client in a tool |
Borrows the host client, or is None when unconfigured. The tool does not create or close it |
SemanticServiceClient.from_settings(runtime.settings.semantic) or direct construction |
The caller owns close(), or uses a with block |
from_settings accepts resolved SemanticSettings and uses its URL, Basic authentication, timeout, TLS, and scenario settings. Direct SemanticServiceClient(base_url, ...) construction enables server certificate verification by default (verify=True); from_settings follows the configured tls policy.
Configuration tls.verify_server defaults to false. Without a client certificate or ciphers, verification stays disabled. When true, the default SSL context is used, or the CA from ca_file when supplied. Provide client_cert and client_key together. Nonempty ciphers is passed to SSLContext.set_ciphers. See semantic configuration for field constraints.
The client uses synchronous httpx.Client. Offload async tool calls with asyncio.to_thread to avoid blocking the event loop. The owning client's close() rejects new requests and waits for synchronous requests in flight before closing its pool. Diagnostics redact Basic credentials and their Base64 representation; logs should not print raw secrets.
Methods and routes
Paths use the /api/semantic/v1/ prefix. Retrieval-table endpoints inspect the semantic service's own metadata tables; business-table endpoints inspect tables and columns in connected business databases.
| Method | HTTP method and route suffix |
|---|---|
semantic_retrieve |
POST semantic/retrieve |
get_table_list |
GET advanced-search/table-list |
get_table_columns_info |
GET advanced-search/table-columns-info |
get_columns_sample_values |
GET advanced-search/column-value-info |
semantic_search_columns |
GET advanced-search/semantic-search-columns |
get_joinable_tables |
GET advanced-search/joinable-tables |
get_table_relations_path |
GET advanced-search/table-relations-path |
vector_search_table_desc |
GET advanced-search/vector-search-table-desc |
vector_search_column_value |
GET advanced-search/vector-search-column-value |
sql_few_shots |
GET advanced-search/sql-few-shots |
search_fulltext |
GET search/fulltext |
search_basic |
POST search/basic, with search criteria |
search_dsl |
GET search/dsl |
search_entities(type_name, *, limit=200, offset=0) |
GET search/basic, paginated enumeration by type |
get_entity_by_guid |
GET entity/guid/{guid} |
get_entity_by_unique_attribute |
GET entity/uniqueAttribute/type/{type_name} |
list_retrieval_tables |
GET retrieval/tables, the semantic retrieval-table list |
get_retrieval_table_schema |
GET retrieval/tables/{table}/schema, a retrieval-table schema |
hybrid_table_columns(tables) |
POST hybrid/table-columns, physical columns for business tables in bulk |
Parameter conventions
Positional arguments go from broad to narrow, such as database, table, and keywords or query. Counts use keyword limit, sent as topK or limit according to the endpoint. max_depth and sample_count are also keyword-only.
Column identifiers use db.table.column. In get_columns_sample_values(column_ids, *, sample_count=3), sample_count ranges from 0 to 100. search_entities requires limit from 1 to 200 and a nonnegative offset, and returns a list of entities.
semantic_retrieve(query, *, db_name=None, evidence=None) accepts natural-language input. Supplying the optional arguments adds db_name and evidence to the request body; omitting them retains the service's default retrieval workflow. POST criteria through search_basic and GET enumeration through search_entities are distinct operations.
Scenario views
Configured semantic_scenario, or scenario= during direct construction, sets X-Semantic-Scenario on requests except health. with_scenario(scenario) returns a client view sharing the same connection pool with a different header value.
Closing a view does not close the pool. The original owning client still owns cleanup and waits for requests made through its views. Reuse the existing client without creating a connection for each scenario.
Data access and SQL validation
| Name | Purpose |
|---|---|
MCPConfig, MCPInfrastructureError |
SQL-over-MCP connection type and infrastructure error. See MCP SQL |
build_sql_service, check_engine_driver, check_read_only_sql, check_sql |
Data gateway services and validation |
recall_database, RecallOptions, RecallError |
Async SQLite exploration and its options and errors |