Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore(debug): summarise before closing client response

Steven Enamakel46562cc6be5a
diff --git a/scripts/debug/capture-first-inference.mjs b/scripts/debug/capture-first-inference.mjs
index 9b381c5c7b..52212b1ba4 100644
--- a/scripts/debug/capture-first-inference.mjs
+++ b/scripts/debug/capture-first-inference.mjs
@@ -252,7 +252,9 @@ const server = http.createServer((req, res) => {
res.write(chunk);
});
upstreamRes.on('end', () => {
- res.end();
+ // Summarise before closing the client side, so anything waiting on
+ // the response (a test, a script driving turns) can read the record
+ // as soon as its call returns.
const text = Buffer.concat(pieces).toString('utf8');
const status = upstreamRes.statusCode || 502;
const record = {
@@ -270,6 +272,7 @@ const server = http.createServer((req, res) => {
record.response_body = path.join(captureAllDir, name);
}
appendSummary(record);
+ res.end();
});
upstreamRes.on('error', error => {
process.stderr.write(`[capture] upstream stream error: ${error.message}\n`);