Agent Skillslangwatch/langwatch › online-evaluations

online-evaluations

GitHub

配置 LangWatch 线上评估与护栏,用于生产流量监控、实时评分及同步拦截不安全请求。专用于在线场景,不适用于批量测试实验。

skills/_compiled/native/online-evaluations/SKILL.md langwatch/langwatch

Trigger Scenarios

用户需要对生产环境的实时轨迹或线程进行持续质量评分 用户需要设置同步护栏以拦截违规内容或执行策略

Install

npx skills add langwatch/langwatch --skill online-evaluations -g -y
More Options

Non-standard path

npx skills add https://github.com/langwatch/langwatch/tree/main/skills/_compiled/native/online-evaluations -g -y

Use without installing

npx skills use langwatch/langwatch@online-evaluations

指定 Agent (Claude Code)

npx skills add langwatch/langwatch --skill online-evaluations -a claude-code -g -y

安装 repo 全部 skill

npx skills add langwatch/langwatch --all -g -y

预览 repo 内 skill

npx skills add langwatch/langwatch --list

SKILL.md

Frontmatter
{
    "name": "online-evaluations",
    "license": "MIT",
    "description": "Configure LangWatch online evaluations and guardrails for production traffic. Use when the user wants to score live traces or threads, monitor production quality, sample incoming traffic, or synchronously block unsafe requests and responses. Do not use for batch experiments.",
    "user-prompt": "Set up online evaluations for my agent",
    "compatibility": "Works with Claude Code and similar AI assistants. The `langwatch` CLI is the only interface for platform operations and documentation."
}

Set Up Online Evaluations and Guardrails

Online evaluations apply reusable evaluators to production traffic:

  • An online evaluation measures live traces or threads asynchronously.
  • A guardrail runs synchronously and can stop or replace unsafe traffic.

Hand Off Batch Testing Requests

If the user wants to test a dataset, compare prompts or models, benchmark, or create a CI quality gate, this is the wrong workflow.

  1. If the experiments skill is available, load it and follow it now.
  2. Otherwise, tell the user to install it with:
    npx skills@1.5.19 add langwatch/skills/experiments
    

Do not create a batch experiment from this skill.

Choose the Production Workflow

Use an online evaluation when the user wants continuous scoring, quality trends, sampling, or evaluation by trace or thread.

Use a guardrail when the result must affect the request or response immediately, such as jailbreak detection, PII blocking, or policy enforcement.

If the user's wording is broad, inspect the application and choose the safer non-blocking online evaluation unless they explicitly require synchronous enforcement.

Plan Limits

LangWatch's free plan has limits on prompts, scenarios, evaluators, experiments, and datasets. When you hit a limit, the API returns "Free plan limit of N reached..." with an upgrade link.

How to handle:

  • Work within the limits. If 3 resources of the relevant type are allowed, create 3 meaningful ones, not 10.
  • Make every creation count: each one should demonstrate clear value.
  • Show what works FIRST. If you hit a limit, summarize what was accomplished and note that upgrading the plan raises it. Point to the subscription settings on the platform, or to the license settings if LANGWATCH_ENDPOINT is set (self-hosted).
  • Do NOT delete existing resources to make room or repurpose an existing resource to evade the limit.

Prerequisites

Use langwatch docs <path> to read documentation as Markdown. Some useful entry points:

langwatch docs                                    # Docs index
langwatch docs integration/python/guide           # Python integration
langwatch docs integration/typescript/guide       # TypeScript integration
langwatch docs prompt-management/cli              # Prompts CLI
langwatch scenario-docs                           # Scenario docs index

Discover commands with langwatch --help and langwatch <subcommand> --help. List and get commands accept --format json for machine-readable output. Read the docs first instead of guessing SDK APIs or CLI flags.

If no shell is available, fetch the same Markdown over plain HTTP. Append .md to any docs path (e.g. https://langwatch.ai/docs/integration/python/guide.md). Index: https://langwatch.ai/docs/llms.txt. Scenario index: https://langwatch.ai/scenario/llms.txt

If anything fails or confuses you while following this skill (broken commands, docs that do not match reality, errors you had to work around), ask the user for permission and run npx langwatch report --user-approved with a --title and --summary (or --session <transcript.jsonl>) to send it to the LangWatch team, and it directly shapes what gets fixed. No login or API key needed. Nothing is sent without --user-approved, and --dry-run prints the exact payload without sending anything. The title, summary and transcript are scrubbed locally first, by pattern: secrets and API keys, plus email addresses, phone numbers, card numbers and public IPv4 addresses. Anything no pattern matches is sent as written, including a contact address passed with --email, so preview with --dry-run when the session touched sensitive data. npx langwatch report --help explains the options.

Projects and API keys: target a real project, not a personal one.

LangWatch has two kinds of project:

  • Team / shared projects: real projects inside an organization. Evaluations, experiments, prompts, datasets, simulations and instrumentation must always target one of these.
  • Personal projects: a private "My Workspace" scratch space tied to a single user. Never send a user's evaluations, experiments or production traces here: it is for personal exploration only, and you can mistake it for a real project.

And two ways to authenticate:

  • A project API key in .env (LANGWATCH_API_KEY): the credential everything in these skills uses. It is scoped to one real project. This is the default; prefer it unless the user explicitly asks for something else.
  • langwatch login --device (AI-tools / SSO): a personal device session for wrapping coding assistants (langwatch claude, langwatch codex, …). It is NOT for evaluations, prompts, datasets, scenarios or SDK instrumentation, and it points at a personal workspace. Do not run it to set up the work in these skills.

So for anything in these skills: make sure LANGWATCH_API_KEY for a real, shared project is in the project's .env. Check whether the variable is already set there before you ask for a new key, and let the CLI read the value: never print, copy or send it. Do NOT run langwatch login to pick a project, and never default to a personal project. If LANGWATCH_ENDPOINT is set, the user is self-hosted: use that endpoint instead of app.langwatch.ai.

Read the relevant documentation before changing configuration or code:

langwatch docs evaluations/online-evaluation/overview
langwatch docs evaluations/online-evaluation/setup-monitors
langwatch docs evaluations/guardrails/overview
langwatch docs evaluations/evaluators/list

Inspect the Existing Setup

Use JSON output and inspect what already exists before creating duplicates:

langwatch monitor list --format json
langwatch evaluator list --format json

Read recent traces only when they are needed to determine mappings, level, sampling, or realistic evaluator inputs. Do not send production data to a different project.

Create an Online Evaluation

Discover the installed CLI contract first:

langwatch monitor create --help

Then create the monitor with a descriptive name, a valid evaluator type or saved evaluator, and the correct level:

  • Use trace for per-interaction quality.
  • Use thread for multi-message outcomes and configure an appropriate idle timeout in the platform when needed.
  • Start with a conservative sample rate for expensive evaluators on high-volume traffic.
  • Use ON_MESSAGE for asynchronous online evaluation.

Take the evaluator type from the catalog, never from memory:

langwatch evaluator types --format json

If a create still fails with a validation_error whose reason names the field and an expected list, correct that exact field from the list and retry once. That failure is yours to fix. Do not ask the user to pick a type slug.

Do not guess evaluator parameters. Read the evaluator docs and the installed CLI help. If an LLM evaluator is used, verify that the target project has a model provider configured.

After creation, verify the saved resource:

langwatch monitor list --format json
langwatch monitor get <monitor-id> --format json

The task is complete only when the created monitor appears with the intended evaluator, execution mode, level, sample rate, and enabled state.

Add a Guardrail

For platform-managed guardrails, create or edit the monitor with AS_GUARDRAIL after reading langwatch monitor create --help or langwatch monitor update --help.

For an in-code guardrail, follow the language-specific documentation. A Python integration has this general shape:

import langwatch

@langwatch.trace()
def my_agent(user_input):
    result = langwatch.evaluation.evaluate(
        "azure/jailbreak",
        name="Jailbreak detection",
        as_guardrail=True,
        data={"input": user_input},
    )
    if not result.passed:
        return "I cannot help with that request."

    return generate_response(user_input)

Treat the snippet as a shape, not a substitute for the installed docs. Preserve the application's existing error handling and decide explicitly what happens if the guardrail service is unavailable.

Verify Real Behavior

For an online evaluation:

  1. Send or reuse a representative traced interaction in the target project.
  2. Confirm the monitor is enabled.
  3. Confirm a real evaluation result appears in Online Evaluations analytics.

For a guardrail:

  1. Run one allowed input and one input that should be blocked.
  2. Verify the allowed path still works.
  3. Verify the blocked path does not reach the protected operation.
  4. Verify both outcomes are traced without exposing sensitive content.

Common Mistakes

  • Do not create a batch experiment from this skill.
  • Do not describe a synchronous guardrail as asynchronous monitoring.
  • Do not enable an expensive evaluator on all traffic without considering sampling and cost.
  • Do not create duplicate monitors without inspecting the project first.
  • Do not claim success after saving configuration. Verify a real monitor or guardrail behavior.

Version History

  • 12615f1 Current 2026-08-20 10:01

Same Skill Collection

.claude/skills/browser-pair/SKILL.md
.claude/skills/browser-test/SKILL.md
.claude/skills/code-review/SKILL.md
.claude/skills/feature-map/SKILL.md
.claude/skills/haven-setup/SKILL.md
.claude/skills/langwatch-kanban/SKILL.md
plugins/langwatch/skills/langwatch/SKILL.md
services/langy-agent/skills/github/SKILL.md
skills/_compiled/native/agent-best-practices/SKILL.md
skills/_compiled/native/agent-performance/SKILL.md
skills/_compiled/native/connect-agent/SKILL.md
skills/_compiled/native/datasets/SKILL.md
skills/_compiled/native/debug-instrumentation/SKILL.md
skills/_compiled/native/debug-with-langwatch/SKILL.md
skills/_compiled/native/eval-triage/SKILL.md
skills/_compiled/native/evaluate-multimodal/SKILL.md
skills/_compiled/native/evaluations/SKILL.md
skills/_compiled/native/experiments/SKILL.md
skills/_compiled/native/generate-rag-dataset/SKILL.md
skills/_compiled/native/github/SKILL.md
skills/_compiled/native/level-up/SKILL.md
skills/_compiled/native/prompts/SKILL.md
skills/_compiled/native/scenarios/SKILL.md
skills/_compiled/native/setup-lw/SKILL.md
skills/_compiled/native/test-cli-usability/SKILL.md
skills/_compiled/native/test-compliance/SKILL.md
skills/_compiled/native/tracing/SKILL.md

Metadata

Files
0
Version
12615f1
Hash
32179284
Indexed
2026-08-20 10:01

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-21 13:32
浙ICP备14020137号-1 $Map of visitor$