DocsWork with agents
Context in portable handoffs
For moving a thread to another provider when one hits its limit, see Provider handoff. This page explains how much history travels with it.
Moonfold transfers conversation context when you switch providers, continue through a portable restart, or use a fork that the provider cannot resume itself.
Short conversations transfer intact. For longer conversations, Moonfold favors recent requests and answers, the original request, and relevant activity such as command outcomes. Selected messages keep their full text, order, and user or assistant role, including partial work from failed or interrupted turns. Your new request stays separate and is never shortened to make history fit.
Codex receives historical messages directly when its installed version supports that operation. Other providers receive the same selection as attributed conversation context. A handoff does not copy the outgoing provider's reasoning, tool-call state, or attachments.
The handoff includes references to omitted history. The agent can use Moonfold's thread-reading tool to retrieve saved messages and activity, including the remainder of a long item. For an important constraint, you can still repeat it in your next message. A handoff is a budgeted selection, not an agent-written summary.
Context limits
A handoff must leave room for existing provider context, your request and attachments, instructions, tools, and subsequent work. If even its retrieval references cannot fit, Moonfold reports an error instead of shortening your request. Compact the target conversation or select a larger-context model before trying again.
Server operators can set MOONFOLD_CONTEXT_HANDOFF_TOKEN_CAP to change the
initial history allowance (default 16,000; clamped to 1,024–64,000). This is an upper
bound, not a provider context-window guarantee. Text accounting conservatively charges one
token per UTF-8 byte, including attribution and JSON escaping. Imported history has a
separate 64,000-byte ceiling; your current input and attachment payloads do not consume
that ceiling.
Moonfold uses available capacity information for your selected model and options, together with provider context telemetry. Starting a fresh provider conversation clears prior usage, while keeping known model capacity. Changing models or context-window options discards stale usage and compaction thresholds.
When no capacity information is available, Moonfold assumes a 128,000-token window. It reserves at least 16,000 tokens, or a quarter of the window when larger, for instructions, tools, and subsequent work. Images reserve an estimated 8,192 tokens each, independent of their file size; other attachments reserve 4,096 each for their references. Existing context is estimated from saved activity when usage telemetry is unavailable. Known smaller windows still constrain the handoff. These are fallback estimates, not exact token counts. Image resolution, custom models, and hidden native context can differ, so the provider may still reject an input.