feat(tracing): emit ls_skill_name for skill invocations - #25
Open
Paarth Ahuja (paarth-a) wants to merge 5 commits into
Open
Paarth Ahuja (paarth-a) wants to merge 5 commits into
Paarth Ahuja (paarth-a) wants to merge 5 commits into
Conversation
Add skillNameFromToolCall() to extract an invoked skill's name from a tool call and emit it as the ls_skill_name run metadata key, so skill usage is queryable via RunQueryStats (group_by metadata path=ls_skill_name). Same key name as the Claude Code and deepagents integrations, so one query spans all coding agents. PROVISIONAL: Codex does not yet emit a distinct skill-invocation span — the rollout only carries skill *catalog* events (list_skills_response, skills_update_available). The extractor is gated on a "skill"/ "invoke_skill" tool name and stays inert for ordinary tools until the real shape is confirmed against a rollout (see the TODO in metadata.ts). Regenerates dist/index.mjs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts: # plugins/tracing/dist/index.mjs
…ollouts) Codex emits no skill-invocation span, no skill/invoke_skill tool, and records no list_skills_response catalog event. Confirmed against two fresh 0.128.0 rollouts (explicit "use openai-docs" + implicit skill-creator, model-chosen): a skill invocation surfaces only as an exec_command reading .../skills/<name>/SKILL.md. - skillNameFromToolCall: gate on exec_command + read commands only (reject writes/edits/deletes and non-exec tools); skill name = dir before /SKILL.md under a skills/ root - trace.ts: dedup per skill per turn (one activation, one tag) - test/sessions/2026/07/23: sanitized real rollouts (explicit + implicit) - metadata.test.ts + skills.test.ts: unit + end-to-end coverage - validator.json: describe the confirmed mechanism (drop PROVISIONAL) - dist/index.mjs: rebuilt Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Paarth Ahuja (paarth-a)
marked this pull request as ready for review
July 23, 2026 20:12
Trim the verbose doc/inline comments on skillNameFromToolCall + the skill tests; the investigation rationale now lives in the PR #25 description/discussion. No behavior change (comment-only + regenerated bundle). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- share isRecord via utils/isRecord.ts (used in metadata.ts + trace.ts), drop the trace.ts-local copy - SKILL_MD_PATH accepts Windows path separators as well as POSIX - clarify the per-skill-per-turn dedup comment (tag first read of each skill) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Emit an
ls_skill_namerun-metadata key for skill invocations, so skill usage is queryable in LangSmith via the run-stats endpoint.skillNameFromToolCall()(inmetadata.ts) derives the skill name;trace.tswires it onto the tool run.Why
Today skill usage isn't aggregatable — the skill name isn't in any queryable metadata field or tag. With
ls_skill_nameyou can run:for per-skill activation counts. It tags the
exec_commandthat loads a skill — the activation — so it measures how often each skill is invoked, not the latency / tokens / cost of the skill's full downstream workflow.ls_skill_nameis the sharedcoding-agent-v1contract key, so once each coding-agent integration emits it, one query can span them.How skills surface in Codex (confirmed)
Captured two fresh Codex 0.128.0 rollouts — one naming a skill explicitly (
openai-docs), one where the model chose a skill implicitly (skill-creator). In both:skill/invoke_skilltool, and nolist_skills_responsecatalog event recorded in the rollout.exec_commandreading the skill's definition file, e.g.cat …/skills/<name>/SKILL.md.So the extractor keys on that read:
exec_commandread commands (cat/sed/rg/…); writes, in-place edits, redirects, and deletes never match, so authoring or removing a skill isn't counted as using it.SKILL.md, required under askills/path segment.SKILL.mdseveral ways in one turn).SKILL.mdfor some non-use reason — is rare.Changes
plugins/tracing/src/metadata.ts—skillNameFromToolCall():exec_commandread →ls_skill_nameplugins/tracing/src/trace.ts— wire onto the tool run + per-turn dedupplugins/tracing/test/fixtures/validator.json—ls_skill_namecontract key (contextual, tool-scoped)plugins/tracing/test/metadata.test.ts— unit coverage (reads vs writes/deletes, non-exec tools, verb-in-name)plugins/tracing/test/skills.test.ts— end-to-end over the real rolloutsplugins/tracing/test/sessions/2026/07/23/rollout-skill-{explicit,implicit}.jsonl— sanitized fixturesplugins/tracing/dist/index.mjs— regenerated bundleTest plan
tsc --noEmitvitest(metadata + skills + contract + trace suites)npm run build(bundle regenerated; skill code present)Companion to the Claude Code plugin's skill-usage tracing.