Skip to content

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

feat(debug): add capture command to debug CLI

Steven Enamakel4c5770b418ad
diff --git a/scripts/debug/capture-first-inference.mjs b/scripts/debug/capture-first-inference.mjs
index 93c4425376..9b420500ee 100644
--- a/scripts/debug/capture-first-inference.mjs
+++ b/scripts/debug/capture-first-inference.mjs
@@ -123,7 +123,7 @@ function upstreamPath(requestUrl) {
* sticky-routing key — it must be identical across the turns of one thread, so
* seeing it change call to call is a finding, not noise.
*/
-export function summarizeRequestBody(body) {
+function summarizeRequestBody(body) {
try {
const json = JSON.parse(body.toString('utf8'));
return {
@@ -145,7 +145,7 @@ export function summarizeRequestBody(body) {
* field), the final usage block, and any error object. Works on a partial body
* too, so a stream cut off mid-way still reports what arrived.
*/
-export function summarizeResponseBody(text) {
+function summarizeResponseBody(text) {
const out = { provider: null, prompt_tokens: null, cached_tokens: null, error: null };
const absorb = json => {
if (json && typeof json === 'object') {
diff --git a/scripts/debug/cli.sh b/scripts/debug/cli.sh
index 55abe8fbb6..14288690de 100755
--- a/scripts/debug/cli.sh
+++ b/scripts/debug/cli.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Dispatcher for `pnpm debug <cmd> <args…>`.
# Agent-friendly wrappers around the project's test/run scripts.
-# Commands: unit | e2e | rust | logs | harness-cache-audit
+# Commands: unit | e2e | rust | logs | harness-cache-audit | capture
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -33,6 +33,11 @@ Commands:
goals-live [options]
Live-test the memory_goals flow (list/add/edit/delete + reflect enrichment),
printing the goals_agent's thoughts, tool calls, token usage and cost.
+ capture [--help]
+ Loopback proxy between the core and its inference backend: dumps the
+ exact request bodies the harness sends and prints one line per
+ inference response (serving endpoint, TTFB, prompt/cached tokens,
+ prompt_cache_key). Configure with CAPTURE_* env vars; `--help` lists them.
Flags common to runners:
--verbose Stream full output to stdout in addition to the log file.
@@ -58,6 +63,9 @@ case "$cmd" in
agent-prepare-context-audit)
exec node "$here/agent-prepare-context-audit.mjs" "$@"
;;
+ capture)
+ exec node "$here/capture-first-inference.mjs" "$@"
+ ;;
goals-live)
exec node "$here/goals-live.mjs" "$@"
;;