Overview
The/prompt endpoint records user prompts in a session and optionally returns relevant context from past observations. It supports automatic context injection based on topic changes and first-prompt detection.
Authentication
This endpoint requires a valid authentication token if configured:Request
Unique identifier for the AI conversation session.
The user’s prompt text. Empty or whitespace-only prompts are skipped.
Project identifier for scoping context retrieval.
Working directory path for the session.
Whether to retrieve and return relevant context from past observations.
Response
Always returns
"ok" for valid requests.Formatted context block to inject into the prompt (only when
with_context: true).Whether context should be automatically injected into the prompt.
Reason for context decision:
"disabled": Auto-context is disabled in config"fts": Context retrieved via full-text search"recency": Context retrieved by recency"empty": No relevant context found"quarantined": Context blocked by safety filters"same_topic": Topic unchanged, no new context needed"timeout": Context retrieval exceeded timeout"error": Context retrieval failed
Number of observations included in the context.
Size of the context block in bytes.
Whether a topic change was detected (only for non-first prompts).
Error message if the request failed.
Example
Without Context
With Context (First Prompt)
With Context (Topic Change)
Auto-Context Behavior
Whenwith_context: true and autoContext.enabled: true in config:
- First Prompt: Always attempts to inject session primer with recent observations
- Subsequent Prompts: Injects context only if topic change detected
- Vague Prompts: Falls back to recency-based retrieval instead of search
- Safety: Blocks context containing high-risk patterns or secrets
- Timeout: Returns
nullcontext if retrieval exceedsautoContext.timeoutMs
Status Codes
- 200 OK: Prompt recorded successfully
- 401 Unauthorized: Missing or invalid authentication token
- 500 Internal Server Error: Failed to get or create session
Use Cases
- Record user prompts for session history
- Retrieve relevant context from past work
- Enable topic-aware context injection
- Build session primers for new conversations
- Track prompt patterns across projects