Langfuse Continuous Optimizer for Openclaw

An automated optimization engine that tunes model routing and prompt usage based on real-time LangFuse performance data.

ekalb81
v0.0.2
Mar 2, 2026
1
917
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install langfuse-continuous-optimizer

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install langfuse-continuous-optimizer using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Langfuse Continuous Optimizer?

The Langfuse Continuous Optimizer is a sophisticated tool designed to create a closed-loop system for AI agent performance. By ingesting observations and evaluator scores directly from LangFuse, this skill enables your agents to adapt their behavior dynamically. It bridges the gap between observability and execution, allowing developers to automate the complex trade-offs between cost, quality, and latency within their Openclaw Skills ecosystem.

This skill is entirely self-contained, providing both a policy builder and a continuous optimization daemon. It generates task-level routing policies that ensure your agent uses the most efficient model for specific sub-tasks, such as planning, tool selection, or summarization, based on historical performance data rather than static configurations.

Langfuse Continuous Optimizer Use Cases

  • Automatically switching between high-reasoning models and cost-effective models based on task performance.
  • Implementing safe promotion cycles for new prompt versions and routing logic.
  • Reducing system-wide latency by identifying tasks where smaller models outperform larger ones.
  • Maintaining a persistent memory of optimization cycles to prevent policy churn and enable rollback reasoning within Openclaw Skills.

How Langfuse Continuous Optimizer Works

  1. Telemetry Ingestion: The optimizer pulls recent observations and performance scores from the LangFuse API within a defined time window.
  2. Policy Synthesis: It normalizes the telemetry data and constructs a staged routing policy artifact.
  3. Safety Guardrails: The system compares the newly generated staged policy against the current live policy to ensure quality gains.
  4. Automated Promotion: If the promotion criteria are met and the feature is enabled, the live policy is updated.
  5. Memory Persistence: Every cycle is recorded to local memory, allowing the optimizer to make informed decisions over long durations.

Langfuse Continuous Optimizer Setup

To integrate this into your existing Openclaw Skills, ensure you have your LangFuse credentials ready. Install the dependencies and use the following commands to start the optimization loop:

# Run a single optimization cycle
python scripts/langfuse_openclaw_optimizer.py run-once \
  --langfuse-host https://us.cloud.langfuse.com \
  --window-hours 24 \
  --out-dir ~/.openclaw/optimizer \
  --live-policy-path ~/.openclaw/llm_routing_policy.json \
  --promote-live-policy

# Launch the optimizer as a continuous background daemon
python scripts/langfuse_openclaw_optimizer.py daemon --interval-min 30 --save-config

Required Environment Variables:

  • LANGFUSE_PUBLIC_KEY
  • LANGFUSE_SECRET_KEY

Langfuse Continuous Optimizer Data Schema & Taxonomy

The skill manages several key artifacts to ensure consistent operation and transparency:

Artifact Format Description
llm_routing_policy.json JSON The production-ready routing policy consumed by the LLM runtime.
staged_policy.json JSON The candidate policy generated during the current cycle for evaluation.
memory.json JSON A persistent state file tracking cycle history and performance gains.
config.json JSON Persisted CLI flags and configuration settings.

Langfuse Continuous Optimizer Advanced Features

  • Daemon mode for hands-off, continuous background optimization cycles.
  • Explicit promotion gating to prevent destructive updates without meeting specific quality thresholds.
  • Task-level tagging support for granular control over planning, retrieval, and generation workflows.
  • Integration with OpenRouter and OpenClaw runtimes via hot-reloading policy files.
  • Local snapshotting of all LangFuse telemetry for offline analysis and auditing.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Requires
Github Stars: 0
forks: 0

Featured*