Skip to main content

Cosmos DB TTL for Ephemeral Prompts

Findable’s flow designer creates ephemeral prompt templates in the prompts container when human input nodes execute. These are short-lived documents (prefixed eph-) that are automatically cleaned up through three mechanisms:
  1. Active deletion — The orchestrator deletes the prompt immediately after receiving a response.
  2. Periodic sweep — A background job (/server/jobs/ephemeral-cleanup) runs every 6 hours to catch any that were missed.
  3. Cosmos DB TTL — Each ephemeral prompt sets a _ttl field (in seconds). Cosmos DB will auto-delete expired documents if TTL is enabled on the container.

Enabling TTL on the Prompts Container

For new deployments, TTL is configured automatically — the server passes defaultTtl: -1 when creating the prompts container via createIfNotExists. For existing deployments where the prompts container already exists, createIfNotExists will not update the container’s TTL setting. You must enable it manually:
Option A: Azure Portal
  1. Navigate to your Cosmos DB account in the Azure Portal
  2. Open Data Explorer
  3. Expand your database and select the prompts container
  4. Click Settings (or Scale & Settings)
  5. Under Time to Live, select On (no default)
    • This sets defaultTtl = -1, which means “no container-wide expiry, but honour per-item _ttl values”
  6. Click Save
Option B: Azure CLI
az cosmosdb sql container update \
  --account-name <your-cosmos-account> \
  --database-name <your-database-name> \
  --name prompts \
  --resource-group <your-resource-group> \
  --ttl -1
Option C: Azure PowerShell
Update-AzCosmosDBSqlContainer `
  -AccountName <your-cosmos-account> `
  -DatabaseName <your-database-name> `
  -Name prompts `
  -ResourceGroupName <your-resource-group> `
  -TtlInSeconds -1

Verifying TTL is Active

After enabling, you can verify in the Portal by checking that the container’s Time to Live setting shows On (no default). New ephemeral prompts will then be auto-deleted by Cosmos DB after their _ttl expires (typically 1 hour).
Note: Even without TTL enabled, ephemeral prompts are still cleaned up by the active deletion and periodic sweep mechanisms. TTL is a defense-in-depth measure for edge cases like server crashes or flow timeouts.

Cosmos DB Container Reference

Containers are grouped by purpose. Partition keys are chosen to match the dominant query pattern: /id for shared/global resources, /email for per-user data, and purpose-specific keys (/executionId, /flowId, /assigneeEmail, /createdBy) where reads are scoped to a particular execution, flow, or owner.

Core & content library

ContainerPartition KeyDescription
settings/idApplication-wide settings (single "default" document)
chat/idChat tab configurations (IChatTabDBItem) — data source, AI options, ACL
prompts/idPrompt templates and groups (per-item TTL for ephemeral prompts)
flows/idFlow Designer flow definitions and flow groups
pages/idNavigation pages (hierarchical via parentPageId)

AI & tools

ContainerPartition KeyDescription
aimodelendpoints/idAI model endpoints (Azure OpenAI, OpenAI, Anthropic, Gemini, etc.)
aisearchendpoints/idAzure AI Search endpoint configurations
aitoolproviders/idTool provider configs (Tavily, SQL, Cosmos, Exchange, OneDrive, etc.)
mcpservers/idMCP server registry entries
datasources/idDatasource catalog entries
dataconnections/idSQL/database connection configs for NL-SQL

Per-user data (partitioned by /email)

ContainerPartition KeyDescription
chatlog/emailConversation history — every message exchange with timestamps and citations
feedback/emailUser feedback (thumbs up/down) on AI responses
usersettings/emailPer-user settings (language, drawer state, AI defaults, memory preferences)
userfavorites/emailUser-bookmarked prompts, flows, and chats
usertheme/emailPer-user Material UI theme preferences
usernotifications/emailIn-app notifications for human-in-the-loop workflows
usernotificationpreferences/emailNotification channel preferences (email, Teams, Slack, SMS)
datasourcelastaccessed/emailPer-user data source activity (used by purge job)
onedrivelastaccessed/emailPer-user OneDrive activity (used by purge job)
userrecommendations/emailCached recommendations doc (singleton per user)
recommendationfeedback/emailPer-user feedback on recommendations
recommendationsaved/emailRecommendations saved into the user’s prompt library

Flow execution & human input (TTL-enabled)

ContainerPartition KeyDescription
humaninput/executionIdActive human-input requests awaiting response (per-item TTL)
flowcheckpoints/executionIdFlow execution checkpoints for resume (per-item TTL)
flowexecutions/flowIdFlow execution runs — “show runs for this flow” (per-item TTL)
flowexecutionsteps/executionIdPer-step execution trace (per-item TTL)

Assignments

ContainerPartition KeyDescription
assignments/assigneeEmailPer-assignee obligations — pushed chats/flows with completion tracking, deadlines, and delegation
assignmentschedules/createdByRecurring assignment templates owned by their creator

Integrations & operations

ContainerPartition KeyDescription
sharepointentitlements/idSharePoint per-user entitlement registry
teamsappicons/idCached Teams app icons
teamsconversationreferences/idTeams conversation references for proactive messaging
jobs/idPeriodic-job throttle records (sweep, cleanup, purge)
Partition-key strategy. /id is the default for shared/global resources where queries are by document ID. /email is used for user-scoped data so each user’s documents land in a single partition for cheap inbox-style reads. /executionId colocates everything related to a single flow run. /flowId colocates execution runs by flow. /assigneeEmail mirrors the /email pattern for assignment inboxes. /createdBy mirrors it for owner-scoped recurring schedules. TTL behaviour. TTL-enabled containers set defaultTtl: -1 so Cosmos honours per-item _ttl values without applying a container-wide expiry. Items written without _ttl live forever; ephemeral items (e.g. unresolved human-input requests, ephemeral prompts) set _ttl and are auto-deleted by Cosmos after expiry. A periodic sweep (ephemeralcleanup, humaninputcleanup, assignmentsweep) provides a defence-in-depth fallback in case TTL is disabled at the container level (which can happen when createIfNotExists is called against a pre-existing container that was created without TTL).