fix(opencode): order legacy message loop by time (#40990)

Co-authored-by: Dax <mail@thdxr.com>
This commit is contained in:
opencode-agent[bot]
2026-08-07 04:08:23 +00:00
committed by GitHub
parent a54a693af2
commit db581e47a3
4 changed files with 120 additions and 10 deletions
@@ -460,6 +460,46 @@ noLLMServer.instance(
{ config: cfg },
)
noLLMServer.instance(
"loop exits for a completed parent turn with nonmonotonic message IDs",
() =>
Effect.gen(function* () {
const prompt = yield* SessionPrompt.Service
const sessions = yield* Session.Service
const chat = yield* sessions.create({ title: "Pinned" })
const userID = MessageID.make("msg_z_user")
const assistantID = MessageID.make("msg_a_assistant")
yield* sessions.updateMessage({
id: userID,
role: "user",
sessionID: chat.id,
agent: "build",
model: ref,
time: { created: 100 },
})
yield* sessions.updateMessage({
id: assistantID,
role: "assistant",
parentID: userID,
sessionID: chat.id,
mode: "build",
agent: "build",
cost: 0,
path: { cwd: "/tmp", root: "/tmp" },
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
modelID: ref.modelID,
providerID: ref.providerID,
time: { created: 200, completed: 201 },
finish: "stop",
})
const result = yield* prompt.loop({ sessionID: chat.id })
expect(result.info.id).toBe(assistantID)
}),
{ config: cfg },
)
it.instance("loop exits without an LLM request for interrupted orphan tool calls", () =>
Effect.gen(function* () {
const { llm } = yield* useServerConfig(providerCfg)