Repository navigation
[M5b] Agent Forge: persisted trace history in the Trace tab - #301
Merged
Merged
Conversation
Every Forge run also writes the SDK's trace files under .lousho/agents/<id>/traces; GET /agents/:id/traces[/:traceId] reads them (only inside that folder); the Trace tab lists past runs next to the waterfall, with span kind and error status. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lexity threshold Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Agent Forge keeps the trace of every run and the Trace tab can reopen any of them. Closes #227.
RunManager.makeTraceExporter()now fans out to the WebSocket exporter and to M5a'sfileTraceExporter({ dir: <baseDir>/.lousho/agents/<agentId>/traces }). BothAgentExecutor.executecall sites share that one helper. Newserver/traceStore.ts(directory, fan-out exporter, list/read throughlistTraces/readTracefrom@lousho/build-ai-agent/traces).GET /agents/:id/traces?limit=N(summaries, newest first, default 20, max 200, no file paths) andGET /agents/:id/traces/:traceId(spans). 404 for an unknown agent or trace, 400 for an invalid id (and for an id prefix that matches several runs).emitSpanforwardskindandstatus;SpanEventgains both (optional), plusTraceSummaryPayload/TraceDetailPayload.orderSpansForWaterfall; spans show their kind and failed spans use the existing--dangercolour. The list reloads when the agent changes and when a run ends. The canvas node mapping is unchanged.### Routestable, CHANGELOG entry. No heading changes.llms*.txtregenerated.Security
Trace files hold prompt and tool content by default. The server only reads under
<baseDir>/.lousho/agents/<agentId>/traces: the agent id passes the existingisValidAgentIdguard, the trace id must match[A-Za-z0-9-]{1,128}and is only matched against file names found in that folder (never joined into a path), and the absolute file path is stripped from the response.Verification
Run on the branch after merging the latest
origin/main:npx tsc --noEmit,npm run lint(zero warnings),npm run build,npm run build --workspace=packages/create-lousho-agent,npm run test:types(64 passed),npm run docs:verify-snippets -- --skip-build(210 type-check, 8 run),npm run docs:llms:check: all pass.npm run test:coverage: first run had one failure,src/tools/built-in/http.test.ts("rejects near the configured timeout", 4.7 s against a 2 s bound) under machine load; it passes alone (23/23). The coverage run on the merged tree (--coverage.reportOnFailureconfig): 230 files passed, 3288 tests passed, 6 skipped.npm run fallow: exit 0. It first flagged mySpanRow(cyclomatic 12, CRAP 43); split into helpers, now 0 above threshold.typecheckclean,typecheck:serverclean,npm run test -- --run119 passed (14 files),npm run test:server130 passed (15 files).npm run test:e2e:studionot run: the specs inapps/agent-forge/e2edo not touch the Trace tab (the ticket asks for it only if they do).pack-smokenot run: no change to exports, bin, package.json or the build.New tests:
server/__tests__/traces.test.ts(a run throughRunManagerwrites a file under the agent folder; list; detail withkind; error status; path-like ids are 400; unknown agent/trace 404; ambiguous prefix 400),runRegistry.test.ts(span messages carrykind, and nostatuson a successful run),src/components/debug/__tests__/TraceHistory.test.tsx(list rendering, Live entry only while active, selecting a trace renders its spans with kind and error colour, list reloads when a run ends, error note). Note: the SDK sets a spanstatusonly on failure, so a successful run's messages havekindbut nostatus.Studio check (real build, offline)
npm run build:studio, then three traces produced withcreateAgent+mockModel+fileTraceExporterinto<scratch>/.lousho/agents/demo/traces, andnode bin/lousho.js studio --port 47931started from<scratch>:GET /agents/demo/traces-> 200, three summaries newest first (e.g.{"traceId":"c344fc16-...","name":"invoke_agent demo","status":"ok","modelCalls":2,"toolCalls":1,"inputTokens":82,"outputTokens":8}), nofilefield;?limit=1-> one.GET /agents/demo/traces/<id>-> 200, spans withkind(clientforchat,internalfor the rest) andstatus{code:"error",...}on the failingexecute_tool; a unique prefix also resolves.No trace 'deadbeef' for agent 'demo'; unknown agent -> 404;..%2F..%2F..%2Fdemo.yaml,..%5C..%5Cx,%2e%2eas trace ids -> 400Invalid trace id;..%2Fdemoand/agents/../tracesas agent -> 400Invalid agent id.untitled-agent; the Trace tab list gained a row (ok,19ms · 1 model · 10/6 tokens) when the run stopped and the waterfall showedinvoke_agent(internal) andchat(client). After a full page reload the waterfall was empty, the list still held the run, and choosing it brought the spans back. With a trace containing a failed tool call copied into the agent's folder, theexecute_tool boomrow readerror, got thetrace-row-errorclass and its bar wasrgb(217, 45, 32)(--danger). Screenshots timed out in this environment, so this was checked through the DOM, not by eye.Docs site follow-up
No new page and no heading changes. Edited only:
docs/agent-forge.md(new "Trace history" paragraph inside step 4 of the walkthrough, an extended sentence and two table rows under### Routes). The Arabic page needs the same paragraph and rows.Live test spend: none (no live calls).
🤖 Generated with Claude Code