fix: detect Ollama "prompt too long" as context overflow error (#34019)

Merged via squash.

Prepared head SHA: 825a402f0f
Co-authored-by: lishuaigit <7495165+lishuaigit@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
This commit is contained in:
lishuaigit
2026-03-17 09:57:33 +08:00
committed by GitHub
parent 6da9ba3267
commit 76500c7a78
20 changed files with 275 additions and 50 deletions

View File

@@ -10,6 +10,7 @@ import {
resolveOwningPluginIdsForProvider,
resolvePluginProviders,
} from "./providers.js";
import { resolvePluginCacheInputs } from "./roots.js";
import type {
ProviderAuthDoctorHintContext,
ProviderAugmentModelCatalogContext,
@@ -76,8 +77,16 @@ function resolveHookProviderCacheBucket(params: {
return bucket;
}
function buildHookProviderCacheKey(params: { workspaceDir?: string; onlyPluginIds?: string[] }) {
return `${params.workspaceDir ?? ""}::${JSON.stringify(params.onlyPluginIds ?? [])}`;
function buildHookProviderCacheKey(params: {
workspaceDir?: string;
onlyPluginIds?: string[];
env?: NodeJS.ProcessEnv;
}) {
const { roots } = resolvePluginCacheInputs({
workspaceDir: params.workspaceDir,
env: params.env,
});
return `${roots.workspace ?? ""}::${roots.global}::${roots.stock ?? ""}::${JSON.stringify(params.onlyPluginIds ?? [])}`;
}
export function resetProviderRuntimeHookCacheForTest(): void {
@@ -105,6 +114,7 @@ function resolveProviderPluginsForHooks(params: {
const cacheKey = buildHookProviderCacheKey({
workspaceDir: params.workspaceDir,
onlyPluginIds: params.onlyPluginIds,
env,
});
const cached = cacheBucket.get(cacheKey);
if (cached) {

View File

@@ -153,9 +153,7 @@ describe("stageBundledPluginRuntime", () => {
description: string;
acceptsArgs: boolean;
}>;
matchPluginCommand: (
commandBody: string,
) => {
matchPluginCommand: (commandBody: string) => {
command: { handler: ({ args }: { args?: string }) => Promise<{ text: string }> };
args?: string;
} | null;