Overview
Theagent_connections table manages connections between agents in a workflow. Each connection represents a data flow or relationship from a source agent to a target agent.
Table Schema
Unique identifier for the connection record (auto-generated UUID)
Foreign key reference to the authenticated user
Foreign key reference to the workflow this connection belongs to. Must be a valid UUID.
ID of the source workflow element where the connection originates
ID of the target workflow element where the connection terminates
ISO 8601 timestamp of when the connection was created
ISO 8601 timestamp of the last connection update
TypeScript Interface
CRUD Operations
Get All Connections
Retrieves all connections for the authenticated user. Endpoint:manage-connections (GET)
Request: GET request with Authorization header
Response:
Create Connection
Creates a new connection between two workflow elements. Uses upsert to prevent duplicates. Endpoint:manage-connections (POST)
Request:
Delete Connection
Removes a connection between two workflow elements. Endpoint:manage-connections (DELETE)
Request:
Validation Rules
UUID Validation
Theworkflow_id must be a valid UUID format. The system validates using this regex pattern:
Self-Connection Prevention
Connections cannot be created wheresource_element_id equals target_element_id. The system rejects such attempts with an error.
Relationships
- user_id → References the authenticated user’s ID
- workflow_id → References a workflow in the
user_workflowstable - source_element_id → References an element ID in the workflow’s elements array
- target_element_id → References an element ID in the workflow’s elements array
Constraints
- Unique constraint: The combination of
workflow_id,source_element_id, andtarget_element_idmust be unique (enforced by upsert withonConflict: 'workflow_id,source_element_id,target_element_id') - Self-connections are not allowed (
source_element_id≠target_element_id) - The
workflow_idmust be a valid UUID - All three identifiers (
workflow_id,source_element_id,target_element_id) are required
Usage Notes
- Connections define the data flow and execution order in a workflow
- The upsert operation prevents duplicate connections from being created
- When deleting a workflow element, associated connections should also be removed
- Connections are stored separately from the workflow data structure for better normalization and query performance
- The system automatically updates the
updated_attimestamp on upsert operations