agentsclimarketplace

Subagent metrics bridging

Skill ychampion/cskill-agents/agents/codex/skills/subagent-metrics-bridging

Translate a streaming subagent run into task progress, analytics, and notifications while keeping partial results and cleanup tidy.From its SKILL.md

Install
npx -y skills add ychampion/cskill-agents --skill subagent-metrics-bridging

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

2.3 KB, 415 tokens by cl100k_base, as published. Nobody here has run it

SKILL: Subagent Metrics Bridging

Domain: metrics-bridging Trigger: Use when an async subagent loop needs to feed its token/tool-use counts, progress, and completion status back into the host task/analytics stack. Source Pattern: Distilled from reviewed async subagent lifecycle, task-progress, and analytics bridge implementations.

Core Method

Drive the async child-agent lifecycle through one progress bridge that feeds task UI, analytics, and notifications from the same stream. As messages arrive, update visible progress, token counts, and the last-active tool so the host can show meaningful live state. When the stream finishes, finalize the result once, record analytics from that finalized snapshot, and then emit completion notifications or warnings. Heavy post-processing should happen after the task is already marked complete so diagnostics do not block the visible lifecycle.

Key Rules

  • Move the visible task status to completed or terminated before running expensive diagnostics or cleanup.
  • Derive progress, token counts, and “last tool used” from one shared tracker instead of recomputing them in multiple places.
  • Finalize the child-agent result once and use that same finalized snapshot for analytics, notifications, and partial-result handling.
  • On aborts or kills, still emit a clean closing notification so the parent task can resolve deterministically.
  • Clear agent-specific transient state after every outcome so later runs do not inherit stale progress or artifacts.

Example Application

When adding a new background worker that prefetches repo data for the user, follow this pattern to link its stream to the task UI/notification system and guarantee the analytics pipeline records its token tally even if it aborts midflight.

Anti-Patterns (What NOT to do)

  • Don’t log the completion event before the agent result is finalized—duplicated token counts appear if you emit analytics prior to finalizeAgentTool.
  • Don’t rely on the final assistant message to always contain text; fallback logic exists inside finalizeAgentTool to pull the last text block, so duplicating that logic invites bugs.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,512. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.