fix(coding-agent): defer ACP reserve confirmation
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user