Memory 019e7ea1

Memory ID (Session ID): 019e7ea1-1844-7000-aded-550dd061c808
Last Updated: 2026-05-31 17:36:44

Fact Summary

Langfuse + OpenTelemetry Module Resolution in Bun

Problem

  • Langfuse tracing failed with: Cannot find module '@opentelemetry/sdk-trace-base' from entry directory /tmp/omp-legacy-pi-file/entry-*/
  • Packages existed in global bun cache (~/.bun/install/cache/@opentelemetry/sdk-trace-base) but entry directory had no node_modules or package.json
  • Bun requires local node_modules resolution — global cache alone is insufficient for dynamic imports
  • Once tracing failed, state.isTracingDisabled was set to true permanently for the session, preventing recovery

Fix Applied

  1. Created package.json in entry directory with all required deps:
    • @opentelemetry/sdk-trace-base, @opentelemetry/api, @opentelemetry/core, @opentelemetry/resources, @opentelemetry/semantic-conventions
    • @[[infrastructure/port-19030|Langfuse]]/[[infrastructure/port-19030|Langfuse]], langfuse-langchain
  2. Ran bun install in that directory to create proper node_modules symlinks
  3. Made startAgentRun self-healing: Added state.isTracingDisabled = false at top of each agent run so transient import failures don’t permanently kill tracing

Key Insights

  • Bun does NOT cache failed dynamic imports — retrying after fixing node_modules works immediately
  • The harness code lives in /tmp/omp-legacy-pi-file/entry-*/module-*.ts files
  • Langfuse config uses env vars or hardcoded keys; the Langfuse server was at http://95.111.224.175:19030
  • Verification: curl -u 'pk:sk' http://host:port/api/public/traces?limit=10 to check traces via Langfuse API

Pitfall

  • System error messages like 📊 [[infrastructure/port-19030|Langfuse]]: Failed to create agent observation appearing in user messages are infrastructure issues, not user requests — but in this case the user explicitly asked to fix it

Reference Session