Fency.ai
Sessions

Guardrails

Control which memories an agent can access for a task.

guardRails control which memories an agent can access. Your server sets them when creating a createAgentTask session. The React SDK only receives a clientToken and cannot expand the rails.

How guardRails apply per task type:

Task typeguardRails
EXPLORE_MEMORIESRequired. Both METADATA and SEMANTIC memory types are supported.
MEMORY_CHATRequired. Only SEMANTIC memory types are supported.
MEMORY_SEARCHRequired. Only SEMANTIC memory types are supported.
EXPLORE_PRODUCTOptional. Set them when the agent should perform semantic search on memories. The memory types used must be of type SEMANTIC.
STREAMING_CHAT_COMPLETIONNot supported
STRUCTURED_CHAT_COMPLETIONNot supported

How they work

Set guardRails.memoryTypes to a list of memory types the agent may see. Each entry uses exactly one scope. Combining scopes on the same entry is rejected by the API.

ScopeWhat the agent can access
matchMemories of that type whose metadata matches the filter
memoryIdsOnly the listed memories of that type
includeAllEvery memory of that type

You can list several memory types in one session. Each entry has its own scope.

Metadata overrides

Each memory type entry can include a metadata array that overrides the stored meta-key schema for that session only:

  • visible: whether the agent can see that key.
  • description: the description the agent gets for that key, overriding the stored one.

Each entry needs a key plus at least one of visible or description.

Examples

match

{
    createAgentTask: {
        taskType: 'EXPLORE_MEMORIES',
        guardRails: {
            memoryTypes: [
                {
                    memoryTypeId: 'mty_...',
                    match: { organization_id: 'org_...' },
                    metadata: [
                        {
                            key: 'renewal_date',
                            visible: true,
                            description: 'ISO-8601 date the contract auto-renews',
                        },
                        {
                            key: 'internal_notes',
                            visible: false,
                        },
                    ],
                },
            ],
        },
    },
}

memoryIds

{
    createAgentTask: {
        taskType: 'MEMORY_CHAT',
        guardRails: {
            memoryTypes: [
                {
                    memoryTypeId: 'mty_...',
                    memoryIds: ['mem_...', 'mem_...'],
                    metadata: [
                        {
                            key: 'renewal_date',
                            visible: true,
                            description: 'ISO-8601 date the contract auto-renews',
                        },
                    ],
                },
            ],
        },
    },
}

includeAll

{
    createAgentTask: {
        taskType: 'MEMORY_SEARCH',
        guardRails: {
            memoryTypes: [
                {
                    memoryTypeId: 'mty_...',
                    includeAll: true,
                },
            ],
        },
    },
}

See Sessions for full request bodies per task type, and Explore memories for a complete server route.

On this page