instrument-existing-agent-with-prefactor-sdk

Instrument existing agents with Prefactor to trace run, LLM, and tool boundaries.

3|Updated Jan 20, 2026
One-click install
npx skills add https://github.com/prefactordev/typescript-sdk --skill instrument-existing-agent-with-prefactor-sdk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: instrument-existing-agent-with-prefactor-sdk
Source: https://github.com/prefactordev/typescript-sdk/tree/main/skills/instrument-existing-agent-with-prefactor-sdk
Command: npx skills add https://github.com/prefactordev/typescript-sdk --skill instrument-existing-agent-with-prefactor-sdk

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Use when an existing agent already works without Prefactor and you need to add tracing for runs, llm calls, tool calls, and failures with minimal behavior changes.

Core Features & Use Cases

  • Instrument boundaries, not business logic.
  • Add a top-level run span and child spans around LLM/tool boundaries.
  • Preserve context propagation and ensure proper finish paths for success and error cases.
  • Capture error metadata and rethrow original errors.

Quick Start

Bootstrap Prefactor resources, install dependencies, and begin instrumenting the agent by wrapping run/llm/tool boundaries with the appropriate adapter.

Frequently Asked Questions about instrument-existing-agent-with-prefactor-sdk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add LLM tracing to an existing agent without changing its behavior?

LLM tracing is added by instrumenting boundaries with Prefactor, wrapping run, LLM, and tool calls in spans while preserving the existing business logic and context propagation.

Can I instrument an agent built with LangChain or AI SDK for run and tool tracing?

Yes, agents built with common adapters like LangChain, AI SDK, or OpenClaw are supported. The instrumentation enforces adapter-specific imports to add tracing around boundaries safely.

What is the best way to capture errors in agent tracing without breaking the original flow?

Error capture in agent tracing works by recording error metadata within spans and rethrowing the original errors. Proper finish paths ensure both success and error cases are traced safely.

How do I add a top-level run span and child spans around tool calls?

You add a top-level run span with child spans around LLM and tool boundaries. This approach targets boundaries specifically, avoiding modifications to the underlying business logic.

Does adding tracing spans to an agent affect context propagation?

No, adding Prefactor tracing spans preserves context propagation. The instrumentation enforces proper finish paths for success and error cases, ensuring safe production usage without altering behavior.

What do I need to start instrumenting an agent with Prefactor?

You need to bootstrap Prefactor resources and install dependencies before wrapping agent run, LLM, and tool boundaries with the appropriate adapter imports.