Your DeepSeek Harness session works with one model. You select another model through an API gateway, send a short follow-up, and receive MODEL_SWITCH_COMPACTION_FAILED.
The new prompt contains only a few words. The second model answers normally in a fresh conversation. Changing the API key makes no difference.
These observations point toward the conversation being transferred, or the capacity declared for its destination. A working endpoint does not establish that an existing session can move to it unchanged.
The official model-switch compaction upgrade guide describes a preflight check before a changed provider/model request is committed. Missing destination capacity, an invalid pressure budget, or an unsuccessful reduction can block the switch. Even short conversations can fail when the destination budget is invalid. GitHub
This article uses a hypothetical migration to explain the diagnosis. It contains no claimed model benchmark or measured Treerouter performance. Technical references were checked on November 21, 2026; match configuration details to your installed Harness version.
Read the failed transition, not just the final message
Begin with three observations: whether the destination works in a new session, whether the old session still works on its previous model, and whether a destination request actually left the application.
Those observations separate problems that can look identical in the interface.
| Observation | Investigation to prioritize |
|---|---|
| Destination fails even with a new, short conversation | Endpoint, credentials, model identifier, and protocol |
| Destination works fresh but rejects the existing session | Conversation size, request envelope, and destination capacity |
| Failure occurs before a destination request is recorded | Local adapter metadata and compaction policy |
| A separate summary request fails first | Summarization route, credentials, and capacity |
| Destination answers but forgets a requirement | Information preserved during migration |
Use the Harness request-lifecycle guide to locate the relevant stage. Do not infer an upstream outage solely from an error displayed by the client.
Record the exact provider/model pair, package version, and a sanitized error chain. Keep the previous route in the same record. A screenshot showing only the newly selected model can conceal the route that actually failed.
There is also a useful stopping rule: if the destination cannot answer one simple request in a fresh session, pause the history-migration experiment. Fix the basic connection with the model-connection guide, then return to the long conversation.
Calculate the budget with the destination’s numbers
Consider a hypothetical destination with a context window of 65,536 tokens. Suppose the request reserves 8,192 tokens for output, while the compaction policy keeps another 65,536 tokens as headroom.
The arithmetic is already impossible before you count the conversation. Output reservation plus headroom exceeds the entire window.
The current compaction backend reference defines the trigger using the smaller of a window fraction and the capacity remaining after output reservation and headroom: GitHub
trigger = floor(min(window × threshold_ratio,
window − output_reservation − headroom))With the hypothetical values above, the second term is negative. Reducing the follow-up from twenty words to two cannot repair a negative budget.
Here is a local worksheet for checking that arithmetic. It does not tokenize a prompt, contact a model, or edit Harness configuration.
from math import floor
def inspect_budget(window, output_reservation, headroom, ratio):
if window <= 0 or output_reservation < 0 or headroom < 0:
raise ValueError("Invalid capacity input")
if not 0 < ratio < 1:
raise ValueError("Use a ratio between zero and one")
remaining = window - output_reservation - headroom
trigger = floor(min(window * ratio, remaining))
return {"valid_capacity": remaining > 0, "trigger": trigger}
print(inspect_budget(65536, 8192, 65536, 0.8))
print(inspect_budget(65536, 8192, 4096, 0.8))The first calculation produces an invalid capacity budget. The second produces a trigger of 52,428 tokens. The second result is an arithmetic example, not a recommended setting or a promise that a real conversation will fit.
You still need a measured request size and a valid retention policy. Lowering headroom simply to make a warning disappear can leave too little room for the next response or subsequent work.
Keep the units explicit in the worksheet. A character count, an estimated token count, and the provider’s reported usage are different measurements. Do not substitute one for another without documenting the approximation.
Confirm that model metadata describes the route you use
A model’s public context specification is useful, but the application also needs usable metadata for the configured route. An alias in a gateway catalog may not match the identifier registered in a local adapter.
The Harness LLM service reference separates model discovery from model resolution. Catalog visibility is not a complete test of the metadata used during execution. GitHub
Build a small route record containing the provider ID, exact model ID, protocol, declared context capacity, and effective output cap. Obtain each value from the relevant configuration or service documentation rather than copying the numbers from a different model family.
For example, a DeepSeek route and a GLM route may both accept Chat Completions requests while exposing different capacity limits. Sharing a wire format does not make their capacity budgets interchangeable. The same caution applies when moving between Claude and Gemini through protocol-specific adapters.
If the failure mentions an adapter or model lookup, use the Harness model-configuration troubleshooting article. Avoid changing compression settings until the destination itself can be resolved correctly.
When evaluating a relay, ask which capacity applies to the exact route available to your account. Record that answer alongside the model identifier. A generic marketing statement about a model family is insufficient for a reproducible migration test.
Check the model writing the summary
Switching the visible model does not necessarily switch the model responsible for summarizing the old conversation.
The current compaction subsystem documentation explains that, once a session contains an assistant answer, the latest answering route normally remains the summary route unless an explicit summary target overrides it. The newly selected destination is not automatically responsible for summarizing history it has not yet answered. GitHub
This creates a practical failure pattern. A team disables the old provider, selects a replacement, and then discovers that moving the session requires a summary call through the disabled route.
In that situation, verify the summary request independently. Does its credential still work? Does its model remain accessible? Can that model accept the selected history? Capture the answer before modifying the destination.
If a different summarizer is appropriate, configure it deliberately and evaluate its output. Do not assume a cheaper model can summarize every history packet or preserve every requirement accurately. The agent harness token-cost article provides the broader cost context; the immediate objective here is a valid, useful handoff.
Treat summary calls as real API work in your usage records. A model-selection click can lead to preparation work before the destination generates a visible answer. That distinction helps explain activity on the previous route without assuming the switch was ignored.
Identify the material that summarization cannot solve
A long session is not one homogeneous block of text. System instructions, tool definitions, conversation history, and tool results contribute different kinds of material.
Summarization is appropriate for older conversational evidence that can be represented more compactly. It is a poor substitute for correcting a permanently oversized request envelope. If a new session already carries a huge tool catalog, shortening yesterday’s dialogue will not make that catalog disappear.
The optional tool-result pruner trims eligible oversized tool-result text after a compaction trigger. It makes no model call, and the original result remains in the session log. Character limits approximate token use; the measured request determines whether enough pressure has been removed. GitHub
Before enabling more aggressive trimming, inspect the actual result. A test run may contain thousands of repetitive lines and one essential failure near the middle. Keeping only the beginning and end could remove the evidence needed for the next decision.
A better task design may store the full artifact in a file and provide a concise index to the relevant sections. The next agent step can retrieve the necessary evidence rather than carrying every line indefinitely. Verify that the required file-access tools remain available after switching models.
This is a change to the workflow, so evaluate it separately from the gateway connection. The model API acceptance guide helps keep functional acceptance distinct from a successful HTTP response.
Rehearse the migration with facts you can check
Create a disposable test conversation with three explicit requirements: a function name that must remain unchanged, an operation the agent must not perform, and a numeric threshold the final result must preserve.
Use fictional values so that the exercise does not depend on customer data. Add enough representative material to exercise your migration path, but do not inflate the transcript with meaningless filler and call that a production benchmark.
Save the requirements separately before switching. After the transition, ask the destination to state the constraints and continue the task. Compare its answer with the saved fixture. A fluent summary is not sufficient evidence that a negation or exact identifier survived.
Also inspect what happened before the switch failed or succeeded. The upgrade guide notes that completed pruning or checkpoints can remain even when a later transition step fails. Returning to the previous model therefore should not be treated as proof that the session is identical to its earlier state.
For an important working session, preserve a supported snapshot or export before experimentation. Do not edit live session-log files manually to simulate a rollback. Keep the controlled migration separate from active business work.
Record preparation time, summary usage, destination usage, and whether the saved requirements survived. This gives you a practical comparison between continuing the original conversation and starting a new one with an explicit handoff packet.
Choose a route that fits the continuing task
The destination should fit the next stage of work, not merely offer an attractive model name. A short classification step and a repository-wide investigation need different evidence and response budgets.
Start with the Treerouter model directory, confirm the exact available route, and test its protocol and capacity with representative input. If you need a separate evaluation account, register for a small integration test before migrating a valuable session.
The acceptance target is specific: the destination receives the intended request, the session retains its required facts, and the workflow finishes within the budget you observed. Keep the successful fixture for future model or adapter changes.
Frequently asked questions
Why does a short prompt produce a context-related switch error?
The new prompt is only part of the request. Existing history and configured capacity budgets also matter. A short prompt cannot repair missing capacity metadata or an impossible output-plus-headroom allocation.
Should I disable automatic compaction to bypass the error?
Only as a deliberate configuration decision with another context-management plan. Bypassing a preparation check does not make the destination accept an oversized request. It can move the failure downstream and remove automatic recovery behavior.
Does this mean the destination model is unreliable?
Not by itself. First establish whether a destination request was sent. A local policy failure, a failed summary call, and an upstream rejection are different events with different owners.






