fix(session): preserved auto-thinking level on classifier failure
- Kept the last successfully classified effort when a later classification fails. - Added regression coverage for the success-then-failure transition. Fixes #6877
This commit is contained in:
@@ -541,6 +541,34 @@ describe("AgentSession role model thinking behavior", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves the resolved auto level when a later classification fails", async () => {
|
||||
const model = getAnthropicModelOrThrow("claude-sonnet-4-5");
|
||||
await createSession({
|
||||
initialModelId: model.id,
|
||||
initialThinkingLevel: Effort.High,
|
||||
modelRoles: { default: `${model.provider}/${model.id}` },
|
||||
});
|
||||
vi.spyOn(session.agent, "prompt").mockResolvedValue(undefined);
|
||||
vi.spyOn(autoThinkingClassifier, "classifyDifficulty")
|
||||
.mockResolvedValueOnce(Effort.Low)
|
||||
.mockRejectedValueOnce(new Error("classifier down"));
|
||||
|
||||
session.setThinkingLevel(AUTO_THINKING);
|
||||
await session.prompt("Handle a straightforward update");
|
||||
const receiptCount = session.sessionManager
|
||||
.getEntries()
|
||||
.filter(entry => entry.type === "thinking_level_change").length;
|
||||
await session.prompt("Investigate another update");
|
||||
|
||||
expect(session.configuredThinkingLevel()).toBe(AUTO_THINKING);
|
||||
expect(session.thinkingLevel).toBe(Effort.Low);
|
||||
expect(session.autoResolvedThinkingLevel()).toBe(Effort.Low);
|
||||
expect(session.agent.state.thinkingLevel).toBe(Effort.Low);
|
||||
expect(session.sessionManager.getEntries().filter(entry => entry.type === "thinking_level_change")).toHaveLength(
|
||||
receiptCount,
|
||||
);
|
||||
});
|
||||
|
||||
it("skips classification for synthetic turns", async () => {
|
||||
const model = getAnthropicModelOrThrow("claude-sonnet-4-5");
|
||||
await createSession({
|
||||
|
||||
Reference in New Issue
Block a user