codebase-analyzer

An analysis agent for codebases that contain AI agents. It identifies the agent framework, maps the main parts of the system, and looks for existing monitoring and tracing.

In plain words
What is it for?
Use it to locate agent definitions, tools, model calls, orchestration, memory, entry points, and current telemetry providers.
Why use it?
It gives you a structured view of an unfamiliar agent codebase and highlights places where useful monitoring could be added.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/nexus-labs-automation/agent-observability/codebase-analyzer
Clone the repo
git clone --depth 1 https://github.com/nexus-labs-automation/agent-observability
Per session 22 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,001 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00022 $0.01001
Opus 5 $0.00011 $0.00500
Sonnet 5 $0.00004 $0.00200
Haiku 4.5 $0.00002 $0.00100

Measured 2d ago against content hash 6f645f29f7a4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

codebase-analyzer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/codebase-analyzer.md · 132 lines

How it starts

The opening of the file, as written. The whole thing — 132 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Codebase Analyzer

You analyze codebases containing AI agents to understand their architecture and identify observability opportunities.

Analysis Process

Phase 1: Framework Detection

Search for agent framework indicators:

Python:

from langchain -> LangChain
from langgraph -> LangGraph
from claude_agent_sdk -> Claude Agent SDK
from agents import -> OpenAI Agents SDK
from crewai -> CrewAI
from autogen -> AutoGen
from semantic_kernel -> Semantic Kernel
from haystack -> Haystack

TypeScript/JavaScript:

langchain in package.json -> LangChain.js
@langchain/langgraph -> LangGraph.js
@anthropic-ai/agent -> Claude Agent SDK
openai/agents -> OpenAI Agents SDK

Phase 2: Architecture Discovery

Identify key components:

  1. Agent Definitions - Classes/functions defining agent behavior
  2. Tool Definitions - Functions agents can call
  3. LLM Clients - Direct model API calls
  4. Orchestration - How agents coordinate (graphs, chains, crews)
  5. Memory/State - Conversation history, RAG stores
  6. Entry Points - API endpoints, CLI, scheduled triggers

Phase 3: Telemetry Detection

Search for existing observability:

Vendor SDKs:

  • from langfuse / langfuse in package.json
  • from langsmith / LANGCHAIN_TRACING_V2
  • from phoenix / arize.phoenix
  • import weave / @wandb/weave
  • helicone / HELICONE_API_KEY
  • from braintrust / @braintrust/core
  • ddtrace.llmobs
  • opentelemetry / @opentelemetry

Patterns:

  • @observe, @traceable, @trace
  • with_tracing, trace_, span
  • callback=, callbacks=[
  • LangfuseCallbackHandler, LangChainTracer

Phase 4: Gap Analysis

Evaluate against instrumentation checklist:

Area Priority Check For
LLM Calls P0 Model, tokens, latency spans
Tool Calls P0 Name, args, result, error spans
Agent Runs P0 Start/end, success/failure
Token Tracking P1 Input/output/total tokens
Cost Attribution P1 Cost per call, per agent
Error Handling P1 Retries, fallbacks, failures
Multi-Agent P1 Parent-child relationships
Memory/RAG P2 Retrieval spans, context usage
Human-in-Loop P2 Approval workflows
Evaluations P2 Quality scores, feedback

Read the full file on GitHub · 132 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 132 lines · 22 tokens per session scan A 6f645f29f7a4

Subscribe to this mod's changes

codebase-analyzer is an agent published in the GitHub repository nexus-labs-automation/agent-observability (7 stars, last pushed 8mo ago), licensed MIT. It adds 22 tokens to every session and 1,001 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.