Files
oh-my-pi/packages/coding-agent/src/config/append-only-context-mode.ts
T
can1357 ae415199dc feat: added build-time compatibility in ModelSpec/buildModel pipeline
- Centralized catalog and registry handling on `ModelSpec` and `buildModel`, resolving compatibility at model build time.
- Removed runtime compatibility detectors and switched provider request flows to direct `model.compat` reads.
- Added compat fields (`supportsReasoningParams`, `alwaysSendMaxTokens`, `strictResponsesPairing`, `whenThinking`).
- Persisted explicit compatibility overrides through `compatConfig` in discovery and cache merge paths.
2026-06-10 06:20:51 +02:00

32 lines
1.1 KiB
TypeScript

import { hostMatchesUrl } from "@oh-my-pi/pi-catalog/hosts";
/** Provider metadata needed to resolve append-only context mode. */
export interface AppendOnlyContextModel {
provider: string;
baseUrl: string;
/** Verbatim sparse compat config (explicit user intent), never the resolved record. */
compatConfig?: object;
}
function shouldAutoEnableAppendOnlyContext(model: AppendOnlyContextModel | null | undefined): boolean {
if (!model) return false;
if (model.provider === "deepseek") return true;
if (hostMatchesUrl(model.baseUrl, "xiaomi")) return true;
return !!model.compatConfig && "supportsStore" in model.compatConfig && model.compatConfig.supportsStore === true;
}
/** Resolves whether append-only context should be active for a model and setting. */
export function shouldEnableAppendOnlyContext(
setting: "auto" | "on" | "off" | undefined,
model: AppendOnlyContextModel | null | undefined,
): boolean {
switch (setting ?? "auto") {
case "on":
return true;
case "off":
return false;
default:
return shouldAutoEnableAppendOnlyContext(model);
}
}