fix(opencode): clarify incomplete shell output

This commit is contained in:
Hona 2026-07-21 00:42:02 +00:00
commit 421100d322
2 changed files with 9 additions and 4 deletions

View file

@ -25,7 +25,7 @@ import { BashArity } from "@/permission/arity"
export { Parameters } from "./shell/prompt"
const MAX_METADATA_LENGTH = 30_000
const POST_EXIT_OUTPUT_GRACE = "500 millis"
const POST_EXIT_OUTPUT_GRACE_MS = 500
const CWD = new Set(["cd", "chdir", "popd", "pushd", "push-location", "set-location"])
const FILES = new Set([
...CWD,
@ -559,7 +559,7 @@ export const ShellTool = Tool.define(
const outputComplete = yield* Fiber.await(output).pipe(
Effect.as(true),
Effect.timeoutOrElse({
duration: POST_EXIT_OUTPUT_GRACE,
duration: `${POST_EXIT_OUTPUT_GRACE_MS} millis`,
orElse: () => Effect.succeed(false),
}),
)
@ -576,7 +576,10 @@ export const ShellTool = Tool.define(
)
}
if (aborted) meta.push("User aborted the command")
if (incomplete) meta.push("shell tool exited without reaching EOF within 500 ms")
if (incomplete)
meta.push(
`shell tool exited without reaching EOF within ${POST_EXIT_OUTPUT_GRACE_MS} ms; a background descendant may be holding the output pipe open`,
)
const raw = list.map((item) => item.text).join("")
const end = tail(raw, limits.maxLines, limits.maxBytes)
if (end.cut) cut = true

View file

@ -1116,7 +1116,9 @@ describe("tool.shell abort", () => {
expect(Date.now() - started).toBeLessThan(3_000)
expect(result.output).toContain("parent done")
expect(result.output).toContain("shell tool exited without reaching EOF within 500 ms")
expect(result.output).toContain(
"shell tool exited without reaching EOF within 500 ms; a background descendant may be holding the output pipe open",
)
expect(result.metadata.outputIncomplete).toBe(true)
}),
15_000,