Workflow Reference Model#
The Reference model is agenta's unified way to address workflows (applications), variants, and environments in API calls. Instead of requiring a UUID everywhere, callers can identify a resource by slug alone, by slug + version, or by id β the server resolves whichever combination is provided.
Core Types#
Three Fern-generated SDK types represent references at different points in the request/response lifecycle:
| Type | File | Direction | Key fields |
|---|---|---|---|
ReferenceRequestModel | sdk/agenta/client/backend/types/reference_request_model.py | Request (inbound) | slug, version (int), commit_message, id |
ReferenceDto | sdk/agenta/client/backend/types/reference_dto.py | Response (outbound) | slug, version (int), commit_message, id |
Reference | sdk/agenta/client/backend/types/reference.py | Response (outbound) | slug, version (str), id, attributes |
ReferenceRequestModel and ReferenceDto are structurally identical (both frozen Pydantic models with extra="allow") . Reference differs in that version is a str rather than int and adds an attributes dict for arbitrary key-value metadata .
The server-side counterpart is ReferenceDTO in api/oss/src/services/variants_manager.py, which adds UUID serialization logic and an encode() helper for nested structures.
Three Reference Roles per API Call#
Every /variants/configs/* endpoint accepts up to three separate reference objects β one per entity type :
application_refβ identifies the app/workflow (byidorslug)variant_refβ identifies the variant (byid, orslug+ optionalversion)environment_refβ identifies the deployment environment (byid, orslug+ optionalversion)
The ConfigResponseModel returned by these endpoints includes all three refs populated with resolved values, plus lifecycle metadata (committed_at, deployed_at, etc.) .
Resolution Logic#
The server uses a dual-strategy lookup :
- By
idβ direct DB lookup, preferred for performance. - By
slug+application_refβ resolves the app first (byidorslug), then resolves the variant/environment within that app. Ifversionis omitted, the latest revision is returned.
Environment resolution differs slightly: version=None always means "latest" for environments, whereas variant resolution requires an explicit flag .
SDK Usage: _ref_or_none and SharedManager#
SharedManager._ref_or_none() is the SDK helper that constructs a ReferenceRequestModel from loose keyword arguments β returning None if all fields are absent. It is called at every SharedManager method boundary before dispatching to the API client .
For example, SharedManager.fetch() accepts variant_slug, variant_version, app_slug, etc. and assembles three reference objects before calling ag.api.variants.configs_fetch() . The same pattern applies to add, commit, fork, deploy, delete, and their async counterparts.
Validation rules enforced by _parse_fetch_request :
variant_slugrequiresapp_idorapp_slugvariant_versionrequiresvariant_slugenvironment_slugrequiresapp_idorapp_slugenvironment_versionrequiresenvironment_slug
Relationship to Other Identifier Systems#
- Slugs are project-scoped, URL-safe strings (
[a-zA-Z0-9_-]+) validated by theSlugDTO mixin . References carry slugs but do not validate them β validation happens at the slug layer. - UUIDs (
id) are globally unique per revision. Preferidwhen performance matters; preferslugfor human-readable scripts and configuration. - The Reference model is not the same as tool execution types (e.g.,
ToolCall,FunctionCall). It is purely an addressing/routing mechanism for workflow and variant resources. - In run-context tracing (
runContext),workflow.id,workflow.slug, andworkflow.versioncorrespond to the same slug/id/version fields but are embedded in the OTel span context rather than passed as Reference objects .
Key Source Files#
| File | Purpose |
|---|---|
sdk/agenta/client/backend/types/reference_request_model.py | SDK request type |
sdk/agenta/client/backend/types/reference_dto.py | SDK response DTO |
sdk/agenta/client/backend/types/reference.py | SDK Reference type with attributes |
sdk/agenta/sdk/managers/shared.py | SharedManager β _ref_or_none, all config operations |
api/oss/src/services/variants_manager.py | Server-side ReferenceDTO, resolution logic |
api/oss/src/routers/variants_router.py | `/configs/add |