feat(batch-agent): add Langfuse prompt management

- _get_system_prompt helper: fetches managed prompts from Langfuse
  with hardcoded fallback (same pattern as chat service)
- journey.py: journey_system prompt manageable via Langfuse
- agent_runner.py: batch_file_classifier, batch_processing,
  batch_cloud_processing prompts all manageable via Langfuse
- redis_consumer.py: link_prompt_to_trace for all three handlers
This commit is contained in:
Roberto Musso
2026-03-23 22:30:36 +01:00
parent 75a826c9d8
commit 55500cc818
3 changed files with 22 additions and 4 deletions

View File

@@ -46,6 +46,7 @@ async def _handle_journey_start(user_id: str, data: dict[str, Any]) -> None:
) as span:
langfuse_handler = tracing.get_langfuse_callback()
reply = await handle_journey_start(user_id, data, langfuse_handler=langfuse_handler)
tracing.link_prompt_to_trace(span, "journey_system")
span.update(output=reply.get("message", "")[:500])
await _publish_to_user(user_id, reply)
tracing.flush()
@@ -78,6 +79,7 @@ async def _handle_journey_message(user_id: str, data: dict[str, Any]) -> None:
) as span:
langfuse_handler = tracing.get_langfuse_callback()
reply = await handle_journey_message(user_id, data, langfuse_handler=langfuse_handler)
tracing.link_prompt_to_trace(span, "journey_system")
span.update(output=reply.get("message", "")[:500])
await _publish_to_user(user_id, reply)
tracing.flush()
@@ -112,6 +114,7 @@ async def _handle_agent_trigger(user_id: str, data: dict[str, Any]) -> None:
) as span:
langfuse_handler = tracing.get_langfuse_callback()
await run_local_agent(user_id, data, langfuse_handler=langfuse_handler)
tracing.link_prompt_to_trace(span, "batch_processing")
span.update(output={"status": "completed"})
tracing.flush()
except Exception as exc: