Langfuse launches AI Gateway Learn more
December 1, 2026

How we built cross-harness skill tracing without pushing complexity to the user

Understanding the influence a skill had on an agent run should be straightforward, but it proved surprisingly hard to implement across a skill's lifecycle stages and across different harnesses.

Picture Tobias KleselTobias Klesel

We've done our fair share of skill engineering ourselves at Langfuse, through our open-source Langfuse skill (hosted on GitHub) and Halo, our in-app agent (read more in How we built Langfuse Halo). Whenever we changed instructions or added references, we wanted to answer the same two things:

  1. which skills did an agent actually use, and
  2. when it used one, did version 2 perform better than version 1?

So we started on a journey to get these questions easily answered in Langfuse. But every harness and SDK, including Halo, loaded and reported skills differently. So how do you trace skill usage in a unified way?

What "using a skill" actually means at runtime

Under the Agent Skills specification, a skill is a directory with a SKILL.md file (YAML frontmatter with a name and description, plus Markdown instructions) and optional files in references/ or scripts/.

my-skill/Agent Skill directory
SKILL.mdrequired
Entrypoint metadata and instructions
YAML frontmatter (name, description)Exposed at startup for discovery
Markdown bodyLoaded when the model invokes the skill
references/optional
Supporting docs opened on demand
scripts/optional
Helper scripts executed for specific steps

To avoid overloading the model's context window with instructions it may not need, skills use progressive disclosure. At startup, the agent only exposes each skill's name and description in the system prompt or tool list. When the model decides a skill applies, it reads SKILL.md. If the task needs more detail, it opens reference files or runs scripts.

Because of this behavior, you can divide the skill lifecycle into five stages:

End-to-end coverage by Langfuse Skill Management
01Installed or fetched
Install via CLI / API

Skill files sit on disk or are fetched from the registry.

02Available
Recorded on GENERATION

Skill name and description appear in the system prompt or tool list.

03Requested (intent)
Computed in trace UI

Model calls a skill-loading tool in its output.

04Loaded
Recorded on TOOL

Tool call succeeds and returns non-null output.

05Evicted or compacted
Not covered today

Session compacts context; skill may be dropped or re-attached.

Collapsing those stages into one flag hides why a skill failed to help:

  • Installed, never discovered: the folder sits on disk, or the agent's context budget dropped its description before the model saw it.
  • Available, never requested: the model saw the description and ignored it, usually because the description was too vague to match the user's phrasing (something we hit when evaluating our own Langfuse skill).
  • Requested, never loaded: the model called the skill tool, but the file never reached context.

Separating model intent from actual loads

Counting a model's tool call as a skill load skews your analytics. Between the model asking for a skill and the instructions entering context, plenty can fail: the path may not exist, a sandbox rule can block the read, the loader can return an error, or (in harnesses like Gemini CLI) the user can deny the activation consent prompt.

In Langfuse, we split this into three signals:

SignalRecorded onCapturing mechanism
Available skillsGENERATIONReported on the model span as the agent's available skill catalog.
Requested skillsGENERATIONParsed in the trace UI from the generation's tool-call output, splitting available skills into Requested and Not requested (with requested file paths).
Loaded skillsTOOLRecorded at ingestion when a subsequent tool span matches a recognized skill loader, has no ERROR level, and returns non-null output (name, version, and file path).

A generation observation reporting three available skills and a request for langfuse v2 in the Preview view.

A generation observation showing three available skills, with langfuse v2 split under Requested from the model's loadSkill tool call.

A loadSkill tool observation showing langfuse v2 and the loaded SKILL.md file in the trace's Preview view.

The subsequent loadSkill tool observation recording langfuse v2 and SKILL.md as loaded once the call succeeds.

A non-error, non-null tool result is still a proxy, not a guarantee. Early on, we scanned plain-text tool outputs for strings like "not found" to catch soft failures, then removed that check because free-text matching was too brittle. If a custom tool swallows an exception and returns an error string with a normal status, it still counts as loaded.

Compaction and eviction

Even with availability, intent, and loads separated, long sessions still introduce the open challenges of compaction and eviction. Once a conversation hits context limits and compacts history, whether a skill loaded earlier is still in context depends on the harness:

Session timeline across context compactionTurns 1 to 7
Skill in context
Still in context?
Skill loadedTOOL span recorded
CompactionDropped or re-attached?
Turn 1Session starts
Turn 2: Skill loadedTOOL span recorded

Skill stays in context across turns 2 to 5.

CompactionContext limit reached

Turns 6+: Still in context? Depends on whether the harness drops or re-attaches the skill.

  • Claude Code re-attaches the most recent invocation of each skill after auto-compaction, keeping up to 5,000 tokens per skill inside a 25,000-token combined budget (most recent first), so older skills can be dropped. If the model calls a skill again and its rendered content hasn't changed, Claude Code inserts a short "already loaded" note instead of repeating the body.
  • Mastra treats skill loading as stateless: instructions sit in conversation history as a tool result, and if compaction trims them out, the agent has to call the skill tool again.

Langfuse doesn't model compaction or eviction today. Answering whether skill X was still in context on generation 14 would require harness-specific compaction hooks or scanning every generation's full message history for earlier skill payloads, and neither has a standard format yet.

Every harness loads skills differently

Tracking availability, intent, and loads is already tricky for one agent. Supporting the mix of coding agents and frameworks teams run makes it much harder.

The Agent Skills spec standardizes the folder layout on disk, not how an agent reads it at runtime. Every harness invents its own discovery budget, tool name, argument schema, and message format:

HarnessLoad mechanismContext delivery
Claude Code / Agent SDKSkill ({skill}), Read, or /nameisMeta: true user row; short tool ack
Anthropic APIbash: cat .../SKILL.md in containerServer-side container tool result
OpenAI CodexShell exec_command (cat), or $skillTool result, or <skill> prompt block
CursorFile read or shell toolTool result
Gemini CLIactivate_skill ({name}) + consent prompt<activated_skill> XML tool result
OpenCodeskill ({id} from path) or @skill-idTool result
LangChain Deep Agentsread_file ({file_path}) via SkillsMiddlewareTool result
Mastraskill, skill_read, or load_skillTool result
Vercel AI SDKHarnessAgent inline skills, or uploadSkillDepends on harness adapter

Those differences make it challenging to get to a unified skill logging design:

  1. Tool names and argument keys don't match across frameworks.
  2. Some agents never call a skill tool. Codex shells out to cat, and Anthropic's API loads skills inside a server-side container with no client tool span.
  3. The tool result isn't always the skill. Claude Code's Skill tool returns a short ack while the rendered body lands in a separate isMeta: true message.
  4. Some loads produce no tool span at all. Slash commands (/skill-name), subagent preloads, and Codex $skill blocks inject skills directly into messages.

Hooks everywhere vs. ingestion-side parsing

Once you see that fragmentation, you run into the main design question for skill tracing: who should report a skill load?

  • Active reporting via hooks everywhere. Every SDK, framework, and coding-agent plugin emits structured events when skills are offered and whenever a file loads. In theory, that's the cleanest signal: exact, version-aware, and able to catch non-tool loads like slash commands or prompt injections. In practice, almost nobody would wire it up. Every harness needs custom load hooks, every custom agent loop has to instrument its own file readers, existing OpenTelemetry pipelines emit nothing until rewritten, and you duplicate data that's already sitting in your tool spans.
  • Pure ingestion-side parsing. Ask nothing from the client and infer everything on the server from prompts and tool spans. Zero client work sounds appealing, but it breaks in two places. First, the server can't reliably extract which skills were offered from arbitrary system prompts. Second, when an agent calls Read(".agents/skills/my-skill/SKILL.md"), the span gives you a path on disk, not whether that folder holds version 1 or version 2 in Langfuse. Guessing skill loads from generic Read calls without knowing which skills exist also flags ordinary source files as skill loads.

Active catalog in, passive loads out

Neither extreme works on its own, so we split the job in two: active reporting for the available catalog, passive ingestion-side parsing for loads.

Active: available skill catalogReported once via skills_available on model and tool spans
Passive: existing tool spansSkill, loadSkill, skill_read, Read, Codex cat
1Carries skill names and versions
2Carries tool name, arguments, output, and error status
Langfuse ingestion pipelineChecks for non-error, non-null output, allow-lists generic file paths against the catalog, and resolves loaded names to skill versions
3Stored on model calls
4Stored on tool calls (catalog discarded after linking)
GENERATION observationsAvailable skills; trace UI splits them into Requested and Not requested from tool calls
TOOL observationsLoaded skill version and file path; feeds filters and per-version Usage analytics
Active: available skill catalogReported once via skills_available on model and tool spans
1Carries skill names and versions
Passive: existing tool spansSkill, loadSkill, skill_read, Read, Codex cat
2Carries tool name, arguments, output, and error status
Langfuse ingestion pipelineSuccess check, path allow-listing from catalog, and version resolution
3Stored on model calls
GENERATION observationsAvailable skills; trace UI splits them into Requested and Not requested
4Stored on tool calls (catalog discarded after linking)
TOOL observationsLoaded skill version and file path; feeds Usage analytics

Harnesses don't natively emit a standardized list of available skills on their spans. To enable full skill tracing in Langfuse, your application attaches one OpenTelemetry attribute, langfuse.observation.skills_available, listing the skill names (and optional versions) available to the agent, either through the Langfuse SDK helpers or directly on your spans. That is the only client-side step: clients and hooks never emit a separate load event.

Instead, Langfuse's ingestion pipeline parses incoming tool observations automatically. It recognizes dedicated skill tools (such as Skill, loadSkill, and skill_read), generic file readers like Read, and literal cat commands inside Codex shell observations without executing any shell code.

One detail makes this split work: clients attach skills_available to both model spans and skill-loading tool spans, even though Langfuse only persists the catalog on GENERATION observations. On a TOOL span, the catalog does two things before ingestion discards it:

  1. It allow-lists generic file and shell reads. For Read, readFile, and Codex cat commands, ingestion inspects the path segments, checks for a skills/<name>/... layout, and requires an unambiguous match against the catalog. Ordinary Read calls on application code never turn into phantom skill loads.
  2. It resolves a tool call to a specific skill version. Named tools like Skill or loadSkill still record name-only loads without a catalog, which show up on traces and name filters. When the catalog is present on the tool span, ingestion matches the loaded name to its exact skill version, which powers per-version Usage analytics.

Tradeoffs we accepted

Centralizing load detection in ingestion gives us skill tracing across custom agents and all of the prominent harnesses without asking teams to rewrite their tools. It also comes with three tradeoffs:

  • Loader drift needs new parser rules. Harnesses whose tool names or argument shapes aren't in our rule table yet, such as activate_skill, read_file, OpenCode's {id}, or Mastra's load_skill, are missed until we add them.
  • Shell scanning is heuristic. Scanning literal cat arguments never executes shell code, which keeps ingestion safe, but it matches command text rather than proving the file was read.
  • Non-tool loads stay invisible to ingestion. Slash commands (/skill-name), prompt-injected $skill blocks, and server-side Anthropic container executions never emit a client-side TOOL span.

Putting load detection in client SDKs or harness plugins would let each integration report exact loads locally (including custom or non-tool loaders), but every new harness shape would require SDK updates and client upgrades across teams. Keeping the parser inside Langfuse flips that equation: adding a new harness rule once fixes tracing for everyone without waiting on client upgrades.

Carrying skill versions into traces

Knowing that a specific skill loaded only gets you halfway if you can't tell whether the agent ran version 2 or version 1.

In Langfuse, each skill version is an immutable snapshot of SKILL.md and its supporting files, promoted or rolled back with movable labels like staging and production through the UI, API, CLI, or MCP. Because Langfuse is the registry and observability backend rather than the runtime skill loader, carrying those version numbers into traces works in one of two setups depending on how your agent loads skills: filesystem harnesses that read folders from disk, or API-driven agents that fetch skills in memory.

1. Filesystem harnesses (Claude Code, Codex, Cursor, Claude Agent SDK). Coding agents read plain folders on disk (.agents/skills/<name>/), and SKILL.md itself has no Langfuse version field. To resolve versions on disk, installing skills with @langfuse/cli (langfuse skills install) writes local version metadata next to those folders recording which Langfuse version landed in each directory. At runtime, the Langfuse SDK's discoverSkills (or discover_skills in Python) reads that directory and its recorded versions into a { name, version } catalog. Passing that catalog to LangfuseSpanProcessor and wrapping the agent run in propagateAttributes automatically attaches those versions to every model and tool span:

import { NodeSDK } from "@opentelemetry/sdk-node";
import { LangfuseSpanProcessor } from "@langfuse/otel";
import { discoverSkills } from "@langfuse/otel/node";
import { propagateAttributes } from "@langfuse/tracing";
import { runAgent } from "./agent";

const skills = await discoverSkills({ dir: ".agents/skills" });

const sdk = new NodeSDK({
  spanProcessors: [
    new LangfuseSpanProcessor({ skills: { available: skills } }),
  ],
});
sdk.start();

try {
  await propagateAttributes({ attachSkills: true }, () => runAgent());
} finally {
  await sdk.shutdown();
}

2. API-driven agents. Agents that load skills directly in memory, including Halo, our Mastra-based in-app assistant, don't read from disk at all. Instead, they call langfuse.api.skills.get(...) at run start, which returns the resolved version number alongside the skill's files. The agent pins that version for the full run so SKILL.md and its reference files always come from the same revision, and passes { name, version } directly into propagateAttributes.

In both setups, propagateAttributes attaches skills in-process only. They aren't sent over OpenTelemetry baggage across service boundaries, and an explicit span attribute always overrides propagated or processor-level defaults.

Usage analytics out of the box

With the available catalog reported on generations, successful loads parsed from tool spans, and version numbers carried into both, the two questions we started with now answer themselves directly in each skill version's Usage tab:

  1. Which skills did an agent actually use? Comparing available vs. loaded observation counts shows whether a skill is being offered and ignored, or actually loaded. Per-file load counts break that down further so you can see which reference docs and scripts agents open and which ones never get touched.
  2. Did version 2 perform better than version 1? Because every loaded tool observation resolves to a specific skill version, you can switch between versions in the sidebar, filter linked generations and tool spans by version, compare outcomes across production traffic in custom dashboards, or trigger evaluations through skill-version webhooks whenever a new version ships.

The Usage tab for langfuse v2 showing version history, available versus loaded observation counts, per-file load breakdown, and linked observations.

The Usage tab for langfuse v2 alongside its version history, showing available vs. loaded observation counts, per-file load breakdown across SKILL.md, references, and scripts, and linked observations.

Try it out

Follow the get-started guide to create your first versioned skill, or read the Skill Management overview and skill tracing docs to connect it to your agent traces.

If your harness loads skills in a format we don't recognize yet, open a GitHub issue with the tool name and a sample input and output. If you like working on this kind of problem, we are hiring.


Was this page helpful?