Agent skill

AI Observability Langchain Python

by Jwuthri in Jwuthri/Tracely-ai

PostHog AI Observability integration for LangChain (Python). An agent skill from Jwuthri/Tracely-ai.

MITAuto-check passedAI & LLM Engineering

Install AI Observability Langchain Python

skills CLI
$ npx skills add Jwuthri/Tracely-ai --skill ai-observability-langchain-python -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Jwuthri/Tracely-ai ai-observability-langchain-python --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Jwuthri/Tracely-ai.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/ai-observability-langchain-python .claude/skills/ai-observability-langchain-python && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
ai-observability-langchain-python
GitHub stars
1.5k
Token cost
~2.2k tokens
SKILL.md length
1,190 words
Files
14 (incl. references)
Skills in repo
4
Repo updated
First seen
Licence
MIT

At a glance

PostHog AI Observability integration for LangChain (Python). An agent skill from Jwuthri/Tracely-ai.

  • Works in 4 steps: Begin — see references/1-begin.md. Pick… → Install — see references/2-install.md.… → Instrument — see… → …
  • Tasks that involve Building AI agents
  • SKILL.md covers Prerequisite — vendor LLM SDK, Steps, Reference files and Key principles, plus 2 more sections
  • Calls pip; needs POSTHOG_API_KEY

What it does

AI Observability Langchain Python is an agent skill from Jwuthri/Tracely-ai. PostHog AI Observability integration for LangChain (Python)

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 14 other files, including reference files (for example `references/1-begin.md`, `references/2-install.md` and `references/3-instrument.md`).

It sits in AI & LLM Engineering, covering Building AI agents and Observability. It works with Python, LangChain, PostHog and OpenTelemetry. The repository describes itself as: Trace-native CI/CD for AI agents — production failures become regression tests that block the PR. Auto-detect, cluster, freeze into hermetic cases, replay in CI for $0. The licence is MIT.

When your agent uses it

  • Tasks that involve Building AI agents
  • Tasks that involve Observability

Example prompts

  • “/ai-observability-langchain-python”

Requirements

  • Python 3
  • A credential in POSTHOG_API_KEY

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Begin — see references/1-begin.md. Pick the variant with the ordered rules (framework before provider, gateway base URL before the SDK it…
  2. Install — see references/2-install.md. Declare the variant's packages in the manifest — and only those. For providers and gateways that's…
  3. Instrument — see references/3-instrument.md. Swap the vendor client for PostHog's wrapper, attach $ai_session_id, a per-turn…
  4. Verify — see references/4-verify.md. Describe a request the user can trigger, and grade what lands in PostHog — one session, grouped…

What it can do on your machine

Read from SKILL.md and the folder at commit 2962e1b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pip

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pip, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • POSTHOG_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

AI Observability Langchain Python loads about 2.2k tokens when it runs, and up to ~23k if it reads all its reference files. Until then it costs about 23 tokens; SKILL.md has 1,190 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~23
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~23k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Jwuthri/Tracely-ai at commit 2962e1b, republished under its MIT licence (© Jwuthri). 1,190 words, ~2,233 tokens.

Download SKILL.mdSave it as .claude/skills/ai-observability-langchain-python/SKILL.md (or your agent's skills folder). This skill also uses 13 other files; get the full folder from GitHub.
name
ai-observability-langchain-python
description
PostHog AI Observability integration for LangChain (Python)
metadata.author
PostHog
metadata.version
1.48.0

PostHog AI Observability for LangChain (Python)

Wire up PostHog's AI Observability so calls made through LangChain (Python) land in LLM Analytics as a full session → trace → span → generation tree — not just isolated $ai_generation events.

Prerequisite — vendor LLM SDK

This skill instruments the LLM calls the project already makes. It does not install the vendor SDK for you.

Check the project's manifest for an LLM package. The catalog is far wider than the obvious providers — 68 variants covering agent frameworks (openai-agents, claude-agent-sdk, LangGraph, CrewAI, Mastra, …) and OpenAI-compatible gateways (Groq, OpenRouter, Together, Ollama, …), which an app reaches through the openai package plus a baseURL override. 1-begin.md carries the ordered decision rules; follow them rather than matching on the first familiar package name. If no LLM SDK is present, switch to the manual-capture variant — it posts $ai_generation events directly and works standalone.

Everything else this skill needs — PostHog credentials, instrumentation packages, env vars — the skill installs and configures itself. It does not require a pre-existing posthog.init(...). If one is already there, reuse its env-var names in 3-instrument.md; if not, that step sets fresh values via set_env_values.

Steps

Read every referenced file before editing. Then work through them in order:

  1. Begin — see references/1-begin.md. Pick the variant with the ordered rules (framework before provider, gateway base URL before the SDK it borrows), then read four facts from the code: the conversation, the user, the turn, and whether the app registers tools.
  2. Install — see references/2-install.md. Declare the variant's packages in the manifest — and only those. For providers and gateways that's the PostHog SDK alongside the vendor SDK, with no OpenTelemetry packages.
  3. Instrument — see references/3-instrument.md. Swap the vendor client for PostHog's wrapper, attach $ai_session_id, a per-turn posthog_trace_id, and the distinct id to every call, and capture tool runs as $ai_span events. This step is what turns isolated generations into a session tree.
  4. Verify — see references/4-verify.md. Describe a request the user can trigger, and grade what lands in PostHog — one session, grouped traces, right attribution — rather than what the diff contains.

Reference files

  • references/1-begin.md - Pick the variant that matches this project, then read the four facts the instrumentation needs
  • references/2-install.md - Declare the packages the variant needs, and no others
  • references/3-instrument.md - Swap in the wrapper client, then attach identity and tool spans so the calls form a session tree
  • references/4-verify.md - Give the user a way to trigger one turn, and grade the tree that reaches PostHog
  • references/langchain.md - Langchain ai observability installation - docs
  • references/python.md - Python - docs
  • references/basics.md - Ai observability basics - docs
  • references/generations.md - Generations - docs
  • references/traces.md - Traces - docs
  • references/sessions.md - Sessions - docs
  • references/spans.md - SPAns - docs
  • references/COMMANDMENTS.md - Framework-specific rules the integration must follow

The linked install page carries the exact code blocks for this variant's language. Prefer copying from there over reconstructing from memory — package names and initialization shapes change between AIO releases.

Key principles

  • Environment variables. Read <ph_project_token> and <ph_client_api_host> from env, using the framework's env-var convention. Never hardcode either value.
  • The SDK wrapper is the default, not OpenTelemetry. OTel makes the session tree awkward to build and maintain, so provider and gateway variants use PostHog's drop-in wrapper client. Reserve OTel for the opentelemetry-* variants and LlamaIndex, and never swap a framework's own tracing hook for an instrumentor.
  • Minimal changes. The wrapper swaps a client constructor and adds parameters to existing calls. Don't restructure the app, and don't wrap the setup in an init function or module globals.
  • Match the docs. Package names and wrapper imports change between AIO releases. The install page for this variant is the source of truth.
  • Cardinality is what gets graded. One $ai_session_id per conversation, one posthog_trace_id per turn, shared by every call in it. An id minted per call is worse than none — it looks instrumented and groups nothing.
  • Tools become spans. When the app registers tools, capture each execution as an $ai_span event sharing the turn's trace id — the wrapper never sees your dispatch loop. Framework variants emit these themselves; an app with no tools correctly has none.
  • Don't touch what isn't yours. This skill instruments LLM observability only — generations, traces, sessions, spans. Identify calls, event tracking, error tracking, and dashboards belong to the base integration skill — do not add or edit them here.
Show full SKILL.md (497 more words)Show less

Emit a run record

When you finish, write .posthog-wizard-cache/.posthog-ai.json at the project root:

json
{ "provider": "openai", "package": "@posthog/ai", "otel_init_file": "src/instrumentation.ts" }

otel_init_file keeps its name for the report's sake, but on the wrapper path there is no OTel init — set it to the file where the wrapper client was constructed (or, on the manual path, where the capture helper lives).

The report/ step reads this file to render an AI Observability section in the setup report. If the cache directory does not exist, create it.

Framework guidelines

  • A missing PostHog configuration must never break the app — read keys optionally (never a required setting), guard init and capture behind their presence, and keep build and boot working with no PostHog environment set — but never silently: in development or debug builds fail loudly, using the language's idiomatic error, with the message "<VAR> variable required by PostHog is missing or un-configured, this causes events to be silently missed. This error stops appearing once <VAR> is configured" (substituting the actual variable name); production stays a no-op
  • AI Observability carve-out: this skill instruments LLM calls and is not product-analytics coverage. Do NOT add posthog.capture() events for user actions, captureException() error handlers, or a reverse proxy unless the user explicitly asks for them
  • AI Observability carve-out: only the wrapper-client and manual-capture install paths construct a PostHog client. The OTel and framework-hook paths have no client at all, so any rule in this file about the Posthog()/PostHog() constructor, exception autocapture, atexit/shutdown registration or flushing simply does not apply — never invent a client just to satisfy one
  • AI Observability carve-out: the $ai_* payload properties ($ai_input, $ai_output_choices, and the rest) intentionally carry user-generated prompt and completion text, so this file's PII rules do NOT apply to them. Those rules still govern every other property you set
  • AI Observability carve-out: read the PostHog key and host exactly as the variant's install doc reads them. A direct os.environ["POSTHOG_API_KEY"] / process.env lookup already fails loudly and idiomatically when unset, which satisfies this file's missing-configuration rule — do NOT add a separate presence check, guard branch, or custom raise around a bootstrap that is only a few lines long
  • Remember that source code is available in the venv/site-packages directory
  • posthog is the Python SDK package name
  • Install dependencies with pip install posthog or pip install -r requirements.txt and do NOT use unquoted version specifiers like >= directly in shell commands
  • In CLIs and scripts: MUST call posthog.shutdown() before exit or all events are lost
  • Always use the Posthog() class constructor (instance-based API) instead of module-level posthog.api_key config
  • Always include enable_exception_autocapture=True in the Posthog() constructor to automatically track exceptions
  • NEVER send PII in capture() event properties — no emails, full names, phone numbers, physical addresses, IP addresses, or user-generated content
  • PII belongs in identify() person properties, NOT in capture() event properties. Safe event properties are metadata like message_length, form_type, boolean flags.
  • Register posthog_client.shutdown with atexit.register() to ensure all events are flushed on exit
  • The Python SDK has NO identify() method — use posthog_client.set(distinct_id=user_id, properties={...}) to set person properties, or use identify_context(user_id) within a context

© Jwuthri, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 13 other files (references) in .claude/skills/ai-observability-langchain-python of Jwuthri/Tracely-ai.

  • SKILL.md
  • .posthog-wizard
  • references/1-begin.md
  • references/2-install.md
  • references/3-instrument.md
  • references/4-verify.md
  • references/COMMANDMENTS.md
  • references/basics.md
  • references/generations.md
  • references/langchain.md
  • references/python.md
  • references/sessions.md
  • references/spans.md
  • references/traces.md

Open the folder on GitHubat commit 2962e1b

Compare with similar skills

AI Observability Langchain Python next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

AI Observability Langchain Python compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
AI Observability Langchain Python this skillJwuthri/Tracely-ai1.5k—~2.2kAutomated safety check: PassMIT
Phoenix Integration SnippetsArize-ai/phoenix12k—~1.4kAutomated safety check: PassApache-2.0
Failproof AI SDK IntegrationFailproofAI/failproofai5.3k—~6kAutomated safety check: PassCustom licence
Agentsop Observability Setupagentsope/SkillAlchemy457—~4.4kAutomated safety check: PassMIT
Add Example AgentGetBindu/Bindu10k—~1.1kAutomated safety check: NotesCustom licence
Upgrade Stripekanchengw/cnllm1754 repos~1.4kAutomated safety check: PassApache-2.0

Similar skills

  • Generates onboarding code snippets for Phoenix tracing integrations and wires them into the project onboarding UI.

    12k GitHub stars~1.4k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Failproof AI SDK Integration

    FailproofAI/failproofai

    Helps instrument a custom Python or TypeScript agent to record events for Failproof AI, verify what gets written, and run an evaluator worker that scores the runs.

    5.3k GitHub stars~6k tokensUpdated 2 days ago
    AI & LLM EngineeringAuto-check passed
  • Agentsop Observability Setup

    agentsope/SkillAlchemy

    Enhancement-overlay skill — the DECISION + WIRING layer for LM observability that the single-backend skills [[langsmith]], [[phoenix]], [[mlflow]] do NOT cover.

    457 GitHub stars~4.4k tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check passed
  • Add Example Agent

    GetBindu/Bindu

    Add a new self-contained example agent under examples/. An agent skill from GetBindu/Bindu.

    10k GitHub stars~1.1k tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check: notes
  • Upgrade Stripe

    kanchengw/cnllm

    Guide for upgrading Stripe API versions and SDKs. An agent skill from kanchengw/cnllm.

    175 GitHub starsUsed in 4 repos~1.4k tokens
    AI & LLM EngineeringAuto-check passed
  • Tool Design

    agentailor/fullstack-langgraph-nextjs-agent

    Design and verify tools that AI agents can actually use — for any framework or language (MCP servers, LangChain/LangGraph, function-calling, raw JSON schema; TypeScript, Python, or otherwise).

    132 GitHub stars~3.2k tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check passed

More from Jwuthri/Tracely-ai

  • Maintain Greptile Rules

    Jwuthri/Tracely-ai

    Evaluate verified findings from merge-ready, Greptile, pull-request, CI, security, billing, and other code reviews, then promote durable review gaps into the version-controlled .greptile…

    1.5k GitHub stars~1.1k tokensUpdated yesterday
    Auto-check passed
  • Openseo Review Web Content

    Jwuthri/Tracely-ai

    Write and review content for the OpenSEO website (web/) — blog posts, guides, feature pages, FAQs.

    1.5k GitHub stars~922 tokensUpdated yesterday
    Auto-check passed
  • SEO Audit

    Jwuthri/Tracely-ai

    Audit a website and deliver a one-page, plain-language SEO report anyone can act on, centered on a single do-this-week action.

    1.5k GitHub stars~1.5k tokensUpdated yesterday
    Auto-check passed

Questions about AI Observability Langchain Python

What does AI Observability Langchain Python do?

PostHog AI Observability integration for LangChain (Python). An agent skill from Jwuthri/Tracely-ai. AI Observability Langchain Python is an agent skill from Jwuthri/Tracely-ai.

When should I use AI Observability Langchain Python?

AI Observability Langchain Python fits situations like: tasks that involve Building AI agents; tasks that involve Observability.

How do I install AI Observability Langchain Python in Claude Code?

Run `npx skills add Jwuthri/Tracely-ai --skill ai-observability-langchain-python -a claude-code`. Or copy the skill folder (.claude/skills/ai-observability-langchain-python in Jwuthri/Tracely-ai) into .claude/skills/ai-observability-langchain-python in your project. Claude Code loads it when a task matches its description.

How do I install AI Observability Langchain Python in Codex?

Run `npx skills add Jwuthri/Tracely-ai --skill ai-observability-langchain-python -a codex`. Or copy the skill folder (.claude/skills/ai-observability-langchain-python in Jwuthri/Tracely-ai) into .agents/skills/ai-observability-langchain-python in your project. Codex loads it when a task matches its description.

Can I use AI Observability Langchain Python in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Jwuthri/Tracely-ai --skill ai-observability-langchain-python -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/ai-observability-langchain-python, .gemini/skills/ai-observability-langchain-python, .github/skills/ai-observability-langchain-python and .opencode/skills/ai-observability-langchain-python in your project.

What does AI Observability Langchain Python need to run?

Going by SKILL.md and its folder, AI Observability Langchain Python needs the command-line tools its instructions call (pip) and credentials named POSTHOG_API_KEY. Our summary lists: Python 3; A credential in POSTHOG_API_KEY.

Does AI Observability Langchain Python access the network?

SKILL.md contains no URLs. Its commands use pip, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is AI Observability Langchain Python safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does AI Observability Langchain Python use?

AI Observability Langchain Python is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does AI Observability Langchain Python use?

About 2.2k tokens (SKILL.md is roughly 8.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 21k tokens, read only when the agent opens those files.

What are the alternatives to AI Observability Langchain Python?

Skills that share tags, products or a category with AI Observability Langchain Python: Phoenix Integration Snippets (Arize-ai/phoenix, 12k stars), Failproof AI SDK Integration (FailproofAI/failproofai, 5.3k stars), Agentsop Observability Setup (agentsope/SkillAlchemy, 457 stars) and Add Example Agent (GetBindu/Bindu, 10k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains AI Observability Langchain Python?

Jwuthri (a GitHub user) maintains it in Jwuthri/Tracely-ai, which has 1,501 GitHub stars. The repository holds 4 skills in this directory. The repository was last updated on October 6, 2026.

Source: Jwuthri/Tracely-ai on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.