fix: Replace automation stubs with real execution engine
- Replace automation execute stub with run_automation() from execution_engine.py - Replace agent execute stub with run_agent() from agent_runner.py - Persist automation settings in system_settings.automation_config JSONB - Add migration 0034 for automation_config column - Settings are now saved and loaded from database instead of being ignored
This commit is contained in:
@@ -306,14 +306,38 @@ async def execute_agent(
|
||||
db.add(run)
|
||||
await db.flush()
|
||||
|
||||
# TODO: Execute agent asynchronously via Agent Runner
|
||||
run.status = "completed"
|
||||
run.completed_at = __import__("datetime").datetime.now(__import__("datetime").timezone.utc)
|
||||
run.duration_seconds = 0.0
|
||||
run.result = "Executed successfully (stub)"
|
||||
await db.flush()
|
||||
# Execute agent via agent runner
|
||||
from app.plugins.builtins.automation.agent_runner import run_agent
|
||||
|
||||
return {"status": "ok", "run_id": str(run.id)}
|
||||
run_id = str(run.id)
|
||||
await db.commit()
|
||||
|
||||
# Run agent
|
||||
result = await run_agent(
|
||||
ctx={"tenant_id": str(tenant_id), "user_id": current_user["user_id"]},
|
||||
agent_id=str(aid),
|
||||
trigger_type="manual",
|
||||
trigger_data={"triggered_by": current_user["user_id"]},
|
||||
)
|
||||
|
||||
# Update run with results
|
||||
from sqlalchemy import update as sa_update
|
||||
from datetime import datetime, timezone
|
||||
now = datetime.now(timezone.utc)
|
||||
async with db.begin():
|
||||
await db.execute(
|
||||
sa_update(AgentRun)
|
||||
.where(AgentRun.id == run.id)
|
||||
.values(
|
||||
status=result.get("status", "completed"),
|
||||
completed_at=now,
|
||||
duration_seconds=0.0,
|
||||
result=result,
|
||||
output_data=result,
|
||||
)
|
||||
)
|
||||
|
||||
return {"status": result.get("status", "ok"), "run_id": run_id, "result": result}
|
||||
|
||||
|
||||
@router.post(
|
||||
|
||||
Reference in New Issue
Block a user