Skip to content

📡 feat: Add Managed Langfuse Configuration - #13084

Draft
danny-avila wants to merge 9 commits into
devfrom
danny-avila/langfuse-config
Draft

danny-avila wants to merge 9 commits into
devfrom
danny-avila/langfuse-config

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

I implemented tenant-level and UI-managed per-agent Langfuse configuration for Managed LibreChat, covering app config, agent persistence, UI editing, runtime merge behavior, and sensitive secret handling.

  • Added top-level langfuse app config with enabled, publicKey, secretKey, and baseUrl, plus the env-ref example in librechat.example.yaml.
  • Persisted optional per-agent langfuse config through schema, types, create/update validation, and agent form defaults.
  • Added an Advanced-panel Langfuse section for enabling tracing and editing public key, secret key, and base URL.
  • Preserved blank secret updates and redacted saved secrets from create/update/get/list/duplicate responses.
  • Resolved effective tenant + agent Langfuse config during run setup, including env refs, partial agent overrides, explicit disable, and warn-and-disable behavior for missing credentials.
  • Added API, config, resolver, and frontend payload tests around the new behavior.

Related Linear issue: AI-927
Depends on agents runtime PR: LibreChat-AI/agents#169

Change Type

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Testing

  • npm run build:packages
  • npm run build:client
  • npm run test:packages:data-provider -- --runInBand src/config.spec.ts --testPathIgnorePatterns=.codex
  • cd client && npm run test:ci -- --runInBand --runTestsByPath src/components/SidePanel/Agents/__tests__/AgentPanel.helpers.spec.ts
  • npm run test:api -- --runInBand server/controllers/agents/v1.spec.js --testPathIgnorePatterns=.codex
  • cd packages/api && npx jest --coverage=false --runInBand src/agents/run.spec.ts
  • npm run test:packages:api -- --runInBand src/agents/run.spec.ts --testPathIgnorePatterns=.codex ran the package suite: 178 passed, 1 skipped, 4993 tests passed

Test Configuration:

  • Node/npm from local workspace
  • Local branch: danny-avila/langfuse-config

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have made pertinent documentation changes
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

Copilot AI review requested due to automatic review settings May 12, 2026 01:23
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 03e21214d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread client/src/components/SidePanel/Agents/AgentPanel.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds tenant-level Langfuse tracing configuration plus optional per-agent overrides, including UI editing, API persistence/validation, runtime resolution (tenant + agent merge with env-ref support), and secret redaction behavior.

Changes:

  • Introduces langfuse in app config schema/types (and example YAML) and threads it through app config loading.
  • Persists optional per-agent langfuse overrides (schema/types + API validation), with write-only secretKey redaction in responses.
  • Adds an Agent “Advanced” panel UI for Langfuse settings and expands unit/integration tests for config + agent endpoints + runtime resolution.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/data-schemas/src/types/app.ts Adds langfuse to AppConfig typing.
packages/data-schemas/src/types/agent.ts Adds per-agent langfuse typing.
packages/data-schemas/src/schema/agent.ts Persists per-agent langfuse in Mongo schema.
packages/data-schemas/src/app/service.ts Includes langfuse in resolved app config object.
packages/data-provider/src/types/assistants.ts Exposes per-agent langfuse type in shared Agent types.
packages/data-provider/src/schemas.ts Adds Langfuse defaults to agent form defaults.
packages/data-provider/src/config.ts Adds langfuse to config schema + bumps config version.
packages/data-provider/src/config.spec.ts Adds configSchema test coverage for langfuse.
packages/api/src/agents/validation.ts Allows langfuse in agent create/update validation.
packages/api/src/agents/run.ts Resolves effective tenant+agent Langfuse config (env refs, overlays, warn/disable).
packages/api/src/agents/run.spec.ts Adds unit tests for effective Langfuse config resolution.
librechat.example.yaml Documents tenant-level langfuse config and bumps version.
client/src/locales/en/translation.json Adds UI strings for Langfuse section.
client/src/components/SidePanel/Agents/AgentSelect.tsx Hydrates Langfuse form values without exposing stored secret.
client/src/components/SidePanel/Agents/AgentPanel.tsx Includes Langfuse in create/update payload composition.
client/src/components/SidePanel/Agents/Advanced/AgentLangfuse.tsx New UI component for Langfuse settings in Advanced panel.
client/src/components/SidePanel/Agents/Advanced/AdvancedPanel.tsx Renders the Langfuse section in the Advanced panel.
client/src/components/SidePanel/Agents/tests/AgentPanel.helpers.spec.ts Adds payload normalization test coverage for Langfuse fields.
client/src/common/agents-types.ts Adds langfuse to the agent form type.
api/server/controllers/agents/v1.spec.js Adds tests for persistence + secret redaction + list behavior.
api/server/controllers/agents/v1.js Normalizes Langfuse config and redacts secretKey in responses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/data-provider/src/schemas.ts Outdated
Comment thread client/src/components/SidePanel/Agents/AgentPanel.tsx Outdated
Comment thread packages/data-provider/src/config.spec.ts Outdated
@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13084 index is now live on the MCP server.
Deploy run

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c809b7606

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/api/src/agents/run.ts Outdated
@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13084 index is now live on the MCP server.
Deploy run

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dfc297ce2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/server/controllers/agents/v1.js Outdated
@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13084 index is now live on the MCP server.
Deploy run

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

1 similar comment
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13084 index is now live on the MCP server.
Deploy run

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c2fdc92cd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/server/controllers/agents/v1.js Outdated
Comment thread client/src/components/SidePanel/Agents/AgentSelect.tsx Outdated
@danny-avila

Copy link
Copy Markdown
Collaborator Author

Audit update pushed in bc636c9.

Resolved the valid findings from the automated review:

  • Preserved three-state langfuse.enabled handling so routine saves keep tenant inheritance, while explicit false still disables tracing per agent.
  • Added a UI clear-secret action and server-side clear sentinel so saved per-agent Langfuse secrets can be removed and tenant defaults can take back over.
  • Moved Langfuse normalization/redaction out of the legacy JS controller into typed packages/api helpers, deduplicating encrypted-value detection and string helpers.
  • Kept direct UI secret values encrypted at rest, preserved exact env-var refs, and redacted secrets in create/update/revert/avatar responses.
  • Fixed runtime resolution to decrypt only agent-origin encrypted values, skip env expansion for decrypted literal secrets, warn-and-disable on bad decrypts, and resolve fields concurrently.
  • Shared the Langfuse schema, added HTTPS/env-ref validation for baseUrl, and expanded resolver/controller/schema/UI tests.
  • Cleaned the hardcoded docs-link color and type references called out in the review.

Audited but did not change:

  • Feature-gating the Langfuse UI, because the product requirement for this PR is explicitly UI-managed per-agent configuration.
  • Adding langfuse to upstream AgentInputs, because that lives in the dependent agents SDK PR/package update.
  • CryptoKey caching, because it is pre-existing crypto internals and broader than this PR.

Local verification:

  • npm run build:packages
  • npm run build:data-provider
  • cd packages/api && npx jest --coverage=false --runInBand src/agents/run.spec.ts src/agents/langfuse.spec.ts src/agents/validation.spec.ts
  • npm run test:packages:data-provider -- --runInBand src/config.spec.ts --testPathIgnorePatterns=.codex
  • cd api && npx jest --coverage=false --runInBand server/controllers/agents/v1.spec.js
  • cd client && npm run test:ci -- --runInBand --runTestsByPath src/components/SidePanel/Agents/__tests__/AgentPanel.helpers.spec.ts
  • Targeted npx eslint on the touched files
  • git diff --check

Note: full cd client && npm run typecheck still fails on pre-existing unrelated diagnostics outside this patch.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13084 index is now live on the MCP server.
Deploy run

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc636c9a2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/api/src/agents/langfuse.ts
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13084 index is now live on the MCP server.
Deploy run

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ddb7090d64

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/api/src/agents/langfuse.ts Outdated
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc2c19d841

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/server/controllers/agents/v1.js Outdated
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13084 index is now live on the MCP server.
Deploy run

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 001c3b5401

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread client/src/components/SidePanel/Agents/Advanced/AgentLangfuse.tsx
@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13084 index is now live on the MCP server.
Deploy run

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13084 index is now live on the MCP server.
Deploy run

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila
danny-avila changed the base branch from main to dev May 13, 2026 17:25
@PylotLight

Copy link
Copy Markdown

Any chance of this one being completed?
We were hoping to get a proper langfuse integration for better observaility for agent setups and tool calling etc.
Worth trying to connect the SDK on our own or wait for this PR?

@danny-avila

Copy link
Copy Markdown
Collaborator Author

Any chance of this one being completed? We were hoping to get a proper langfuse integration for better observaility for agent setups and tool calling etc. Worth trying to connect the SDK on our own or wait for this PR?

You don't need this PR to configure langfuse, you can start already: https://www.librechat.ai/docs/configuration/langfuse

This PR is to add langfuse from admin panel and/or on a per-agent basis.

@PylotLight

PylotLight commented May 28, 2026 •

Copy link
Copy Markdown

Apologies, but what if you don't want to trace all conversations but only specific ones?
i.e for a production deployment, capturing every message would be too intenstive, so would need a way to refine/capture only sepcific selected traces?

Also we might need to pass an extra header via Proxy-Authorization, is that possible?

Ignore all that, raised PR for what I'm looking for.
LibreChat-AI/agents#209

This branch has not been deployed

No deployments
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.

3 participants