Repository navigation
Description
Summary
schedule_executions carries five execution-origin columns for audit (source_user_id, source_user_email, source_agent_name, source_mcp_key_id, source_mcp_key_name), but the scheduler's create_execution() never writes them — they are NULL on every scheduler-created row. triggered_by records that a run was manual, but never who triggered it. Once server logs roll, "did anyone trigger this run, and who?" becomes unanswerable from the database.
This is an audit-completeness gap, not a vulnerability — no access control depends on these columns.
Component
Scheduler (database layer) / Backend (schedules router)
Priority
P2 — executions run correctly; the attribution metadata is simply absent.
Error
No error is raised. The failure is silent and only visible on inspection:
triggered_by = manual
source_user_id = NULL
source_user_email = NULL
source_agent_name = NULL
source_mcp_key_id = NULL
source_mcp_key_name = NULL
Observed as NULL across the entire execution history of an actively used schedule (100+ runs, mixed schedule and manual).
Location
- File:
src/scheduler/database.py - Line: 373 —
create_execution() - Function:
create_execution()— the INSERT column list omits all fivesource_*columns
cursor.execute("""
INSERT INTO schedule_executions (
id, schedule_id, agent_name, status, started_at, message, triggered_by,
model_used, attempt_number, retry_of_execution_id
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""", (...))Root Cause
The columns exist in the schema and the backend's own database layer supports them (src/backend/database.py accepts source_user_id and siblings), but the scheduler is a separate service with its own DB module, and its create_execution() was never extended to match. Nor does the signature accept them — there is no parameter to thread a caller identity through:
def create_execution(
self, schedule_id, agent_name, message,
triggered_by="schedule", model_used=None,
attempt_number=1, retry_of_execution_id=None,
) -> Optional[ScheduleExecution]:The identity is available at the point of origin — the backend's trigger endpoint authenticates the caller (user or MCP key) before delegating — but it is dropped at the backend → scheduler hop, which forwards only schedule_id in the URL path.
Consequence: for cron-triggered runs NULL is correct and harmless. For triggered_by='manual' runs the attribution exists only in MCP-server / backend logs, bounded by log retention, so the durable record cannot answer who initiated a run.
Reproduction Steps
- Trigger any agent schedule manually (MCP
trigger_agent_schedule, or the backend trigger endpoint) as an authenticated user or MCP key. - Query the resulting row:
SELECT triggered_by, source_user_id, source_user_email, source_agent_name, source_mcp_key_id, source_mcp_key_name FROM schedule_executions ORDER BY started_at DESC LIMIT 1;
- Observe
triggered_by = 'manual'with all fivesource_*columns NULL.
Suggested Fix
Thread the authenticated caller from the backend trigger endpoint through to create_execution().
src/backend/routers/schedules.py— forward the caller identity in the POST body to the scheduler's trigger endpoint (currently identity-free):
response = await client.post(
f"{SCHEDULER_URL}/api/schedules/{schedule_id}/trigger",
json={
"source_user_id": current_user.id,
"source_user_email": current_user.email,
"source_mcp_key_id": mcp_key.id if mcp_key else None,
"source_mcp_key_name": mcp_key.name if mcp_key else None,
},
timeout=10.0,
)-
src/scheduler/main.py— read that payload in_trigger_handler()and pass it down through_execute_manual_trigger(). -
src/scheduler/database.py— accept the fields and include them in the INSERT:
def create_execution(
self, schedule_id, agent_name, message,
triggered_by="schedule", model_used=None,
attempt_number=1, retry_of_execution_id=None,
source_user_id=None, source_user_email=None,
source_agent_name=None, source_mcp_key_id=None, source_mcp_key_name=None,
) -> Optional[ScheduleExecution]:Cron-triggered runs keep passing NULL, which is the correct value for them.
Note this composes with the sibling issue on execution_id: undefined — both are fixed most cleanly by creating the execution record synchronously in _trigger_handler(), at which point the caller identity is still in scope. Worth sequencing them together.
Environment
- Observed on a deployed instance running
1d3863d5 - Confirmed still present at
4d743fdb(2026-07-27) —create_execution()INSERT column list is unchanged
Related
src/scheduler/database.py—create_execution()src/backend/database.py— backend equivalent, which does acceptsource_*src/backend/routers/schedules.py— manual trigger delegation (identity dropped here)- Sibling gaps in the same manual-trigger path filed separately (undefined
execution_id; silent lock-denied cron tick)
Activity
dolho commentedon Aug 4, 2026
/claim — picking this up. Branch:
fix/1970-scheduler-execution-origin.github-actions commentedon Aug 4, 2026
@dolho This issue is already assigned to dolho. Use
/unclaimfirst if you want to take over.dolho commentedon Aug 4, 2026
PR: #1974
fix(scheduler): bound source_user_id and fix is_empty (#1970, /edge-c…
fix(scheduler): record who initiated an execution (#1970) (#1974)
fix(scheduler): record who initiated an execution (#1970)
fix(scheduler): record who initiated an execution (#1970)
fix(scheduler): return a real execution_id, and 409 when nothing star…
feat(schedules): Run-now and webhook fires of an addressed schedule s…
feat(schedules): a schedule that names a user runs as that seat — rea…
feat(workspace): the role card in Agent details — role, objectives wi…
test(execution-origin): the #1970 guard reads the whole trigger handl…