fix: complete fast mode fallback and status wiring

This commit is contained in:
Vincent Koc
2026-06-22 09:09:45 +08:00
parent 93ad397725
commit aa3797c8d0
7 changed files with 27 additions and 4 deletions
+1
View File
@@ -1498,6 +1498,7 @@ export class AcpGatewayAgent implements Agent {
modelProvider: session.modelProvider,
model: session.model,
fastMode: session.fastMode,
effectiveFastMode: session.effectiveFastMode,
verboseLevel: session.verboseLevel,
traceLevel: session.traceLevel,
reasoningLevel: session.reasoningLevel,
+1
View File
@@ -1926,6 +1926,7 @@ async function agentCommandInternal(
fastMode === "auto"
? (opts.fastModeAutoOnSeconds ?? fastModeState.fastAutoOnSeconds)
: fastModeState.fastAutoOnSeconds,
isFinalFallbackAttempt: runOptions?.isFinalFallbackAttempt,
timeoutMs,
runTimeoutOverrideMs,
runId,
+2
View File
@@ -478,6 +478,7 @@ export function runAgentAttempt(params: {
fastMode?: FastMode;
fastModeStartedAtMs?: number;
fastModeAutoOnSeconds?: number;
isFinalFallbackAttempt?: boolean;
timeoutMs: number;
runTimeoutOverrideMs?: number;
runId: string;
@@ -791,6 +792,7 @@ export function runAgentAttempt(params: {
fastMode: params.fastMode,
fastModeStartedAtMs: params.fastModeStartedAtMs,
fastModeAutoOnSeconds: params.fastModeAutoOnSeconds,
isFinalFallbackAttempt: params.isFinalFallbackAttempt,
verboseLevel: params.resolvedVerboseLevel,
bashElevated: params.opts.bashElevated,
approvalReviewerDeviceId: params.opts.approvalReviewerDeviceId,
+3 -1
View File
@@ -4124,7 +4124,9 @@ async function runEmbeddedAgentInternal(
};
}
} finally {
await maybeEmitFastModeAutoResetBestEffort();
if (params.isFinalFallbackAttempt !== false) {
await maybeEmitFastModeAutoResetBestEffort();
}
forgetPromptBuildDrainCacheForRun(params.runId);
stopRuntimeAuthRefreshTimer();
await runAgentCleanupStep({
@@ -153,6 +153,8 @@ export type RunEmbeddedAgentParams = {
fastModeAutoOnSeconds?: number;
/** Shared notification state for nested harnesses that can observe the same tool boundary. */
fastModeAutoProgressState?: FastModeAutoProgressState;
/** True when the outer model fallback loop has reached its final candidate. */
isFinalFallbackAttempt?: boolean;
verboseLevel?: VerboseLevel;
reasoningLevel?: ReasoningLevel;
toolResultFormat?: ToolResultFormat;
+5 -1
View File
@@ -168,6 +168,7 @@ export function isFallbackSummaryError(err: unknown): err is FallbackSummaryErro
export type ModelFallbackRunOptions = {
allowTransientCooldownProbe?: boolean;
isFinalFallbackAttempt?: boolean;
};
type ModelFallbackRuntimeContext = {
@@ -1657,7 +1658,10 @@ async function runWithModelFallbackInternal<T>(
run: params.run,
...candidate,
attempts,
options: runOptions,
options: {
...runOptions,
isFinalFallbackAttempt: i + 1 === candidates.length,
},
// Only the outer fallback loop knows another candidate remains. Carry
// that fact through this attempt so the embedded runner does not freeze
// the shared lane before the next candidate can run.
+13 -2
View File
@@ -9,6 +9,7 @@ import {
import { resolveContextTokensForModel } from "../agents/context.js";
import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js";
import { resolveExtraParams } from "../agents/embedded-agent-runner/extra-params.js";
import { resolveFastModeState } from "../agents/fast-mode.js";
import { resolveModelAuthMode } from "../agents/model-auth.js";
import {
areRuntimeModelRefsEquivalent,
@@ -25,7 +26,6 @@ import {
formatProviderModelRef,
resolveSelectedAndActiveModel,
} from "../auto-reply/model-runtime.js";
import { formatFastModeStatusValue } from "../shared/fast-mode.js";
import type {
ElevatedLevel,
ReasoningLevel,
@@ -56,6 +56,7 @@ import {
} from "../media-understanding/runner.entries.js";
import type { MediaUnderstandingDecision } from "../media-understanding/types.js";
import { resolveAgentIdFromSessionKey } from "../routing/session-key.js";
import { formatFastModeStatusValue } from "../shared/fast-mode.js";
import { resolveStatusTtsSnapshot } from "../tts/status-config.js";
import {
estimateUsageCost,
@@ -882,6 +883,13 @@ export function buildStatusMessage(args: StatusArgs): string {
const verboseLevel =
args.resolvedVerbose ?? args.sessionEntry?.verboseLevel ?? args.agent?.verboseDefault ?? "off";
const fastMode = args.resolvedFast ?? args.sessionEntry?.fastMode ?? false;
const fastModeState = resolveFastModeState({
cfg: args.config,
provider: activeProvider,
model: activeModel,
agentId: args.agentId,
sessionEntry: args.sessionEntry,
});
const reasoningLevel =
args.resolvedReasoning ??
args.sessionEntry?.reasoningLevel ??
@@ -970,7 +978,10 @@ export function buildStatusMessage(args: StatusArgs): string {
`Execution: ${execution.label}`,
`Runtime: ${agentRuntimeLabel}`,
`Think: ${thinkLevel}`,
`Fast: ${formatFastModeStatusValue({ mode: fastMode })}`,
`Fast: ${formatFastModeStatusValue({
mode: fastMode,
fastAutoOnSeconds: fastModeState.fastAutoOnSeconds,
})}`,
textVerbosity ? `Text: ${textVerbosity}` : null,
verboseLabel,
traceLabel,