latestOpenAPI 3.1.0raw.githubusercontent.com2026-08-14129143297.4 KB

0e52fe5f8d33

admin

Compact User Context

Synchronously compact a user's currently-visible conversation context.

Use this when a bug or model error has poisoned a user's in-context conversation history (e.g. the agent confidently asserted a wrong fact about its own capabilities) and you want to reset the LLM-facing context without dropping durable user-supplied facts. The OSS admin_compact_visible_messages helper extracts facts into MEMORY.md / USER.md / SOUL.md before advancing the trim watermark, so the next turn starts from a clean slate plus the rewritten memory.

keep_recent preserves the last N visible turns so the user's pending request is not lost when an admin clears stale context mid-conversation. hint is prepended to the compaction LLM's <conversation> block as [admin note: ...] to bias how the LLM reads the messages, which is useful when the exact failure mode is known (e.g. "ignore prior agent claims about being read-only").

Audit-logged via AdminAction.COMPACT_USER_CONTEXT; the resulting compaction_events row is also linked from ctx.detail so a forensic query can join admin action to the compaction outcome.

post/api/admin/users/{user_id}/compact-now

Path parameters

user_idstring required

Request body

keep_recentinteger

Preserve the last N visible messages from compaction so the agent retains immediate context (e.g. a pending user request).

hintstring nullable

Optional steering note prepended inside the compaction LLM's <conversation> block as [admin note: ...]. Use to bias how the LLM reads the conversation, e.g. 'ignore prior agent self-claims about AppFolio capabilities'.

Response

Successful Response

compacted_message_countinteger required
new_watermarkinteger nullable required
memory_updatedboolean required
event_idinteger nullable required
previous_event_idinteger nullable