feat(coding-agent): wire pi-langfuse agent tracing into MemSWE smoke runner - #18
Draft
LaloLalo1999 wants to merge 2 commits into
Draft
LaloLalo1999 wants to merge 2 commits into
LaloLalo1999 wants to merge 2 commits into
Conversation
…runner Add the pi-langfuse extension (pinned devDependency) and load it into the faux and minimax agent sessions so harness runs emit complete Langfuse observability: root agent, per-request generation, and per-tool observations covering prompt, provider requests, tool calls, final response, usage, and cost. This complements the existing OTLP harness spans (benchmark/memory/verifier/scoring) for a single Langfuse view of every action and datum on a run. Agent tracing activates only when pi-langfuse finds credentials (LANGFUSE_PUBLIC_KEY/SECRET_KEY env pair or a saved config.json) and is disabled by --no-otel-trace, so the deterministic faux path stays inert without credentials. The extension is loaded by package-manifest path to keep its @langfuse/@opentelemetry types out of the harness typecheck and to degrade gracefully if the optional dependency is absent. Records langfuse_tracing in agent-result.json, logs activation per session, documents setup in the README, and imports the already-exported SessionSpec/VerifierSpec types the runner uses. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DVPsBgxwNigbDrdgHM3xNj
|
Mention Blocks like a regular teammate with your question or request: @blocks review this pull request Run |
…angfuse # Conflicts: # packages/coding-agent/scripts/memswe-smoke-runner.ts
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.
Summary
Adds the
pi-langfuseextension (from https://pi.dev/packages/pi-langfuse) to the MemSWE harness so that runs emit complete observability to Langfuse for every action and datum on a run.The harness already exported its own benchmark/memory/verifier/scoring spans over OTLP (
memswe-trace-scaffold.ts), but the agent session itself loaded empty extensions (createMemSwerResourceLoader), so the agent-internal layer — prompts, LLM generations, tool calls, final response, usage, cost — was never captured. This PR closes that gap by loadingpi-langfuseinto the faux and minimax agent sessions, giving a single Langfuse view that combines:agent, per-requestgeneration, per-tooltoolobservations.Changes
packages/coding-agent/package.json: pinnedpi-langfuse@1.5.4as a devDependency (harness scripts run viatsx; not shipped indist/, and excluded from the publishednpm-shrinkwrap.json).scripts/memswe-langfuse-extension.ts(new):isLangfuseAgentTracingConfigured()gate +loadLangfuseExtensions()that loads the extension from its package manifest path (so its@langfuse/*/@opentelemetry/*types stay out of the harness typecheck and a missing optional dep degrades to an inert run).scripts/memswe-smoke-runner.ts: threadobservabilityEnabledinto the agent sessions; load the extension when configured; recordlangfuse_tracinginagent-result.json; log activation per session. Also imports the already-exportedSessionSpec/VerifierSpectypes the runner used but never imported.README.md: new Observability (Langfuse) subsection documenting both layers and setup.Activation & safety
pi-langfusefinds credentials: theLANGFUSE_PUBLIC_KEY/LANGFUSE_SECRET_KEYenv pair, or a saved~/.pi/agent/pi-langfuse/config.json.--no-otel-tracedisables it.SECRET_ENV_NAME_PATTERN), so traces never reach agent- or author-controlled commands.Verification
npm run check(biome, pinned-deps, ts-imports, shrinkwrap,tsgo --noEmit, browser-smoke): passes. The publishednpm-shrinkwrap.jsonis unchanged (devDependencies are excluded from the shrinkwrap walk).loadLangfuseExtensions()loads the extension with 0 errors and registers its 3 commands and all 19 observability event handlers (before_provider_request,tool_call,tool_result,agent_end, …);isLangfuseAgentTracingConfigured()returnsfalse/truefor empty/keyed env.memswe:smokerun and 5 suite tests require the sibling../memswebenchmark repo, which is not cloned in this environment (pre-existingENOENT, unrelated to this change).🤖 Generated with Claude Code
Generated by Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is enabled.