Skip to content

feat: auto-instrument LangChain, CrewAI, AutoGen, LlamaIndex#3

Closed
ryandao wants to merge 1 commit intomainfrom
devsquad/theo/1776054993399
Closed

feat: auto-instrument LangChain, CrewAI, AutoGen, LlamaIndex#3
ryandao wants to merge 1 commit intomainfrom
devsquad/theo/1776054993399

Conversation

@ryandao
Copy link
Copy Markdown
Owner

@ryandao ryandao commented Apr 13, 2026

Summary

  • Add auto-instrumentation patches for LangChain, CrewAI, AutoGen, and LlamaIndex that trace agent runs without needing the decorator
  • LangChain: patches / with automatic run-type detection (agent/tool/llm)
  • CrewAI: patches with crew metadata and agent roles capture
  • AutoGen: patches with agent name/type tracking
  • LlamaIndex: patches and
  • All patches safely skip if the framework library is not installed
  • Updated to activate all framework patches alongside existing LLM patches
  • Added optional dependency groups: , , , ,
  • Full documentation for each framework in

Test plan

  • All patches skip gracefully when framework not installed
  • LangChain run-type detection correctly classifies agents, tools, and LLMs
  • calls all 8 patches (4 LLM + 4 framework)
  • 98 tests passing

*Submitted by 🔧 Theo (DevSquad) for task *

Framework support (task-framework-support):
- Add auto-instrumentation patches for LangChain, CrewAI, AutoGen, and
  LlamaIndex that trace agent runs without needing @agent decorator
- LangChain: patches Runnable.invoke/ainvoke with run-type detection
- CrewAI: patches Crew.kickoff with crew metadata capture
- AutoGen: patches ConversableAgent.generate_reply
- LlamaIndex: patches BaseQueryEngine.query and BaseChatEngine.chat
- All patches follow existing pattern (safe skip if lib not installed)
- Update instrument() to activate all framework patches
- Add optional dependency groups in pyproject.toml
- Add framework documentation in sdk/docs/frameworks/

Test coverage (task-test-coverage):
- 98 tests covering all SDK modules
- Unit tests for registry (init, instrument)
- Unit tests for instrumentation (@agent, session, track_*, sanitize)
- Unit tests for otel (ID helpers, OTLP builder, LiveSpanProcessor)
- Unit tests for token extraction (_extract.py)
- Unit tests for all integration patches (graceful skip when not installed)
- Unit tests for LangChain run-type detection logic
- Public API surface tests
- Test infrastructure with in-memory span exporter and shared fixtures
- CI workflow updated to run SDK tests on Python 3.11-3.13

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryandao ryandao closed this Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant