fix(api): fix transparent upgrade SSE channel mismatch and chat mode routing

- workflow_execute_task: add AppMode.CHAT/AGENT_CHAT/COMPLETION to the
  AdvancedChatAppGenerator routing branch so transparently upgraded old
  apps can execute through the workflow engine.
- app_generate_service: use app_model.mode (not hardcoded AppMode.AGENT)
  for SSE event subscription channel, ensuring the subscriber and
  Celery publisher use the same Redis channel key.

Made-with: Cursor
This commit is contained in:
Yansong Zhang
2026-04-09 17:27:41 +08:00
parent 2de2a8fd3a
commit e50c36526e
2 changed files with 9 additions and 2 deletions

View File

@ -165,10 +165,11 @@ class AppGenerateService:
on_subscribe = cls._build_streaming_task_on_subscribe(on_subscribe)
generator = AdvancedChatAppGenerator()
subscribe_mode = AppMode.value_of(app_model.mode)
return rate_limit.generate(
generator.convert_to_event_stream(
generator.retrieve_events(
AppMode.AGENT,
subscribe_mode,
payload.workflow_run_id,
on_subscribe=on_subscribe,
),

View File

@ -183,7 +183,13 @@ class _AppRunner:
pause_state_config: PauseStateLayerConfig,
):
exec_params = self._exec_params
if exec_params.app_mode in {AppMode.ADVANCED_CHAT, AppMode.AGENT}:
if exec_params.app_mode in {
AppMode.ADVANCED_CHAT,
AppMode.AGENT,
AppMode.CHAT,
AppMode.AGENT_CHAT,
AppMode.COMPLETION,
}:
return AdvancedChatAppGenerator().generate(
app_model=app,
workflow=workflow,