diff --git a/CHANGELOG.md b/CHANGELOG.md
index b72929a..7f95938 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,15 @@ recorded by the `MandoCode` submodule.
period-correct white dialog on the silver desktop.
### Fixed
+- **The context window setting now actually reaches the model.** It was exported as
+ `OLLAMA_CONTEXT_LENGTH` only when MandoCode launched the Ollama daemon itself — anyone whose
+ daemon was already running (the tray app, most commonly) silently got the daemon's own default
+ instead, making the Settings field, the "context window sized to Nk tokens" line, and the
+ per-model auto-sizing all cosmetic. The window now rides on every chat request as `num_ctx`,
+ which outranks the tray app's slider and the daemon default, applies from the next message with
+ no restart, and — as a bonus the old design could never offer — is genuinely per-agent: two tabs
+ can run different windows against the same daemon. The Settings caption and README stop calling
+ it app-wide, and `0` still means "let Ollama decide."
- **W98 chat prompts are readable again.** Your own prompts rendered in the theme's gold, which
resolves to a dark mustard `#806000` — 3.21:1 on a silver window, under the accessibility floor
and hard going for anyone with less-than-perfect sight. W98 prompts now use black window text
@@ -33,6 +42,13 @@ recorded by the `MandoCode` submodule.
and is now white underlined at 4.77:1. Other themes are untouched.
### Added
+- **Conversations compact themselves before the context window overflows** (pinned harness
+ update). Local Ollama never rejects an oversized prompt — it silently drops the oldest tokens,
+ system prompt first, which surfaced as "Model returned an empty response" at the end of a
+ tool-heavy turn on a small model. The harness now estimates each outgoing prompt (history plus
+ every tool schema riding along, MCP servers included) before sending, and when it nears the
+ window it folds older history into a recap first and says so in the reply — leaving thinking
+ models the generation headroom they spend reasoning before any visible answer appears.
- **Undo for the notes assistant.** A gold undo arrow appears in the note header after the assistant
inserts or replaces text, putting the note back exactly as it was. Ctrl+Z can't do this job —
assigning the editor's text resets the TextBox's own undo history, so the one edit you *didn't*
diff --git a/MandoCode b/MandoCode
index 9d2bde3..a341d42 160000
--- a/MandoCode
+++ b/MandoCode
@@ -1 +1 @@
-Subproject commit 9d2bde3f44ac6fa6880bf01bcb4b5f6e04f6926b
+Subproject commit a341d42d9e8b578602294542156ff2bf025136c2
diff --git a/README.md b/README.md
index 7c75e0d..72775fc 100644
--- a/README.md
+++ b/README.md
@@ -148,9 +148,11 @@ approval in one agent would stop another's from ever rendering; and `ChatControl
(not `+=`) five approval delegates, so on shared services the last agent constructed silently
steals every approval.
-Two settings can't be per-agent and are labelled app-wide in the UI: **Appearance** is a property
-of the window (and lives outside the shared config), and **Context window** is applied as
-`OLLAMA_CONTEXT_LENGTH` when MandoCode starts the Ollama daemon — one daemon, one context window.
+One setting can't be per-agent and is labelled app-wide in the UI: **Appearance** is a property
+of the window (and lives outside the shared config). **Context window** used to share that label —
+it was applied as `OLLAMA_CONTEXT_LENGTH` at daemon start, one daemon, one window — but it now
+rides on every chat request as `num_ctx`, so each agent's own value governs its own conversations,
+like any other per-agent setting.
### Settings and the config file
diff --git a/src/MandoCode.Desktop/MainWindow.xaml b/src/MandoCode.Desktop/MainWindow.xaml
index c70e3a6..7f4a49f 100644
--- a/src/MandoCode.Desktop/MainWindow.xaml
+++ b/src/MandoCode.Desktop/MainWindow.xaml
@@ -1027,11 +1027,11 @@
Minimum="1" SpinButtonPlacementMode="Compact" SmallChange="1024"
ValueChanged="Setting_NumberChanged" HorizontalAlignment="Stretch"
ToolTipService.ToolTip="Upper limit on how long a single response can be. Raise it if answers get cut off mid-code; lower it for shorter, faster replies."/>
-
-
, the starting point every NEW agent is seeded
/// from. "Make Default for New Agents" is the one action that writes it.
///
-/// Two things are deliberately app-wide rather than per-agent, because the machinery underneath
-/// them is:
-/// • MCP servers — OS processes owned by a single shared McpClientManager. An agent can turn
-/// MCP on or off for itself (AIService.AttachMcpPluginsAsync honours its own EnableMcp), but
-/// the server SET is one list. Edits land on Defaults and mirror into every live agent, so
-/// per-agent autoApprove lookups agree with what the MCP page shows.
-/// • ContextLength — applied as OLLAMA_CONTEXT_LENGTH when MandoCode starts the Ollama daemon.
-/// One daemon, one context window.
+/// One thing is deliberately app-wide rather than per-agent, because the machinery underneath
+/// it is: MCP servers — OS processes owned by a single shared McpClientManager. An agent can turn
+/// MCP on or off for itself (AIService.AttachMcpPluginsAsync honours its own EnableMcp), but
+/// the server SET is one list. Edits land on Defaults and mirror into every live agent, so
+/// per-agent autoApprove lookups agree with what the MCP page shows.
+/// (ContextLength used to be on this list — env-var-scoped to the one daemon — but it now rides
+/// on every request as num_ctx, so each agent's own value governs its own conversations.)
///
/// A clone's Save() must never be called: it would write that agent's session settings over
/// everybody's defaults. The method is public and non-virtual on a type in the read-only harness
diff --git a/src/MandoCode.Desktop/ViewModels/ChatController.cs b/src/MandoCode.Desktop/ViewModels/ChatController.cs
index d5bd06c..155e905 100644
--- a/src/MandoCode.Desktop/ViewModels/ChatController.cs
+++ b/src/MandoCode.Desktop/ViewModels/ChatController.cs
@@ -1173,7 +1173,7 @@ private async Task ApplyModelSwitchAsync(string modelTag)
if (recommendedCtx > 0 && recommendedCtx != _config.ContextLength)
{
_config.ContextLength = recommendedCtx;
- _transcript.Append(_html.Dim($"Context window sized to {recommendedCtx / 1024}k tokens for this model tier (takes effect when MandoCode starts Ollama)."));
+ _transcript.Append(_html.Dim($"Context window sized to {recommendedCtx / 1024}k tokens for this model tier (applies from your next message)."));
}
_busy.Start("Switching model...");