From f6b3182a807b6dc8c1901bfe036714c5f1003b61 Mon Sep 17 00:00:00 2001 From: Lars Date: Sun, 12 Apr 2026 13:44:08 +0200 Subject: [PATCH] fix: Add wrapper in prompts.py execute endpoint for workflow signature mismatch Problem: Workflows executed via /api/prompts/execute (not /api/workflows/execute) were passing call_openrouter directly to execute_prompt_with_data, which then passes it to workflow_executor. workflow_executor expects (prompt, model) signature but call_openrouter has (prompt, max_tokens=4096) signature. Previous fix in workflows.py was correct but unused - workflows use prompts.py endpoint. Solution: Added workflow_llm_call() wrapper in execute_unified_prompt() endpoint that matches expected (prompt, model) -> str signature. Related: cb3aa48 (workflows.py fix for different endpoint) --- backend/routers/prompts.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/routers/prompts.py b/backend/routers/prompts.py index 1f32011..cc438db 100644 --- a/backend/routers/prompts.py +++ b/backend/routers/prompts.py @@ -1488,6 +1488,14 @@ async def execute_unified_prompt( 'vitalwerte': 7 } + # Wrapper function to match workflow_executor's expected signature: (prompt, model) -> str + # workflow_executor calls: openrouter_call_func(prompt, "anthropic/claude-sonnet-4") + # but call_openrouter expects: call_openrouter(prompt, max_tokens=4096) + async def workflow_llm_call(prompt: str, model: str = None) -> str: + # Ignore model parameter (already set in OPENROUTER_MODEL env var) + # Use default max_tokens=4096 from call_openrouter + return await call_openrouter(prompt) + # Execute with prompt_executor # Always enable debug when saving to collect metadata for value table result = await execute_prompt_with_data( @@ -1495,7 +1503,7 @@ async def execute_unified_prompt( profile_id=profile_id, modules=modules, timeframes=timeframes, - openrouter_call_func=call_openrouter, + openrouter_call_func=workflow_llm_call, # Use wrapper with correct signature enable_debug=debug or save # Enable debug if saving for metadata collection )