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
Option C: Azure PowerShell

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

AI & tools

Per-user data (partitioned by /email)

Flow execution & human input (TTL-enabled)

Assignments

Integrations & operations

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).