Handoff-style /model switch command and per-turn thinking level (#64)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Yaowei ZhengandClaude Fable 5 authored and GitHub committed 2026-07-26 16:31:51 +08:00
1 parent 816a823b75
commit 1e23452f48
58 files changed
+1064 -336

No files matched your search

+49 -6
View File
@@ -149,7 +149,6 @@ describe("session-index", () => {
model_context_window: 1000,
system_prompt: "",
tools: [],
thinking_level: "default",
agent_state: "/tmp/a",
workspace: "/tmp/w-restart",
source: "subagent",
@@ -176,7 +175,6 @@ describe("session-index", () => {
model_context_window: 1000,
system_prompt: "",
tools: [],
thinking_level: "default",
agent_state: "/tmp/a",
workspace: "/tmp/w-cli",
source: "schedule",
@@ -281,7 +279,6 @@ describe("session-index", () => {
model_context_window: 1000,
system_prompt: "",
tools: [],
thinking_level: "default",
agent_state: "/tmp/a",
workspace: "/tmp/w-sub",
source: "subagent",
@@ -390,7 +387,6 @@ describe("session-index", () => {
model_context_window: 1000,
system_prompt: "",
tools: [],
thinking_level: "default",
agent_state: "/tmp/a",
workspace: "/tmp/cli-workspace",
};
@@ -426,7 +422,6 @@ describe("session-index", () => {
model_context_window: 1000,
system_prompt: "",
tools: [],
thinking_level: "default",
agent_state: "/tmp/a",
workspace: session.workspace,
};
@@ -484,7 +479,6 @@ describe("session-index", () => {
model_context_window: 1,
system_prompt: "",
tools: [],
thinking_level: "default",
agent_state: "/a",
workspace: "/w",
}),
@@ -539,4 +533,53 @@ describe("session-index", () => {
);
expect(sessionIdCreatedAt("not-a-session")).toBeNull();
});
it("single-session GET exposes tracePath (the LATEST shard); absent without a trace; list rows omit it", async () => {
await configureModels();
const res = await api.post(base(), {});
const { session } = (await res.json()) as SessionCreateResponse;
// No trace yet: no tracePath.
const before = (await (
await api.get(`/api/sessions/${session.sessionId}`)
).json()) as SessionResponse;
expect(before.session.tracePath).toBeUndefined();
const meta: SessionMetaPayload = {
session_id: session.sessionId,
model_id: session.modelId,
provider: session.provider,
model_context_window: 128000,
system_prompt: "",
tools: [],
agent_state: "/tmp/a",
workspace: session.workspace,
};
await writeTraceFile(t.root, projectId, "default_agent", "2026-07-02", session.sessionId, 1, [
sessionMeta(meta),
userText("a"),
]);
await writeTraceFile(t.root, projectId, "default_agent", "2026-07-03", session.sessionId, 2, [
sessionMeta(meta),
userText("b"),
]);
const after = (await (
await api.get(`/api/sessions/${session.sessionId}`)
).json()) as SessionResponse;
// The /model switch block hands this to the model: it must point at the latest shard.
expect(after.session.tracePath?.endsWith(`${session.sessionId}_002.jsonl`)).toBe(true);
// List rows omit it (locating it would cost a directory walk per row).
const list = (await (await api.get(base())).json()) as SessionsResponse;
expect(list.sessions.find((s) => s.sessionId === session.sessionId)?.tracePath).toBeUndefined();
});
it("rejects an invalid per-task thinkingLevel with 400 (five names only)", async () => {
await configureModels();
const res = await api.post(base(), {});
const { session } = (await res.json()) as SessionCreateResponse;
const bad = await api.post(`/api/sessions/${session.sessionId}/tasks`, {
input: [{ type: "text", text: "hi" }],
thinkingLevel: "ultra",
});
expect(bad.status).toBe(400);
});
});