Database Models
Auto-generated from source on
2026-10-30 15:00 UTC. Do not edit manually — runmake specto regenerate.
SQLAlchemy ORM models — modules/svc-ai/app/db/postgres/models.py.
Provider
A registered LLM provider (e.g. OpenAI, Anthropic). Stores connectivity config and enabled/disabled state.
Table:
providersMixins:
DateMixin.Updated
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | Enum | No | ||
display_name | String | No | ||
is_default | Boolean | No | ||
base_url | String | Yes | ||
is_enabled | Boolean | No | ||
config | JSON | Yes |
Relationships
models→LLMModel
LLMModel
A specific model offered by a provider. Stores capability flags, token limits, pricing, and default config.
Table:
llm_modelsMixins:
FKMixin.Provider.Child,DateMixin.Updated
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
model_name | String | No | ||
display_name | String | Yes | ||
description | Text | Yes | ||
is_default | Boolean | No | ||
is_recommended | Boolean | No | ||
is_chat | Boolean | No | ||
is_embedding | Boolean | No | ||
is_vision | Boolean | No | ||
is_available | Boolean | No | ||
context_window | Integer | Yes | ||
max_output_tokens | Integer | Yes | ||
input_cost_per_token | Numeric | Yes | ||
output_cost_per_token | Numeric | Yes | ||
cache_read_cost_per_token | Numeric | Yes | ||
cache_write_cost_per_token | Numeric | Yes | ||
cache_write_1h_cost_per_token | Numeric | Yes | ||
long_context_threshold | Integer | Yes | ||
long_context_input_multiplier | Numeric | Yes | ||
long_context_output_multiplier | Numeric | Yes | ||
data_region | Enum | Yes | ||
effort | Enum | Yes | ||
latency | Enum | Yes | ||
knowledge_cutoff | Date | Yes | ||
config | JSON | Yes | ||
archived_at | DateTime | Yes |
Relationships
provider→Providerconversations→Conversationinvocations→LLMInvocation
Conversation
A multi-turn LLM conversation session.
userid is the requesting user from svc-core — stored as plain text, no FK constraint. externalagent_id optionally links to a svc-core Agent; again no FK constraint.
Table:
conversationsMixins:
FKMixin.LLMModel.NullableChild,DateMixin.Updated
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
user_id | Text | No | ||
external_agent_id | UUID | Yes | ||
title | String | Yes | ||
total_input_tokens | Integer | No | ||
total_output_tokens | Integer | No | ||
total_tokens | Integer | No |
Relationships
model→LLMModelmessages→ChatMessage
ChatMessage
A single message within a Conversation. token_count is stored per-message for accurate billing and context management.
Table:
chat_messagesMixins:
FKMixin.Conversation.Child,DateMixin.Sent
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
role | Enum | No | ||
content | Text | No | ||
token_count | Integer | No |
Relationships
conversation→Conversation
LLMInvocation
One traced invocation — an execution, a resumed segment of one, or a platform flow — and the model calls it made. Tracks token usage, latency, cost, and outcome for observability and billing. conversation_id is a soft cross-service reference to svc-core's conversations.id (no FK constraint).
`provider / model_name name the model the request asked for (an agent's or a prompt's configured model, a generation flow's model), or the one model every call used when the request named none. They are stored as text so the row says which model it was even when the catalogue does not list it, or no longer does; model_id is the catalogue link when there is one. Null only when the calls used several models and the request named none — calls` says exactly which did what, one row per model call.
Table:
llm_invocationsMixins:
FKMixin.LLMModel.NullableChild,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
conversation_id | UUID | Yes | ||
user_id | UUID | Yes | ||
workspace | String | Yes | ||
core_invocation_id | UUID | Yes | ||
purpose | String | Yes | ||
output_preview | Text | Yes | ||
prompt_tokens | Integer | No | ||
completion_tokens | Integer | No | ||
total_tokens | Integer | No | ||
latency_ms | Integer | Yes | ||
status | Enum | No | ||
error_detail | Text | Yes | ||
request_config | JSON | Yes | ||
estimated_cost_usd | Numeric | Yes | ||
provider | String | Yes | ||
model_name | String | Yes |
Relationships
model→LLMModelcalls→LLMInvocationCall
LLMInvocationCall
One model call within a traced invocation, as the usage meter saw it.
Recorded where the call happened, against the model that was actually built for it — so a graph run whose system nodes run on one model and whose skill nodes pin others says which node called which model, and a retry or a runtime fallback shows the attempt that failed as well as the one that answered. `provider / model_name are required — every call site names the model it built, and the meter logs one that does not; model_id` is the catalogue link when the model is listed.
`estimated_cost_usd` is None when the call could not be priced (or failed), never zero for "unknown".
Table:
llm_invocation_callsMixins:
FKMixin.LLMModel.NullableChild,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
invocation_id | UUID | No | ||
sequence | Integer | No | ||
provider | String | No | ||
model_name | String | No | ||
kind | String | No | ||
node | String | Yes | ||
step | String | Yes | ||
pass_index | SmallInteger | Yes | ||
prompt_tokens | Integer | No | ||
completion_tokens | Integer | No | ||
cache_read_tokens | Integer | No | ||
cache_write_tokens | Integer | No | ||
reasoning_tokens | Integer | No | ||
latency_ms | Integer | Yes | ||
status | Enum | No | ||
error_detail | Text | Yes | ||
estimated_cost_usd | Numeric | Yes | ||
pricing | JSON | Yes |
Relationships
invocation→LLMInvocation
ToolInvocation
A single tool call made during an agent execution.
Records the tool name, input arguments, raw output, execution outcome, and latency — the primary data source for tool observability and debugging.
conversation_id is a soft cross-service reference to svc-core's conversations.id (no FK constraint).
executioncontext captures free-form metadata about the execution that produced this call (e.g. skillid, graph node name, agent name) so invocations can be grouped or filtered by workflow.
Table:
tool_invocationsMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
conversation_id | UUID | Yes | ||
user_id | UUID | Yes | ||
workspace | String | Yes | ||
core_invocation_id | UUID | Yes | ||
tool_name | String | No | ||
input_args | JSON | Yes | ||
raw_output | Text | Yes | ||
latency_ms | Integer | Yes | ||
status | Enum | No | ||
error_detail | Text | Yes | ||
execution_context | JSON | Yes | ||
report | JSON | Yes |
Relationships
citations→ToolCitation
ToolCitation
A single source citation extracted from a ToolInvocation's output.
Each citation captures the tool that produced it, the raw source reference (URL or document name), a human-readable title, and an ordinal index that preserves the order in which sources appeared in the tool response.
source_type distinguishes URLs (clickable links) from knowledge-base documents (filename references) and other custom citation kinds, allowing the frontend to render each type appropriately.
collection is only populated for queryknowledgebase invocations and records which RAG collection the document was retrieved from.
Table:
tool_citationsMixins:
FKMixin.ToolInvocation.Child
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
index | Integer | No | ||
source_type | Enum | No | ||
source | Text | No | ||
title | Text | No | ||
collection | String | Yes | ||
relevance_score | Float | Yes |
Relationships
invocation→ToolInvocation
WorkerAgentDefinition
A reusable worker agent definition — the building block for skill graphs.
Definitions describe an agent's role, system prompt, default model, and default tools. They are referenced by name in skill graphdefinitions so that graphs stay lightweight (no embedded configs) while remaining fully customisable via configoverrides at the node level.
is_builtin=True entries are seeded on startup and should not be deleted by regular users.
Table:
worker_agent_definitionsMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
display_name | String | No | ||
description | Text | No | ||
role | Enum | No | ||
system_prompt | Text | No | ||
default_model_config | JSON | No | ||
tools_enabled | Boolean | No | ||
mcp_servers | JSON | No | ||
default_tools | JSON | No | ||
input_schema | JSON | No | ||
output_schema | JSON | No | ||
tags | JSON | No | ||
is_builtin | Boolean | No |
AgentMemory
What an agent keeps of one person between conversations — written by memorywrite, recalled by memoryread (`app/memory`).
externalagentid and userid are soft cross-service references to svc-core — no FK constraints so svc-ai remains independently deployable. conversationid links the memory to the conversation that produced it.
`kind is an episode (one turn) or a curated memory (fact, preference, goal) written only from the person's quoted words, kept in evidence`. A corrected memory is superseded rather than deleted, so its history stays readable; recall leaves out superseded and expired rows.
Table:
agent_memoriesMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
external_agent_id | UUID | Yes | ||
user_id | Text | No | ||
conversation_id | UUID | Yes | ||
memory_key | String | No | ||
content | Text | No | ||
created_at | DateTime | No | ||
kind | String | No | ||
evidence | Text | Yes | ||
workspace | String | Yes | ||
embedding | ARRAY | Yes | ||
embedding_key | String | Yes | ||
expires_at | DateTime | Yes | ||
superseded_at | DateTime | Yes | ||
superseded_by | UUID | Yes | ||
confirmed_at | DateTime | Yes | ||
recall_count | Integer | No | ||
last_recalled_at | DateTime | Yes |
SpendCounter
Model spend in one period — a UTC day or calendar month — kept for the deployment's spending ceiling (`app.services.spend_guard`).
One row per period, `day:2026-10-08 or month:2026-10`, incremented by every metered call. The guard keeps the running total in memory and writes here so that a restart does not forget what the day has spent.
Table:
spend_counters
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
cost_usd | Numeric | No | ||
updated_at | DateTime | No |