instrument-existing-agent-with-prefactor-sdk
Installation
SKILL.md
Instrument Existing Agent With Prefactor SDK
Instrument a working agent that was built without Prefactor.
Core principle: instrument boundaries, not business logic.
Quick Start
- Bootstrap Prefactor credentials with
skills/bootstrap-existing-agent-with-prefactor-cli/SKILL.md(prefactor setuporprefactor setup --create). - Inspect the project and install the matching Prefactor adapter with the project's existing package manager (
bun,npm,pnpm, oryarn). - Identify runtime path: built-in adapter (
@prefactor/langchain,@prefactor/ai,@prefactor/openclaw,@prefactor/claude) or custom@prefactor/coreadapter. - Add one top-level run span and child spans around LLM/tool boundaries.
- Preserve context propagation and package-prefixed span types.
- Record error metadata and rethrow original errors.
- Finish spans on success, error, cancel, and stream terminal paths.
- Verify in your project's build/test/typecheck flow, then confirm traces with
prefactor agent_instances list --agent_id <agent_id>andprefactor agent_instances agent_context <instance_id>.