Skip to content

Commit 208bb21

Browse files
test(session): a manual compaction uses the given model and does not resume the agent
Pins the behavior the one-shot "compact now" relies on: POST /session/:id/summarize creates a compaction with the model in the body and runs the loop. The summary request goes to that model (not the session's), and with auto: false no continue message is added, so the agent does not resume on the session's metered model. A characterization test of existing behavior; no code change. Ref LDE-40, anomalyco#47 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GHX6CpBR14wnFxJLDahwTr
1 parent 5d41a81 commit 208bb21

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

‎packages/opencode/test/session/accuracy-loop.test.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,3 +873,48 @@ it.instance(
873873
}),
874874
60_000,
875875
)
876+
877+
// "Compact now" (POST /session/:id/summarize does exactly this): the summary goes
878+
// to the model the caller names, and with auto: false the agent does not resume.
879+
it.instance(
880+
"a manual compaction uses the model it is given and does not continue the agent",
881+
() =>
882+
Effect.gen(function* () {
883+
const { llm } = yield* useConfig(undefined, {
884+
provider: {
885+
test: {
886+
...provider.test,
887+
models: {
888+
...provider.test.models,
889+
"cheap-model": { ...provider.test.models["test-model"], id: "cheap-model", name: "Cheap" },
890+
},
891+
options: { ...provider.test.options, baseURL: (yield* TestLLMServer).url },
892+
},
893+
},
894+
})
895+
const prompt = yield* SessionPrompt.Service
896+
const compaction = yield* SessionCompaction.Service
897+
const chat = yield* session()
898+
yield* llm.push(bigStep())
899+
yield* llm.text("worked")
900+
yield* prompt.prompt({ sessionID: chat.id, agent: "build", parts: [{ type: "text", text: "hi" }] })
901+
expect(yield* llm.hits).toHaveLength(2)
902+
903+
yield* llm.text("summary")
904+
// a reply queued for a resumed agent: it must never be requested
905+
yield* llm.text("resumed")
906+
yield* compaction.create({
907+
sessionID: chat.id,
908+
agent: "build",
909+
model: { providerID: ProviderV2.ID.make("test"), modelID: ModelV2.ID.make("cheap-model") },
910+
auto: false,
911+
})
912+
yield* prompt.loop({ sessionID: chat.id })
913+
914+
const hits = yield* llm.hits
915+
expect(hits).toHaveLength(3)
916+
expect(hits[2]!.body.model).toBe("cheap-model")
917+
expect(yield* compactions(chat.id)).toHaveLength(1)
918+
}),
919+
60_000,
920+
)

0 commit comments

Comments
 (0)