fix(coding-agent): defer ACP reserve confirmation

This commit is contained in:
Brent
2026-07-23 16:51:08 +00:00
committed by can1357
parent 93af91b7f5
commit 6d4a345d69
4 changed files with 52 additions and 2 deletions
@@ -459,6 +459,43 @@ describe("createAgentSession deferred model pattern resolution", () => {
}
});
test("defers ACP reserve fallback until prompt-time capabilities are configured", async () => {
const settings = Settings.isolated({
"retry.usageAwareFallback": true,
"retry.usageReservePolicy": "confirm",
});
settings.setModelRole("task", "runtime-provider/runtime-model,runtime-provider/runtime-reasoning-model");
const options = await buildSessionOptions("task");
vi.spyOn(options.authStorage, "getModelUsageHealth").mockImplementation(async (_provider, healthOptions) =>
healthOptions.modelId === "runtime-model"
? {
state: "reserve",
accounts: [
{
credentialId: 1,
credentialType: "oauth",
state: "reserve",
remainingFraction: 0.05,
},
],
}
: { state: "healthy", accounts: [{ credentialId: 2, credentialType: "oauth", state: "healthy" }] },
);
const { session } = await createAgentSession({
...options,
modelPatternFallbackRole: "subagent:usage-aware-acp",
settings,
hasUI: false,
deferUsageReserveConfirmation: true,
});
try {
expect(session.model?.provider).toBe("runtime-provider");
expect(session.model?.id).toBe("runtime-model");
} finally {
await session.dispose();
}
});
test("enforces fail-closed reserve policy without requiring a fallback candidate", async () => {
const settings = Settings.isolated({
"retry.usageAwareFallback": true,