Fix/langfuse tracing UI format - #3
Merged
Merged
Conversation
Replace broken LangChain callback (incompatible with langchain 1.x) with Langfuse SDK direct trace API — no LangChain dependency, works reliably with Langfuse server v2. Add marked@15 to web app and render agent messages as proper HTML so bold (**text**), lists, code blocks, and headers display correctly instead of showing raw *** symbols. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Display the active session ID as a monospace badge at the top of the chat so users can correlate conversations with Langfuse traces. Add a "New chat" button that resets the message list and generates a fresh session ID. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Planner: rewrite prompt to output exactly one token — eliminates verbose
LLM output that contained the word "tools" in prose, which was tripping
the old `"tool" in next_step` router into always calling search.
Router: tighten check to `startswith("tool:")` so natural language in
next_step can never accidentally match.
Synthesizer: make it the sole owner of message history — planner no longer
adds the user message, so synth adds the User+Assistant pair together at
end of each turn. Fixes the bug where current user message appeared twice
in the synthesizer's context, confusing the LLM about what was history vs
the current question.
Frontend: persist session ID in localStorage so memory survives page
refreshes instead of generating a new ID on every load.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace ainvoke with astream_events so every LangGraph event is captured.
Build a structured Langfuse trace hierarchy in real time:
Trace (agent-workflow)
├── Span: planner — node input/output + decision made
│ └── Generation — exact prompt, model, response, token counts, latency
├── Span: tool:search — query input, raw results, errors [if triggered]
└── Span: synth — node input/output
└── Generation — exact prompt, model, response, token counts, latency
Nodes now accept RunnableConfig and pass it to llm.invoke()/tool.invoke()
so LangGraph propagates the astream_events callback manager into LLM and
tool calls, making them surface as on_chat_model_* and on_tool_* events.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Server (docker-compose.yml): - langfuse/langfuse:2 → langfuse/langfuse:3 (web) - Add langfuse/langfuse-worker:3 (async job processor) - Add clickhouse/clickhouse-server:24.12 (trace/span storage) - Add minio + minio-init (S3-compatible blob storage + bucket setup) - Redis is now shared between agent platform and Langfuse worker queue - LANGFUSE_HOST updated to http://langfuse-web:3000 inside compose network - ENCRYPTION_KEY added (placeholder — generate with: openssl rand -hex 32) SDK (pyproject.toml + agent.py): - langfuse>=2.0.0,<3.0.0 → langfuse>=3.14.6,<4.0.0 - Replace manual astream_events trace builder (80 lines) with LangfuseCallbackHandler (v3 fixed langchain_core import compat) attached to invoke_config["callbacks"] - Wrap invocation in start_as_current_observation() so user_id, session_id, tags, and metadata are set on the root trace via update_current_trace() - Graceful fallback to plain ainvoke when Langfuse is not configured Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…, Alembic Core fixes: - Truncate history sent to LLM at 10 turns; full history stays in Postgres checkpoint - Wrap all LLM calls with exponential backoff retry (3 attempts, jitter) - Split planner model from synthesizer via PLANNER_MODEL env var - Replace create_tables() with Alembic migrations; exclude LangGraph tables from autogenerate Tracing: - Fix Langfuse v3: use sync context manager, create CallbackHandler inside active span so node observations nest correctly under the root trace Tooling: - Fix duckduckgo_search -> ddgs (package renamed) - Fix agentdb port conflict: map 5433:5432 - Fix frontend: 120s AbortSignal timeout + improved error messages with URL Tests: - Fix integration tests: use TestClient as context manager so FastAPI lifespan fires - Fix mock LLM to accept **kwargs (LangGraph passes config= through) - Add 13 unit tests covering all four fixes Docs: - Update README features, env vars table (PLANNER_MODEL), repo structure, tech stack Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The test connects to a live DB, which doesn't exist in the unit CI job. Skip gracefully via pytest.skip() on OperationalError so unit tests pass in both local (DB available) and CI (no DB) environments. 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
Changes
Type of change
fix/)feature/)chore/)Checklist
just test)just lint && just format-check)just typecheck).env.exampleupdated if new env vars were introducedNotes for reviewer