diff --git a/nix/templates/harness-base.nix b/nix/templates/harness-base.nix index 478dd82..3040d45 100644 --- a/nix/templates/harness-base.nix +++ b/nix/templates/harness-base.nix @@ -228,6 +228,25 @@ ''; }; + options.hyperhive.autoCompact = lib.mkOption { + type = lib.types.bool; + default = true; + description = '' + Enable proactive watermark-based compaction. When `true` (the + default) the harness automatically runs a notes-checkpoint turn + followed by `/compact` once the context window crosses 75% of + the model's limit, keeping later turns from hitting the hard + overflow path. Set to `false` to disable proactive compaction + entirely (`HIVE_COMPACT_WATERMARK_TOKENS=0`); the reactive path + (compact-on-overflow when the session is already past the limit) + still applies. + + Disable for agents that run large-context models (sonnet/opus) + where the heuristic fires too early and discards useful history + before the session is actually close to the limit. + ''; + }; + config = { environment.etc."hyperhive/extra-mcp.json".text = builtins.toJSON config.hyperhive.extraMcpServers; @@ -260,6 +279,10 @@ environment.variables = { HIVE_DEFAULT_MODEL = config.hyperhive.model; SHELL = "${pkgs.bashInteractive}/bin/bash"; + } // lib.optionalAttrs (!config.hyperhive.autoCompact) { + # Zero watermark disables proactive compaction; the reactive path + # (compact-on-overflow) still fires when the session is truly full. + HIVE_COMPACT_WATERMARK_TOKENS = "0"; }; boot.isNspawnContainer = true;