Skip to content
Get started

Attach a memory layer to a variation

client.Agents.Variations.AddMemoryLayer(ctx, workspaceID, agentID, variationID, body) (*VariationMemoryLayerAssignment, error)
POST/v1/workspaces/{workspaceId}/agents/{agentId}/variations/{variationId}/memory_layer_assignments

Attaches a memory layer to a variation at a given position in the variation’s baseline memory stack.

ParametersExpand Collapse
workspaceID string
agentID string
variationID string
body AgentVariationAddMemoryLayerParams
MemoryLayerID param.Field[string]Optional

Layer to attach. Accepts the canonical memlyr_… form or the external_id:<value> form.

Position param.Field[int64]Optional

Position in the stack. If omitted, server appends (max existing position + 1).

formatint32
ReturnsExpand Collapse
type VariationMemoryLayerAssignment struct{…}

VariationMemoryLayerAssignment attaches a single MemoryLayer to a variation at a given position in the variation’s baseline memory stack. A variation has at most one assignment per memory_layer_id.

Variations only support whole-layer attachments — entry pinning is an objective-level capability.

ID stringOptional

Assignment row id — handle for removing the assignment. Distinct from the referenced memory layer’s id.

MemoryLayer BareMetadataOptional

BareMetadata contains the minimal metadata for a resource: the ID and an optional human-readable name. These are used for reference fields where the full metadata (account scoping, timestamps, labels, external IDs) is not needed — e.g., the tool references inside an agent variation spec or the tools assigned to an objective. Both fields are server-populated; clients provide IDs through sibling fields rather than by constructing a BareMetadata themselves.

ID stringOptional
Name stringOptional

Human-readable name of the referenced resource, populated by the server on reads for convenience. Absent on references to resources that do not have a name (e.g., objective tasks).

Position int64Optional

Position in the variation’s baseline stack. Lower values sit lower; the highest-position assignment is on top of the variation’s baseline. Gaps are fine — only relative position matters. Positions must be unique within a variation; a request that would collide with an existing assignment’s position is rejected with InvalidArgument.

formatint32

Attach a memory layer to a variation

package main

import (
  "context"
  "fmt"

  "github.com/cadenya/cadenya-go"
  "github.com/cadenya/cadenya-go/option"
)

func main() {
  client := cadenya.NewClient(
    option.WithAPIKey("My API Key"),
  )
  variationMemoryLayerAssignment, err := client.Agents.Variations.AddMemoryLayer(
    context.TODO(),
    "workspaceId",
    "agentId",
    "variationId",
    cadenya.AgentVariationAddMemoryLayerParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", variationMemoryLayerAssignment.ID)
}
{
  "id": "id",
  "memoryLayer": {
    "id": "id",
    "name": "name"
  },
  "position": 0
}
Returns Examples
{
  "id": "id",
  "memoryLayer": {
    "id": "id",
    "name": "name"
  },
  "position": 0
}