Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@


from contextlib import asynccontextmanager
import asyncio

from fastapi import APIRouter, FastAPI
from fastapi.middleware.cors import CORSMiddleware
Expand Down Expand Up @@ -68,6 +69,10 @@ async def lifespan(app: FastAPI):
await sync_manager.start()
set_worker_sync_manager(sync_manager)

# Start async background backfill of Paygent agents (non-blocking)
from api.services.pipecat.paygent_agent_sync import run_backfill_if_requested
asyncio.create_task(run_backfill_if_requested())

yield # Run app

# Shutdown sequence - this runs when FastAPI is shutting down
Expand Down
7 changes: 7 additions & 0 deletions api/routes/workflow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import re
import asyncio
import uuid
from datetime import datetime
from typing import List, Literal, Optional
Expand Down Expand Up @@ -399,6 +400,9 @@ async def create_workflow(
},
)

from api.services.pipecat.paygent_agent_sync import ensure_agent_async
asyncio.create_task(ensure_agent_async(workflow.id, workflow.name))

if trigger_paths:
await db_client.sync_triggers_for_workflow(
workflow_id=workflow.id,
Expand Down Expand Up @@ -499,6 +503,9 @@ async def create_workflow_from_template(
},
)

from api.services.pipecat.paygent_agent_sync import ensure_agent_async
asyncio.create_task(ensure_agent_async(workflow.id, workflow.name))

if trigger_paths:
await db_client.sync_triggers_for_workflow(
workflow_id=workflow.id,
Expand Down
Loading