feat: add LangfuseEventHandler telemetry package v0.2.1#3
Open
mrkeithelliott wants to merge 3 commits into
Open
feat: add LangfuseEventHandler telemetry package v0.2.1#3mrkeithelliott wants to merge 3 commits into
mrkeithelliott wants to merge 3 commits into
Conversation
…abs-agentflow v0.1.1 - Rename package to gittielabs-agentflow in pyproject.toml (import stays agentflow) - Add LLM_CALL_STARTED / LLM_CALL_COMPLETED constants to events.py - Emit LLM call events from AgentExecutor.run() with node_id, session_id, timing, and token usage - Fix google_genai.py: thinking metadata was computed but dropped; now passed to AgentResponse - Export new event constants from agentflow.__init__ - Add orchestration and telemetry optional dependency groups Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- session/multi_user.py: MultiUserHistory with HistoryPersistence protocol
- Per-user in-memory history with configurable max and optional persistence backend
- load()/save() for pluggable DB persistence (e.g. PostgreSQL adapter)
- Lazy loading: each user's history is loaded from persistence exactly once per session
- orchestration/types.py: Plan and PlanStep TypedDicts
- orchestration/executor.py: DAGExecutor with topological round-batching
- asyncio.gather() for independent steps, dependency resolution via {{key.result}} refs
- Graceful fallback to sequential execution on circular deps
- orchestration/classifier.py: ComplexityClassifier
- Fast bypass for short messages (< 20 words, no multi-step markers)
- Haiku LLM call for ambiguous messages, defaults to SIMPLE on failure
- Export all new symbols from agentflow.__init__
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- telemetry/langfuse_handler.py: LangfuseEventHandler - Maps EventBus events to Langfuse trace/span/generation hierarchy - WORKFLOW_STARTED -> trace, NODE_STARTED -> span, LLM_CALL_COMPLETED -> generation - TOOL_CALLED -> child span under node span, NODE_COMPLETED/ERROR -> close span - LLM generations nested under correct node span via node_id thread-through - flush() method for graceful shutdown - Lazy import via __getattr__ to avoid hard failure when langfuse not installed - env var is LANGFUSE_BASE_URL (not LANGFUSE_HOST) for US cloud Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
agentflow/telemetry/package withLangfuseEventHandlerthat maps EventBus events to the Langfuse trace/span/generation hierarchyWORKFLOW_STARTED→langfuse.trace(),NODE_STARTED→trace.span(),LLM_CALL_COMPLETED→span.generation()(with model, token counts, latency),TOOL_CALLED→ child span,NODE_COMPLETED/WORKFLOW_COMPLETEDclose their objects,ERRORmarks spans as failed__init__.pyvia__getattr__— importingagentflownever fails even whenlangfuseis not installed0.2.1; addstelemetry = ["langfuse>=2.0"]optional dependency groupTest plan
pip install -e ".[dev]"passes (no langfuse installed) — lazy import does not raisepip install -e ".[dev,telemetry]"thenfrom agentflow import LangfuseEventHandlerworkspytest tests/ -v— 150 pass, 1 pre-existing Qdrant mock failure unrelated to this PRLANGFUSE_*env vars, send a message through openclaw, verify trace tree appears in Langfuse cloud🤖 Generated with Claude Code