perf(server): omit repeated OpenCode progress logs (#9689)

This commit is contained in:
Theo Browne authored and GitHub committed 2026-09-04 07:26:51 -07:00
1 parent 44dc8ae259
commit ec8b2119c3
3 files changed
+71 -1

No files matched your search

@@ -341,6 +341,19 @@ describe("EventNdjsonLogger", () => {
},
threadId,
);
yield* native.write(
{
event: {
type: "message.part.updated",
payload: {
properties: {
part: { type: "tool", state: { status: "running", output: "progress" } },
},
},
},
},
threadId,
);
yield* native.write({ type: "turn.completed", id: "native-final" }, threadId);
yield* store.close();
@@ -362,6 +375,51 @@ describe("EventNdjsonLogger", () => {
}),
);
it.effect("keeps OpenCode tool input, final output, and errors in native logs", () =>
Effect.gen(function* () {
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-provider-log-"));
const basePath = NodePath.join(tempDir, "events.log");
const threadId = ThreadId.make("thread-tool-lifecycle");
try {
const store = yield* makeEventNdjsonLogStore(basePath, { batchWindowMs: 0 });
const native = store.logger("native");
const input = { command: "run-build" };
const states = [
{ status: "pending", input },
{ status: "completed", input, output: "Build complete", time: { start: 1, end: 2 } },
{ status: "error", input, error: "Build failed", time: { start: 3, end: 4 } },
{ status: "unknown", input },
null,
];
const events = states.map((state) => ({
event: {
type: "message.part.updated",
payload: { properties: { part: { type: "tool", state } } },
},
}));
for (const event of events) {
yield* native.write(event, threadId);
}
yield* store.close();
const payloads = NodeFS.readFileSync(
ownedLogPath(basePath, "thread-tool-lifecycle"),
"utf8",
)
.trim()
.split("\n")
.map((line) => parseLogLine(line).payload);
assert.deepEqual(
payloads,
events.map((event) => encodeUnknownJson(event)),
);
} finally {
NodeFS.rmSync(tempDir, { recursive: true, force: true });
}
}),
);
it.effect("contains hostile event accessors inside guarded serialization", () =>
Effect.gen(function* () {
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-provider-log-"));
@@ -229,7 +229,15 @@ function shouldPersist(stream: EventNdjsonStream, event: unknown): boolean {
const part = Reflect.get(properties, "part");
if (typeof part !== "object" || part === null) return true;
const partType = Reflect.get(part, "type");
return partType !== "text" && partType !== "reasoning";
if (partType === "text" || partType === "reasoning") return false;
if (partType === "tool") {
// Running snapshots repeat growing output. Pending and terminal states stay in the log.
const state = Reflect.get(part, "state");
if (typeof state === "object" && state !== null) {
return Reflect.get(state, "status") !== "running";
}
}
return true;
}
return true;
+4
View File
@@ -230,6 +230,10 @@ sandbox.
## OpenCode server ownership and catalog
Native OpenCode event logs skip text deltas and running tool snapshots. Pending, completed,
and failed tool states remain, including final output and errors. This filter does not change
events sent to clients or orchestration storage.
Each OpenCode provider instance owns one lazy local server for catalog discovery and
text-generation helpers through [`OpenCodeServerOwner.ts`][opencode-server-owner]. Concurrent
borrowers share startup. The server closes 30 seconds after the last borrower releases it, or