feat(coding-agent): added per-turn AUTO_THINKING in coding-agent session

- Added AUTO_THINKING as a configured thinking level in settings, schema, SDK, and session plumbing.
- Implemented per-turn auto reasoning classification with online/local prompts, effort clamping, and skip guards.
- Updated model selectors, ACP options, footer/status UI, and events to render auto and auto->resolved states.
- Added AUTO_THINKING parse/clamp tests and fixed local-module cycle and hashline preview regressions.
This commit is contained in:
can1357
2026-05-31 03:31:31 +02:00
parent 3f2e4b2fe7
commit 7f866a48a8
21 changed files with 827 additions and 76 deletions
@@ -0,0 +1,43 @@
import { describe, expect, it } from "bun:test";
import { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
import { Effort, getBundledModel } from "@oh-my-pi/pi-ai";
import {
AUTO_THINKING,
clampAutoThinkingEffort,
parseConfiguredThinkingLevel,
parseThinkingLevel,
} from "@oh-my-pi/pi-coding-agent/thinking";
import { parseDifficultyBucket, parseDifficultyLevel } from "../src/auto-thinking/classifier";
describe("auto thinking classifier helpers", () => {
it("parses configured thinking without widening provider-facing thinking selectors", () => {
expect(parseConfiguredThinkingLevel(AUTO_THINKING)).toBe(AUTO_THINKING);
expect(parseConfiguredThinkingLevel(Effort.High)).toBe(Effort.High);
expect(parseConfiguredThinkingLevel("bogus")).toBeUndefined();
expect(parseThinkingLevel(AUTO_THINKING)).toBeUndefined();
expect(parseThinkingLevel(ThinkingLevel.Off)).toBe(ThinkingLevel.Off);
});
it("maps online 4-way classifier labels to effort levels", () => {
expect(parseDifficultyLevel("x-high")).toBe(Effort.XHigh);
expect(parseDifficultyLevel("The answer is HIGH.")).toBe(Effort.High);
expect(parseDifficultyLevel("med")).toBe(Effort.Medium);
expect(parseDifficultyLevel("low")).toBe(Effort.Low);
expect(parseDifficultyLevel("unknown")).toBeUndefined();
});
it("maps local 3-bucket labels to coarse effort levels", () => {
expect(parseDifficultyBucket("trivial")).toBe(Effort.Low);
expect(parseDifficultyBucket("moderate")).toBe(Effort.High);
expect(parseDifficultyBucket("hard")).toBe(Effort.XHigh);
expect(parseDifficultyBucket("medium")).toBeUndefined();
});
it("clamps auto effort to model support while never resolving below low", () => {
const model = getBundledModel("anthropic", "claude-sonnet-4-6");
if (!model) throw new Error("Expected bundled Claude Sonnet 4.6 model");
expect(clampAutoThinkingEffort(model, Effort.XHigh)).toBe(Effort.High);
expect(clampAutoThinkingEffort(model, Effort.Minimal)).toBe(Effort.Low);
});
});