Add LangChain auto-instrumentation and cross-framework benchmarks - #11
Closed
manemsai wants to merge 13 commits into
Closed
Add LangChain auto-instrumentation and cross-framework benchmarks#11manemsai wants to merge 13 commits into
manemsai wants to merge 13 commits into
Conversation
Adds a benchmark suite that runs the same refund-ticket workload through AutoGen, CrewAI, LangGraph, LlamaIndex, Semantic Kernel, and native Python, profiling each with AgenticLens to normalize tokens/cost/latency for an apples-to-apples comparison. Also adds two more realistic examples (support_copilot.py, multiagent_edge_cases_demo.py) exercising the full step lifecycle plus recommender edge cases. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Surfaces the new benchmarks/ harness so the apples-to-apples token/cost/latency comparison across agent frameworks is discoverable from the main README instead of buried in a results folder. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Applies ruff format, wraps long string literals under the 100-char line limit, drops an unused import, and adds noqa for the intentional sys.path manipulation in the native-Python benchmark runner. These files were added without a lint pass in the prior commit. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds agenticlens.adapters.langchain.AgenticLensCallbackHandler, an optional (pip install "agenticlens[langchain]") callback handler that turns LangChain's own on_llm_*/on_tool_*/on_retriever_* events into AgenticLens steps automatically, so LLM calls, tool calls, and retrieval don't need manual step() wrapping. Since it produces the same Step shape as the manual API, every existing recommender, exporter, and CLI command works against LangChain-sourced workflows unmodified. This was the top item on the roadmap's near-term integrations list (README, ROADMAP). Adds langchain-core as the optional `langchain` extra, wires it into CI so the adapter is actually tested, and adds a mypy override to stop following into langchain-core's internals (its transitive numpy stub can be newer than our target Python version). Documented in docs/langchain-integration.md and linked from the README and mkdocs nav. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
benchmark_runner.py invokes each framework script via `agenticlens profile <script>` in a subprocess. Every script except native_python imports from the `benchmarks` package, which only resolved if the project root happened to already be on PYTHONPATH in the caller's shell -- otherwise every framework but native_python failed with ModuleNotFoundError. Pass PYTHONPATH explicitly so the harness works out of the box for any contributor. Also refreshes the committed report/result fixtures from a clean run through the fixed harness, confirming all six frameworks (including AutoGen, previously unverified in this environment) now execute end-to-end and reproduce the same token/cost figures as before. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Extends the benchmark suite with a second workload that hits real, live, free APIs for every tool/retriever step (Open-Meteo geocoding + forecast, Frankfurter exchange rates, Wikipedia REST summary) instead of scripted fixtures. Adds a *_live.py implementation per framework (native Python, LangGraph, CrewAI, AutoGen, LlamaIndex, Semantic Kernel), a shared benchmarks/shared/live_travel_tasks.py task module, and live_benchmark_runner.py to orchestrate and compare them. Unlike the deterministic support-refund benchmark -- where every framework reports identical numbers because everything is a FakeResponse -- token counts stay stable here (LLM steps still fall back without an OPENAI_API_KEY) but latency is now genuinely live: it varies run to run and framework to framework based on real network conditions, with geocoding consistently the slowest step (~600-670ms) across all six. Also adds examples/live_multiagent_travel_briefing.py, the single-run version of the same workflow this benchmark is derived from. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…genticlens into feature/notebook
pramodbn27
approved these changes
Aug 9, 2026
pramodbn27
approved these changes
Aug 9, 2026
pramodbn-cloud
approved these changes
Aug 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR grows AgenticLens in three main directions:
agenticlens.adapters.langchain.AgenticLensCallbackHandlerWhat Changed
agenticlens[langchain]with a LangChain callback adapter that records LLM, tool, and retriever activity into the active AgenticLens workflow.profile()context.support_copilot.py,multiagent_edge_cases_demo.py, andlive_multiagent_travel_briefing.py.langchainextra is available during checks.Why
This makes AgenticLens easier to adopt in existing LangChain-style stacks while also giving the repo a concrete, repeatable way to compare token, cost, latency, retrieval, and tool-call behavior across multiple agent frameworks.
Validation
uv run ruff check benchmarks/frameworks/crewai/run_crewai_live.pyruff check .ruff format --check .mypypytestReviewer Notes
langchain-coreis optional and exposed through the newlangchainextra.mainso the PR is now mergeable again.