feat: add DeerFlow 2.x observability - #248
Conversation
ralf0131
left a comment
There was a problem hiding this comment.
- [Info]
patch.py:_track_graph— Strong-ref fallback list for unhashable graphs could grow without bounds in theory, but in practice graphs are created once per application. Acceptable for current usage.
Code Quality Highlights
- Optional DeerFlow imports are correctly wrapped in try/except (telemetry must not hard-depend on application internals)
_LEGACY_GRAPH_ATTRScleanup ensures graphs aren't misclassified as ReAct/deepagents when marked as DeerFlow - Entry depth via ContextVar prevents nested span creation - CI workflow JSON additions are mechanical (adding deerflow to lint/test matrices) ### Test Coverage - New test files underloongsuite-instrumentation-deerflow/tests/with conftest fixtures -test_response_id.pyfor the sharedresolve_response_idhelper (from #247's util-genai addition)
Note: Reviewed the core patch.py (802 lines) and extended_handler.py changes in detail. CI config, package metadata, and README changes reviewed at a high level.
Automated review by github-manager-bot
SummaryAdds a new FindingsNo blocking issues.
Code Quality Highlights
Test Coverage
Note: Reviewed the core Automated review by github-manager-bot |
|
This PR has conflicts with the git fetch origin
git checkout feat/deerflow-observability
git rebase origin/main
# resolve conflicts, then:
git push --force-with-leaseThis is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved. Automated notification by github-manager-bot |
ralf0131
left a comment
There was a problem hiding this comment.
Summary
New DeerFlow 2.x instrumentation adapter — a thin layer over existing LangChain/LangGraph instrumentations. Code structure looks solid.
Review
- Architecture ✅ — Clean
BaseInstrumentorimplementation with proper dependency management (LangChain + LangGraph instrumentors) - Version gating ✅ — Correct
>=2,<3range check ondeerflow-harnessdistribution - Error handling ✅ — Proper cleanup on failure (reverse-order uninstrument)
- Semantic conventions ✅ — Well-defined constants for agent framework, session, and trace attributes
- Tests ✅ — Comprehensive VCR-based test coverage
⚠️ Action Required
This PR has merge conflicts with main. Please rebase and resolve conflicts before this can be merged:
git fetch origin
git checkout <your-branch>
git rebase origin/main
# resolve conflicts, then:
git push --force-with-leaseAutomated review by github-manager-bot
ralf0131
left a comment
There was a problem hiding this comment.
Summary
Adds OpenTelemetry instrumentation for ByteDance DeerFlow 2.x. New package loongsuite-instrumentation-deerflow follows the established LoongSuite instrumentation pattern with proper version gating (2.x ≤ v < 3.x), reentrancy tracking via ContextVar, and wrapt-based function patching.
Findings
- [Info] The PR has merge conflicts with
mainthat need to be resolved before merge. - [Info] Core patch logic (802 lines) is well-structured. The
_ENTRY_DEPTHContextVar correctly handles reentrancy, andWeakKeyDictionaryfor graph markers avoids memory leaks. - [Info] Error handling is comprehensive:
DeerFlowRunError,DeerFlowRunTimeout,DeerFlowRunInterruptedprovide clear error semantics. - [Info] Consider splitting the CI workflow file additions into a separate commit for cleaner history.
Code looks good. Please resolve merge conflicts when convenient.
Automated review by github-manager-bot
ralf0131
left a comment
There was a problem hiding this comment.
Summary
DeerFlow 2.x observability adapter built on top of existing LangChain/LangGraph instrumentations. Clean adapter pattern with proper ENTRY/AGENT/STEP span hierarchy, Gateway and embedded-client lifecycle handling, and comprehensive test coverage (52 tests across Python 3.12-3.13).
Findings
- [Info]
patch.pyis 802 lines — the core instrumentation logic is substantial. Consider splitting Gateway vs embedded-client patches into separate modules if complexity grows. - [Info] Good use of
WeakKeyDictionaryfor graph marker tracking to avoid memory leaks, andContextVarfor entry depth to ensure thread safety.
Suggestions
- The version validation (
>=2, <3) and fail-open import handling are well-implemented. The documentation clearly explains the supported deployment modes (foreground/daemon/Docker/embedded SDK).
Automated review by github-manager-bot
Description
This PR adds observability support for ByteDance DeerFlow 2.x as a thin adapter over the existing LoongSuite LangChain and LangGraph instrumentations.
The adapter marks only DeerFlow-created LangGraph graphs with two internal scalar semantics: the framework name and the direct model-decision node name. LangGraph propagates those values through a copy of
RunnableConfig.metadata, and the LangChain tracer uses them to create oneAGENTand exactly oneSTEPper direct model decision. Existing LangGraph prebuilt ReAct detection and DeepAgents behavior remain unchanged.The DeerFlow package adds Gateway and embedded-client
ENTRYlifecycle handling, lead/subagent identity, session and user propagation, correlation attributes, streaming teardown, timeout/error/interruption handling, cached-alias restoration, and concurrency isolation. Direct SDK graph invocation starts atAGENTand does not invent an applicationENTRY.The public package supports the official DeerFlow source distribution at
>=2,<3and intentionally does not depend on the unrelated PyPI placeholder. The README documents local foreground/daemon, Docker development/production, and embedded SDK integration. Local command wrapping and persistent site bootstrap do not require changes to DeerFlow Python source.This PR does not change
loongsuite-distro/src/loongsuite/distro/bootstrap_registry; release registration and version refreshes remain part of the release workflow.Fixes # (N/A)
Type of change
How Has This Been Tested?
tox -e precommittox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-deerflow.stable -- -q(52 passed)tox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-deerflow.current -- -q(52 passed)tox -c tox-loongsuite.ini -e py313-test-loongsuite-instrumentation-deerflow.current -- -q(52 passed)tox -c tox-loongsuite.ini -e lint-loongsuite-instrumentation-deerflowtox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-langchain-latest -- -q(173 passed)tox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-langgraph-latest -- -q(20 passed)tox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-deepagents-latest -- -q(11 passed)tox -e py312-test-util-genai -- -q(271 passed, 1 skipped because optional OSS credentials were not configured)PYTHONPATH=.github/workflows/generate_workflows_lib/src python .github/workflows/generate_workflows.pyPYTHONPATH=.github/workflows/generate_workflows_lib/src python .github/workflows/generate_workflows_loongsuite.pyloongsuite-instrumentproduced oneAGENT -> STEP -> CHAIN -> LLMtree without duplicate core spansAGENT -> STEP -> LLMtree without an application import changemainDoes This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
Validation Evidence
Scope and compatibility
>=2,<3, Python 3.12+.bootstrap_registryhas no diff frommain; publishing metadata is deferred to the release process.main.agentdecision node.Lifecycle and telemetry
ENTRY; direct graph calls begin atAGENT.STEP; two-round tool loops reporttool_callsfollowed bystop.AGENTorSTEPspans.Weaver and CI
gen_ai.framework, an existing LoongSuite extension attribute not yet declared by the external registry; DeerFlow-specific lifecycle validation is otherwise complete.