- shared/config.py: add LANGFUSE_SECRET_KEY, LANGFUSE_PUBLIC_KEY, LANGFUSE_HOST - services/chat/app/tracing.py: new module — Langfuse client singleton, create_trace(), get_langfuse_callback(), get_prompt(), link_prompt_to_trace(), score_trace(), flush/shutdown helpers. Gracefully no-ops when keys are missing. - services/chat/app/llm.py: add callbacks param to get_llm() for LangChain callback handler injection - services/chat/app/deep_agent.py: accept langfuse_handler in all run_* and _run_single_agent* functions, pipe callbacks to LLM calls, fetch managed prompts from Langfuse with fallback to hardcoded system prompts - services/chat/app/redis_consumer.py: create Langfuse trace per request (home_request/floating_request), pass callback handler to deep_agent, link prompt name to trace, attach output preview, flush after each request - services/chat/app/main.py: shutdown Langfuse client in lifespan teardown - services/chat/requirements.txt: add langfuse>=2.0.0 Langfuse prompt names: 'home_system', 'floating_system' — create these in the Langfuse dashboard to manage prompts. Without them, hardcoded defaults are used transparently.
Chat Service
Owns: deep_agent (home + floating chat), memory middleware, domain agents (task, note, project, timeline), LLM orchestration.
Tables owned
memory_corememory_associativememory_episodicmemory_proactive
Tables read (cross-service)
users(for encryption_key — memory decryption)
Endpoints
POST /chat(REST fallback)
Redis channels
- Subscribe:
chat:request:{user_id} - Publish:
ws:out:{user_id}(stream frames + tool calls) - BRPOP:
tool:result:{call_id}(30s timeout)