Skip to content

feat: expose skill and subagent names in tool observations - #40

Open
suolongcn wants to merge 13 commits into
langfuse:mainfrom
suolongcn:fix/38-semantic-tool-names
Open

suolongcn wants to merge 13 commits into
langfuse:mainfrom
suolongcn:fix/38-semantic-tool-names

Conversation

@suolongcn

@suolongcn suolongcn commented Sep 18, 2026 •

Copy link
Copy Markdown

OpenCode exports skill invocations as skill. Subagent invocations are exported as task with subagent_type in OpenCode v1 and as subagent with agent in OpenCode v2, preventing Langfuse dashboards from grouping usage by skill name or subagent type.

Name these tool observations skill:<name>, task:<subagent_type>, or subagent:<agent>, trimming surrounding whitespace and falling back to the original tool name for missing, blank, or non-string values. Preserve the original inputs and tool metadata. The shared span creation path covers execution hooks and observations reconstructed from completed or failed message parts.

Add integration coverage for semantic names, fallback values, unchanged inputs and metadata, parent relationships, duplicate hook/message events, and OpenCode v1/v2 subagent payloads.

Validation:

  • pnpm run format
  • pnpm run build
  • pnpm run lint
  • pnpm run test:integration (39 tests passed)

Closes #38.

Local Langfuse verification

Verified commit ab787fc against local OpenCode 2 and self-hosted Langfuse 4.37.0. The built local plugin was loaded through the OpenCode 2 plugin system while keeping the published-package config unchanged, then real OpenCode 2 skill and subagent executions were exported through the Langfuse span processor and checked in Langfuse.

  • OpenCode v1 payloads still resolve semantic names as skill:<name> and task:<subagent_type>.
  • OpenCode v2 skill payloads resolve semantic names as skill:<name>.
  • OpenCode v2 subagent payloads now resolve semantic names as subagent:<agent>; OpenCode 2 exports sub-agent invocations as subagent nodes with an agent input field, not v1-style task nodes with subagent_type.
  • Missing, blank, or non-string semantic fields fall back to the original tool name.
  • Original inputs and tool metadata are preserved; duplicate hook/message events are still de-duplicated.
  • pnpm run format, pnpm run build, and pnpm run test:integration passed locally with 39 integration tests.

Skill input and output(opencode v1)

image

Subagent input and output(opencode v1)

image

Skill input and output(opencode v2)

image

Subagent input and output(opencode v2)

Please note that in OpenCode V2, sub-agent invocations are no longer represented as task nodes in the trace, but as subagent nodes. The semantic observation name is expected to be subagent:<agent>.
image

@CLAassistant

CLAassistant commented Sep 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@bezbac

bezbac commented Sep 18, 2026

Copy link
Copy Markdown
Member

Hi @suolongcn. I’m currently preparing the plugin for OpenCode 2 and expect to release it officially on Monday. This may cause some conflicts; if you could resolve them afterward, that would be great. I’ll take another look once everything is finalized. Ideally, please monitor the releases for the OpenCode 2-compatible version. Thanks!

@suolongcn

Copy link
Copy Markdown
Author

Hi @suolongcn. I’m currently preparing the plugin for OpenCode 2 and expect to release it officially on Monday. This may cause some conflicts; if you could resolve them afterward, that would be great. I’ll take another look once everything is finalized. Ideally, please monitor the releases for the OpenCode 2-compatible version. Thanks!

Okay! Looking forward to the new release!

@suolongcn

Copy link
Copy Markdown
Author

@bezbac I have modified this PR and verifyed this function with opencode v1 and opencode v2. Please help me to review this PR.

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.

Feature: expose skill and subagent names for Langfuse analytics

3 participants