🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore: improve AGENTS.md (#12818)
Hassieb Pakzadf73452b797e5
diff --git a/.agents/AGENTS.md b/.agents/AGENTS.mdindex be7cfab6f4..6d408ea5bf 100644--- a/.agents/AGENTS.md+++ b/.agents/AGENTS.md@@ -6,26 +6,55 @@ continue to work while `.agents/` stays the source of truth.Langfuse is an open source LLM engineering platform for developing, monitoring,evaluating, and debugging AI applications.-Langfuse monorepo guidance for fast, safe code changes.## Maintenance Contract- `AGENTS.md` is a living document.+- Keep this file concise and router-like. Push narrow or conditional workflows+ into package-local `AGENTS.md` files or shared skills under `skills/`.- Update this file in the same PR when monorepo-level architecture, workflows,dependency boundaries, mandatory verification commands, or release/securityprocesses materially change.-- Update this file when user feedback adds a durable repo-level instruction that- future agents should follow. Update the relevant shared skill files under- `skills/` as well when that feedback changes a reusable workflow, checklist,- or decision rule that those skills should teach. Treat feedback as durable- when it changes the default workflow, review expectations, naming rules,- verification rules, or handoff conventions for future tasks. Do not edit this- file or shared skills for one-off task preferences.-- For package-local material changes, update the package-local `AGENTS.md` in+- Update this file and the relevant shared skills when user feedback introduces+ a durable repo-level default for future agents. Do not edit this file for+ one-off task preferences.+- For package-local material changes, update the nearest package `AGENTS.md` inthe same PR.-- If no material guidance changed, do not edit AGENTS files or shared skills.-## Project Structure & Module Organization+## Start Here By Task++- Repo-wide agent setup, `.agents/**`, provider shims, or MCP/bootstrap config:+ [`README.md`](README.md),+ [`skills/agent-setup-maintenance/SKILL.md`](skills/agent-setup-maintenance/SKILL.md)+- Backend/API work in `web/src/server/**`, `web/src/pages/api/public/**`,+ `worker/src/**`, or `packages/shared/src/**`:+ [`skills/backend-dev-guidelines/SKILL.md`](skills/backend-dev-guidelines/SKILL.md)+- Model pricing work in `worker/src/constants/default-model-prices.json`,+ `packages/shared/src/server/llm/types.ts`, or related pricing files:+ [`skills/add-model-price/SKILL.md`](skills/add-model-price/SKILL.md)+- Code review tasks:+ [`skills/code-review/SKILL.md`](skills/code-review/SKILL.md)+- Changelog drafting for completed feature branches:+ [`skills/changelog-writing/SKILL.md`](skills/changelog-writing/SKILL.md)+- ClickHouse schema/query review:+ [`skills/clickhouse-best-practices/SKILL.md`](skills/clickhouse-best-practices/SKILL.md)+- Monorepo/Turbo task graph changes:+ [`skills/turborepo/SKILL.md`](skills/turborepo/SKILL.md)+- User-visible frontend changes, Playwright review, or browser signoff:+ [`skills/frontend-browser-review/SKILL.md`](skills/frontend-browser-review/SKILL.md)+- Web UI and frontend entry points:+ `../web/AGENTS.md`+- Worker queues and processors:+ `../worker/AGENTS.md`+- Shared contracts, exports, schema, and migrations:+ `../packages/shared/AGENTS.md`+- EE-only work:+ `../ee/AGENTS.md`++Read the minimal set required for the task. More-specific package guides and+shared skills take precedence over this root file for their scoped areas.++## Project Structure```textlangfuse/@@ -38,11 +67,6 @@ langfuse/└─ scripts/ # Repo scripts```-- Package guides:- - `../web/AGENTS.md`- - `../worker/AGENTS.md`- - `../packages/shared/AGENTS.md`- - `../ee/AGENTS.md`- Dependency direction:- `web` -> `@langfuse/shared`, `@langfuse/ee`- `worker` -> `@langfuse/shared`@@ -50,46 +74,33 @@ langfuse/- `@langfuse/shared` -> no imports from `web`, `worker`, or `ee`- Queue payload schemas and queue-name contracts are owned by`packages/shared/src/server/queues.ts`.-- High-signal domain models live in:- - `packages/shared/src/domain/observations.ts`- - `packages/shared/src/domain/traces.ts`- - `packages/shared/src/domain/scores.ts`-- Database schema entry points live in:- - `packages/shared/prisma/schema.prisma`- - `packages/shared/clickhouse/migrations/clustered/*.sql`-- Shared package import surfaces:- - `@langfuse/shared`: client-safe/shared contracts, types, schemas, and- reusable utilities- - `@langfuse/shared/src/server`: server-only shared services, repositories,- queue helpers, logging, ingestion, auth, and runtime helpers- - `@langfuse/shared/src/db`: Prisma client singleton plus Prisma types- - `@langfuse/shared/src/env`, `@langfuse/shared/encryption`: focused env and- encryption helpers- - See `../packages/shared/AGENTS.md` for the full export map and when to use- each entrypoint+- High-signal shared entry points:+ - Domain models: `packages/shared/src/domain/{observations,traces,scores}.ts`+ - Postgres schema: `packages/shared/prisma/schema.prisma`+ - ClickHouse migrations:+ `packages/shared/clickhouse/migrations/{clustered,unclustered}/*.sql`- Architecture handbook:[langfuse.com/handbook/product-engineering/architecture](https://langfuse.com/handbook/product-engineering/architecture)with source markdown in`../langfuse-docs/content/handbook/product-engineering/architecture.mdx`- (GitHub mirror:- [architecture.mdx](https://github.com/langfuse/langfuse-docs/blob/4188c1ba453240c90a763a8067ef442d68839323/content/handbook/product-engineering/architecture.mdx#L4))-## Build, Test, and Development Commands+## Core Commands- Install deps: `pnpm install`- Dev all packages: `pnpm run dev`- Dev web only: `pnpm run dev:web`- Dev worker only: `pnpm run dev:worker`-- Codex environment bootstrap: `bash scripts/codex/setup.sh` (installs deps, Playwright Chromium, runs `pnpm --filter=shared run db:generate`, and refreshes workspace Prisma artifacts)-- Codex environment maintenance: `bash scripts/codex/maintenance.sh`-- Install repo-local Playwright browsers for agents: `pnpm run playwright:install`- Lint all: `pnpm run lint`- Typecheck all: `pnpm run typecheck` / `pnpm tc`-- To try running build, always run `pnpm run build:check` and verify that it succeeds. This does not impact running web servers-- If you have to rebuild all for testing, run: `pnpm run build`+- Build check: `pnpm run build:check`+- Full build: `pnpm run build`- Full reset/bootstrap (destructive): `pnpm run dx`+- Codex environment bootstrap: `bash scripts/codex/setup.sh`+- Codex environment maintenance: `bash scripts/codex/maintenance.sh`+- Install Playwright Chromium for agent browser review: `pnpm run playwright:install`Minimum verification matrix:+| Change scope | Minimum verification || --- | --- || `web/**` only | `pnpm --filter web run lint` + targeted web tests |@@ -99,114 +110,66 @@ Minimum verification matrix:| Public API contract (`web/src/pages/api/public/**`, `web/src/features/public-api/types/**`, `fern/apis/**`) | web lint + targeted server API tests + Fern update/regeneration; never hand-edit `generated/**` || Cross-package refactor (`web` + `worker` + `shared`) | `pnpm run lint` + `pnpm run typecheck` + targeted tests per impacted package |-## Coding Style & Naming Conventions+## Repo Rules- Keep changes scoped; avoid unrelated refactors.-- Prefer package-local implementation details in package AGENTS files.+- Prefer package-local implementation details in package `AGENTS.md` files.- Do not hand-edit generated/build artifacts:- `generated/*`- `web/.next/*`- `web/.next-check/*`- `*/dist/*`- `packages/shared/prisma/generated/*`+- Public API contract changes must update Fern sources in `fern/apis/**` and+ regenerated outputs; never hand-edit `generated/**`.+- Keep tests independent and parallel-safe.+- For bug fixes, write the failing test first, confirm it fails, then fix the+ bug.+- For user-visible frontend changes in `web/**`, review the affected flow in a+ real browser with the Playwright MCP server before signoff. Use+ `skills/frontend-browser-review/SKILL.md` and `../web/AGENTS.md` for the+ browser-review loop.+- Never commit secrets or credentials. Keep `.env*.example` files in sync with+ required env vars.++## Shared Agent Setup-## Testing Guidelines--- Keep each test independent and parallel-safe.-- Implement automated tests for every new feature and for material feature- behavior changes. If a test is genuinely not feasible, document the reason in- the PR description.-- Client tests contain `....clienttest.ts`-- When you write a test for a bug or similar, write the test that fails first.- Check that it fails. Only then fix the bug. Otherwise, the test is not good.--## Commit & Pull Request Guidelines+- `.agents/AGENTS.md` is the canonical root guide.+- Root `AGENTS.md` is a symlink to `.agents/AGENTS.md`.+- Root `CLAUDE.md` is a compatibility symlink to `AGENTS.md`.+- Shared agent/tool config lives in `config.json` and shared skills live in+ `skills/`.+- Project-scoped provider discovery files are generated local artifacts. Edit+ the canonical files under `.agents/` instead of editing generated tool+ directories by hand.+- If you change `.agents/config.json`, `skills/**`, or the shim-generation+ workflow, run:+ - `pnpm run agents:sync`+ - `pnpm run agents:check`+- Do not commit generated provider config or shim outputs under `.claude/`,+ `.cursor/`, `.codex/`, `.vscode/`, or `.mcp.json`.+- Durable cross-tool guidance belongs in root/package `AGENTS.md` files or+ `skills/**`, not only in tool-specific config directories.++## Commit, PR, and Release Rules- Commit messages and PR titles must follow Conventional Commits:`type(scope): description` or `type: description`.-- Use a lowercase conventional type such as `feat`, `fix`, `docs`, `refactor`,- `chore`, or `test`; keep the description concise and imperative.- PR titles are validated by `.github/workflows/validate-pr-title.yml`.-- Reference: https://www.conventionalcommits.org/en/v1.0.0/-- Include AGENTS.md updates in the same PR when guidance materially changes.- In PR descriptions, list impacted packages and executed verification commands.--## Docs Linking--- Public API contract changes must update Fern sources in `fern/apis/**` and regenerated outputs; do not hand-edit `generated/**`.-- Use repo-relative file paths in docs and runbooks.-- Our docs live in `../langfuse-docs/` which is a different repo. You may always access this.--## Agent-specific Notes--- Root `AGENTS.md` is monorepo-level only.-- Package-local runbooks, commands, and entry points belong in package `AGENTS.md` files.-- Keep guidance DRY: canonicalize to the most specific file.-- `.agents/AGENTS.md` is the canonical root guide.-- Root `AGENTS.md` is a symlink to `.agents/AGENTS.md`.-- Root `CLAUDE.md` is a compatibility symlink to `AGENTS.md` because Anthropic still documents `CLAUDE.md` as the project memory filename.-- Repo-owned Codex cloud bootstrap lives in `scripts/codex/setup.sh` and `scripts/codex/maintenance.sh`; contributors still configure the actual environment in the Codex UI.-- Shared agent/tool config lives under `config.json` and `skills/`; `pnpm install` regenerates tool-specific config shims via `pnpm run agents:sync` and validates them with `pnpm run agents:check`.-- Durable repo guidance that should apply across tools belongs in root/package `AGENTS.md` files or `skills/**`, not only in tool-specific config directories.-- Codex may create or refine shared skills under `skills/` when a repeated repo-specific workflow would help future agents. Keep shared skills tool-neutral and scoped to durable guidance.-- Shared agent setup overview: [`README.md`](README.md)-- Shared skill index: [`skills/README.md`](skills/README.md)-- Shared skills use a short `SKILL.md` entrypoint and should prefer focused `references/` docs and `scripts/` helpers over large compiled guides. Keep any local `AGENTS.md` concise and use it as a router, not a dump of all details.-- If a task matches one of the shared skill scopes below, read the linked `SKILL.md` before editing code, then follow its local references as needed:- - Backend and API work in `web/src/server/**`, `web/src/pages/api/public/**`, `worker/src/**`, or `packages/shared/src/**`: [`skills/backend-dev-guidelines/SKILL.md`](skills/backend-dev-guidelines/SKILL.md)- - Model pricing work in `worker/src/constants/default-model-prices.json`, `packages/shared/src/server/llm/types.ts`, or related pricing files: [`skills/add-model-price/SKILL.md`](skills/add-model-price/SKILL.md)- - Code review tasks: [`skills/code-review/SKILL.md`](skills/code-review/SKILL.md)- - Changelog drafting for completed feature branches: [`skills/changelog-writing/SKILL.md`](skills/changelog-writing/SKILL.md)-- If more than one skill matches, read the minimal set required.-- Claude should discover the shared repo skills via `.claude/skills/`, which projects `skills/` through symlinks at provider-specific discovery paths.--## Release Channel--- Release workflow is managed at root (`pnpm run release`).-- Langfuse Cloud deployments are triggered by pushes to `production` (`.github/workflows/deploy.yml`).-- Promote `main` to `production` via `.github/workflows/promote-main-to-production.yml` (manual `workflow_dispatch`).-- Use `pnpm run release:cloud` for CLI-triggered Cloud promotions with preflight branch/migration checks.-- Do not change release/versioning flow without updating this file and impacted package guides.--## GitHub Search--- use the github cli `gh search issues` to search github.--## GitHub Issues and Pull Requests--- Placeholder: add issue triage and PR hygiene conventions used by maintainers.--## Security and Configuration Tips--- Never commit secrets or credentials.-- Keep examples in `.env*.example` files in sync with required env vars.-- Follow `SECURITY.md` for vulnerability reporting/handling.--## Troubleshooting--- Lint/typecheck failures: run `pnpm run lint` and `pnpm run tc`.-- Schema/client drift: run `pnpm run db:generate`.-- Local infra issues: run `pnpm run infra:dev:up`; use `pnpm run dx` only when destructive reset is intended.--## Agent Browser Automation--- Project-scoped MCP configs are generated local artifacts at `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, and `.codex/config.toml`.-- Tool-specific runtime shims are generated local artifacts at `.claude/settings.json`, `.cursor/environment.json`, and `.codex/environments/environment.toml`.-- Tool-specific config directories such as `.claude/`, `.codex/`, `.cursor/`, and `.vscode/` remain because the tools discover project settings from those fixed paths.-- `config.json` is the source of truth for shared MCP/bootstrap settings; regenerate tool-specific files with `pnpm install` or `pnpm run agents:sync` instead of editing them by hand.-- Install Chromium into the default user-level Playwright cache with `pnpm run playwright:install`.-- `scripts/codex/setup.sh` runs the Playwright install step and an explicit `pnpm --filter=shared run db:generate` before workspace-wide `db:generate` for first-time Codex bootstrap.-- Playwright MCP traces and other browser session artifacts live under `.playwright-mcp/` and are gitignored.-- For user-visible frontend changes in `web/**`, review the affected flow in a real browser with the Playwright MCP server before signoff. Cover the primary changed path with a quick functional pass and a visual check for obvious regressions.-- For web flows, start `pnpm run dev:web` (or `pnpm run dev`) before asking an agent to drive the app in a browser.-- Optional: generate Playwright's planner/generator/healer agent files with `pnpm --filter web exec playwright init-agents --loop=<claude|vscode|copilot|opencode>`.--## Git Notes--- Do not use destructive git commands (for example `reset --hard`) unless explicitly requested.+- Release workflow is managed at root with `pnpm run release`.+- Promote `main` to `production` via+ `.github/workflows/promote-main-to-production.yml` or+ `pnpm run release:cloud`.+- Do not change release/versioning flow without updating this file and impacted+ package guides.++## Git and Tooling Notes++- Use `gh search issues` for GitHub issue search.+- Do not use destructive git commands such as `reset --hard` unless explicitly+ requested.- Do not revert unrelated working-tree changes.- Keep commits focused and atomic.--## Cursor Rules--- Any remaining `.cursor/rules/*.mdc` files should stay as thin wrappers around shared `AGENTS.md`, package docs, or shared skills rather than owning durable repo guidance directly.+- Remaining `.cursor/rules/*.mdc` files should stay thin wrappers around shared+ docs or skills rather than owning durable repo guidance directly.diff --git a/.agents/skills/README.md b/.agents/skills/README.mdindex af3b23db58..0f97919fdd 100644--- a/.agents/skills/README.md+++ b/.agents/skills/README.md@@ -23,6 +23,25 @@ Shared skills should use progressive disclosure:## Available Skills+### agent-setup-maintenance++Use for:+- `.agents/config.json`, `.agents/AGENTS.md`, or `.agents/README.md`+- shared skill additions or shared skill routing changes+- generated shim behavior in `scripts/agents/sync-agent-shims.mjs`+- install-time agent sync behavior and provider discovery paths++Open: [agent-setup-maintenance/SKILL.md](agent-setup-maintenance/SKILL.md)++### frontend-browser-review++Use for:+- user-visible changes in `web/**`+- Playwright MCP browser review before signoff+- checking visible regressions in layout, styling, navigation, or responsive behavior++Open: [frontend-browser-review/SKILL.md](frontend-browser-review/SKILL.md)+### backend-dev-guidelinesUse for:diff --git a/.agents/skills/agent-setup-maintenance/SKILL.md b/.agents/skills/agent-setup-maintenance/SKILL.mdnew file mode 100644index 0000000000..86735e01dc--- /dev/null+++ b/.agents/skills/agent-setup-maintenance/SKILL.md@@ -0,0 +1,65 @@+---+name: agent-setup-maintenance+description: |+ Shared workflow for editing Langfuse's repo-owned agent setup under `.agents/`.+ Use when changing AGENTS files, shared skills, `.agents/config.json`,+ generated shim behavior, provider discovery paths, or install-time agent sync.+---++# Agent Setup Maintenance++Use this skill when changing the shared agent setup for the repository.++## Start Here++- Read [`../../README.md`](../../README.md) for the shared config and shim model.+- Read root [`../../AGENTS.md`](../../AGENTS.md) for repo-level expectations.+- Inspect [`../../../scripts/agents/sync-agent-shims.mjs`](../../../scripts/agents/sync-agent-shims.mjs)+ before changing generated outputs or provider discovery behavior.+- Inspect [`../../../scripts/postinstall.sh`](../../../scripts/postinstall.sh)+ and [`../../../package.json`](../../../package.json) when changing install-time+ sync behavior.++## Workflow++1. Edit the canonical files under `.agents/`, not generated provider outputs.+2. Keep root `AGENTS.md` and `CLAUDE.md` as discovery symlinks; do not turn+ them back into manually maintained copies.+3. Treat tool-specific directories such as `.claude/`, `.cursor/`, `.codex/`,+ `.vscode/`, and `.mcp.json` as generated discovery surfaces unless the tool+ requires a truly tool-specific feature.+4. Keep root `AGENTS.md` concise and router-like. Move detailed or conditional+ workflows into shared skills or package `AGENTS.md` files.+5. When adding or changing a shared skill, update `skills/README.md` and link+ it from root `AGENTS.md` if it changes the default reusable workflow.+6. When shared setup behavior changes materially, update `README.md` and+ contributor-facing docs in the same PR.++## Docker / Install-Time Constraint++- `pnpm install` runs in environments that may not contain the full repo source+ tree.+- In Docker builds, Turbo's pruned install stage can run root `postinstall`+ before `scripts/` and `.agents/` are available in the image.+- Keep install-time agent setup logic robust in those pruned contexts: skip+ cleanly when the required repo-owned files are not present.++## Required Verification++Run after changing shared agent setup:++- `pnpm run agents:sync`+- `pnpm run agents:check`++Run additional verification when relevant:++- `pnpm run postinstall` when install-time behavior changes+- targeted tests for any scripts you changed++## Design Rules++- Prefer one repo-owned source of truth over duplicated provider-specific files.+- Keep shared setup tool-neutral where possible.+- Only keep provider-specific files in source control when the provider requires+ a fixed discovery path or feature that cannot be expressed through the shared+ setup model.diff --git a/.agents/skills/frontend-browser-review/SKILL.md b/.agents/skills/frontend-browser-review/SKILL.mdnew file mode 100644index 0000000000..f644a034f8--- /dev/null+++ b/.agents/skills/frontend-browser-review/SKILL.md@@ -0,0 +1,60 @@+---+name: frontend-browser-review+description: |+ Shared workflow for browser-based review of user-visible frontend changes in Langfuse.+ Use when a change affects UI behavior, layout, styling, navigation, or browser-visible+ regressions and should be checked with the Playwright MCP server before signoff.+---++# Frontend Browser Review++Use this skill when a change affects what users see or do in the browser.++## Start Here++- Read [`../../../web/AGENTS.md`](../../../web/AGENTS.md) for web-specific+ entry points and test commands.+- Use the workspace `playwright` MCP server configured from the repo-owned+ shared agent setup.++## When To Use It++- UI changes in `web/**`+- Layout, styling, or responsive behavior changes+- Changes to navigation or page flows+- Bug fixes where the failure mode is visible in the browser+- Final signoff for user-visible frontend work++## Review Loop++1. Start the app with `pnpm run dev:web` unless an existing local server is+ already running.+2. Install Chromium with `pnpm run playwright:install` if Playwright has not+ been set up on the machine yet.+3. Open the primary changed flow with the Playwright MCP server.+4. Exercise the main happy path affected by the change.+5. Check for obvious visual regressions:+ - broken layout or spacing+ - banner overlap or viewport anchoring issues+ - missing loading, empty, or error states+ - broken responsive behavior on narrow widths+6. If the page changed materially, inspect the resulting UI state and compare+ it against the intended behavior from the task or existing patterns.+7. If the browser session fails, inspect traces and artifacts under+ `.playwright-mcp/`.++## Output Expectations++Report:++1. What flow you reviewed+2. Whether the primary flow worked+3. Any visible regressions or follow-up risks+4. If review was blocked, exactly what prevented browser verification++## Scope Notes++- This skill complements, not replaces, targeted tests and linting.+- For implementation details, stay in `web/AGENTS.md` and package-local skills.+- Use this as the browser-signoff workflow, not as a generic frontend coding+ guide.diff --git a/web/AGENTS.md b/web/AGENTS.mdindex 2afef07021..7c52c18d43 100644--- a/web/AGENTS.md+++ b/web/AGENTS.md@@ -53,6 +53,8 @@ Use root [AGENTS.md](../AGENTS.md) for monorepo-level rules.## Package-Local Skills+- Shared browser-review workflow for user-visible frontend changes:+ [`../.agents/skills/frontend-browser-review/SKILL.md`](../.agents/skills/frontend-browser-review/SKILL.md)- React composition and component API design:[`web/.agents/skills/vercel-composition-patterns/SKILL.md`](.agents/skills/vercel-composition-patterns/SKILL.md)- React/Next.js performance and rendering best practices:@@ -60,7 +62,8 @@ Use root [AGENTS.md](../AGENTS.md) for monorepo-level rules.Read these package-local skills before substantial frontend refactors when thetask involves component composition, reusable component APIs, rendering-performance, bundle size, or React/Next.js performance patterns.+performance, bundle size, React/Next.js performance patterns, or browser-based+signoff of user-visible changes.## Web Conventions- Put net-new feature code under `src/features/<feature>/*`; put broadly reusable@@ -115,7 +118,9 @@ performance, bundle size, or React/Next.js performance patterns.1. Prefer `src/features/<feature>/*` for feature-local code.2. Put broadly reusable components in `src/components/*`.3. Keep server logic near feature server folders when possible.-4. Review the affected user flow in a real browser with the Playwright MCP server before signoff, including a quick functional pass and a visual regression check.+4. Review the affected user flow in a real browser with the Playwright MCP+ server before signoff. Use+ `../.agents/skills/frontend-browser-review/SKILL.md`.### Agent browser loop1. Start the app with `pnpm run dev:web` unless an existing local server is already running.