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

@@ -26,6 +26,7 @@ from langchain_core.messages import AIMessage, HumanMessage, SystemMessage, Tool
from app.agents.filesystem_agent import FILESYSTEM_TOOLS
from app.llm import get_llm
import app.tracing as tracing
logger = logging.getLogger(__name__)
@@ -144,7 +145,10 @@ def _build_system_prompt(
if existing_template
else ""
)
return _SYSTEM_PROMPT_TEMPLATE.format(
# Try Langfuse-managed prompt first, fall back to hardcoded template
managed = tracing.get_prompt("journey_system", fallback=None)
template = managed if managed is not None else _SYSTEM_PROMPT_TEMPLATE
return template.format(
directory=directory,
data_types=", ".join(data_types),
template_start=_TEMPLATE_START,