Launch Week 02 wrapped — explore all five launches

Confident Tracing Skill

Teach your agent to instrument Python and TypeScript AI apps with confident-trace integrations and custom spans.

Overview

The confident-tracing Agent Skill teaches your coding agent how to instrument an AI application with the Python or TypeScript confident-trace SDK so every model call, retrieval, tool call, and agent step appears span by span in Confident AI.

Its scope is deliberately narrow: producing well-formed traces. The skill detects the language, framework, model provider, agent SDK, gateway, bundler, and existing OpenTelemetry setup; prefers a supported integration; falls back to custom @span, span(), or withSpan() instrumentation where needed; and adds useful trace context. Attaching metrics and running evals belongs to the deepeval skill.

When It Triggers

The skill activates on prompts like:

Prompts that trigger the skill
Instrument this app with Confident Trace.
Add automatic tracing to my LangGraph agent.
Add @span around the custom retriever in this Python RAG pipeline.
Make my TypeScript agent's OpenAI calls appear in Confident AI.

Installation

Works with Cursor, Claude Code, Codex, Windsurf, OpenCode, and any other Skills-compatible assistant:

npx skills add confident-ai/confident-trace --skill "confident-tracing"

Prerequisites

  • Python 3.10+ or Node.js 22+
  • confident-trace installed in the application
  • A project-scoped CONFIDENT_API_KEY for export to Confident AI

What Changes in Your Codebase

  1. Ask for tracing

    The agent detects the language and AI stack, reads the current confident-trace integration documentation, and chooses automatic instrumentation whenever a supported integration exists.

    Prompt
    Instrument this agent with confident-trace and send its traces to Confident AI.
  2. Initialize the SDK

    In Python, the agent installs confident-trace and calls init() once before provider or framework calls:

    import confident_trace as ct
    
    ct.init()

    In TypeScript, automatic instrumentation requires both init() in the entry file and the Node registration preload:

    import { init } from "confident-trace";
    
    const tracing = init();
    node --import confident-trace/register dist/index.js
  3. Add custom spans where integrations cannot

    The agent adds custom spans only around application-owned boundaries or unsupported components. It uses one of the five supported span types: agent, llm, retriever, tool, or custom.

    Python example
    import confident_trace as ct
    
    @ct.span(type="retriever")
    def retrieve(query: str) -> list[str]:
        documents = search(query)
        ct.update_span(input=query, retrieval_context=documents)
        return documents
    TypeScript example
    import { span, updateSpan } from "confident-trace";
    
    const retrieve = span(
      { name: "retrieve", type: "retriever" },
      async (query: string) => {
        const documents = await search(query);
        updateSpan({ input: query, retrievalContext: documents });
        return documents;
      },
    );
  4. Add trace and conversation context

    The agent uses update_trace() or updateTrace() for trace input, output, tags, metadata, user ID, thread ID, turn ID, and environment. It uses turn() when each conversation turn must start a separate trace while remaining associated with the same thread.

    with ct.turn(thread_id="chat-42", turn_id="2", input=user_input):
        answer = run_agent(user_input)
        ct.update_trace(output=answer)
  5. Verify traces

    The agent finishes active work and streams before flushing or shutting down, then verifies the trace hierarchy in Confident AI:

    export CONFIDENT_API_KEY="confident_us_proj_..."
    python main.py

FAQs

Which integrations does the skill support?

The skill covers the integrations implemented by the current confident-trace SDK. Python includes OpenAI, Anthropic, Google GenAI, Bedrock, LangChain, LangGraph, OpenAI Agents, CrewAI, LlamaIndex, Agno, smolagents, Google ADK, Microsoft Agent Framework, Pydantic AI, Strands, AgentCore, Claude Agent SDK, and supported LLM gateways. TypeScript includes OpenAI, Anthropic, Google GenAI, Vercel AI SDK, LangChain, LangGraph, Mastra, OpenAI Agents, and supported gateways. The skill reads the repository's current integration docs before writing setup code.

Will it trace my whole backend?

No. It instruments AI components only: agent loops, model calls, retrieval, tool calls, and application boundaries that organize them.

Does it work in both Python and TypeScript?

Yes. Python uses @span and span context managers. TypeScript uses span() and withSpan() and requires the confident-trace/register preload for automatic instrumentation.

Does it attach metrics or run evals?

No. Its job ends at producing well-formed traces. Use the deepeval skill for evaluation suites, datasets, metrics, and test runs.

Next Steps

Scaling beyond prototype?For teams evaluating Confident AI in productionTalk to us

Last updated on

Built byConfident AI