context_length_exceeded. Piramyd’s context compaction feature solves this transparently: when your conversation approaches the limit, the API automatically summarizes older messages into a structured summary and retries the request, so your application never sees the error.
How It Works
To enable context compaction, include athread_id (or its alias conversation_id) in every request that belongs to the same conversation:
thread_id is present, Piramyd handles the rest automatically:
- Detection — if the accumulated messages would produce a
context_length_exceedederror, the API intercepts it before returning it to your client. - Compaction — older messages are summarized into a structured block covering:
- Goals — what the user is trying to achieve
- Plans — approaches agreed upon or in progress
- Decisions — choices made during the conversation
- Files — any files referenced or created
- Tool state — previous tool call results relevant to ongoing tasks
- Blockers — unresolved issues or open questions
- Preservation — system messages are kept intact and verbatim. The most recent messages are also preserved without modification, ensuring the model has full fidelity on the immediate context.
- Retry — the compacted history is used to transparently retry the original request. Your client receives the response as if no compaction occurred.
- Checkpointing — compaction state is persisted in Redis. On subsequent requests in the same thread, the API proactively applies compaction if a checkpoint exists, rather than waiting for the context window to overflow.
Using thread_id in a Request
Manual Compaction
If you want to trigger compaction explicitly — for example, to pre-compact a long conversation before starting a new leg of work — use the manual compaction endpoint:messages array in the request body; the response returns the compacted history you can drop directly into your next request.
Request
compacted_messages as the messages array in your next request.
System One models do not support context compaction. System One (e.g.
jev-latest) has a hard 64,000-token limit per request covering the state and all questions. There is no automatic compaction for System One requests — if your input exceeds the limit, you will receive a 413 context_too_large error. Reduce the size of the state field instead.