Skip to content

Add Laminar tracing to processMessage() pipeline#5

Merged
not-reed merged 1 commit intomainfrom
feat/laminar-tracing
Apr 8, 2026
Merged

Add Laminar tracing to processMessage() pipeline#5
not-reed merged 1 commit intomainfrom
feat/laminar-tracing

Conversation

@not-reed
Copy link
Copy Markdown
Owner

@not-reed not-reed commented Apr 8, 2026

Summary

  • Adds opt-in Laminar tracing to every processMessage() call via a null-object wrapper (tracing.ts) — zero overhead when LAMINAR_API_KEY is unset
  • Three spans per turn: process_message (root), context_assembly (memory/observation counts), llm_call (full preamble the model saw + tokens/cost)
  • Scheduler-fired calls tagged with scheduler + scheduleId for easy filtering in the dashboard
  • scheduleId added to ProcessMessageOpts and passed through from the scheduler
  • New env vars: LAMINAR_API_KEY, LAMINAR_BASE_URL (documented in .env.construct.example)
  • Self-hosted under Apache 2.0 — one Laminar instance supports multiple Construct instances via projects

Motivation

Personality quirks (redundant reminders, repetition, temporal confusion) are hard to debug because there's no visibility into what context the model actually received. The llm_call span captures the full preamble, enabling trace replay to understand exactly why the agent made a decision.

Self-hosting setup

git clone https://github.com/lmnr-ai/lmnr
cd lmnr
docker compose up -d
# Dashboard: http://localhost:5667
# Create a project per Construct instance, copy API key
LAMINAR_API_KEY=<from-dashboard>
LAMINAR_BASE_URL=http://localhost:8000

Test plan

  • just check passes (typecheck + lint + fmt + tests)
  • Omitting LAMINAR_API_KEY produces no errors or behavior change
  • With Laminar running locally, a CLI message produces a trace with 3 spans in the dashboard
  • A scheduler-fired message appears with scheduler tag and schedule_id attribute

🤖 Generated with Claude Code

Instruments every processMessage() call with three spans:
- process_message (root, EXECUTOR) — input message, source, tags, usage
- context_assembly — observations, active messages, memory counts, skill count
- llm_call (LLM) — full preamble sent to model, response, tokens, cost

Scheduler-fired calls are tagged with "scheduler" + scheduleId so they
can be filtered separately in the dashboard — useful for debugging
reminder suppression decisions.

Fully opt-in: omit LAMINAR_API_KEY to disable with zero overhead (null
object pattern in tracing.ts). Self-hosted under Apache 2.0 via Docker.
One Laminar instance supports multiple Construct instances via projects.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying sprawl with  Cloudflare Pages  Cloudflare Pages

Latest commit: 34ddccf
Status: ✅  Deploy successful!
Preview URL: https://df37b8c5.sprawl.pages.dev
Branch Preview URL: https://feat-laminar-tracing.sprawl.pages.dev

View logs

@not-reed not-reed merged commit ca6bb89 into main Apr 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant