Skip to content

fix(execution): MCP sync task triggered_by=mcp attribution (#473) - #475

Merged
vybe merged 1 commit into
mainfrom
feature/473-mcp-sync-triggered-by
Apr 23, 2026
Merged

vybe merged 1 commit into
mainfrom
feature/473-mcp-sync-triggered-by

Conversation

@vybe

@vybe vybe commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The /task endpoint always wrote triggered_by = "manual" for non-agent callers, even when the request came through MCP
  • Added elif x_via_mcp: triggered_by = "mcp" branch to mirror the identical pattern already working in /chat
  • Both sync and async execution paths are fixed (they share the same variable)

Changes

  • src/backend/routers/chat.py — 3-line fix at the triggered_by determination block in execute_parallel_task
  • tests/test_self_execute.py — Added test_triggered_by_mcp_for_mcp_user_calls; updated existing tests to include x_via_mcp in the logic under test

Test Plan

  • TestTriggeredByField (4 tests): pytest tests/test_self_execute.py::TestTriggeredByField -v — all pass
  • Full test_self_execute.py suite (22 tests) — all pass
  • Manual: trigger a /task via MCP client, verify schedule_executions.triggered_by = "mcp" in DB

Fixes #473

🤖 Generated with Claude Code

The /task endpoint always set triggered_by="manual" for non-agent callers,
regardless of whether the request arrived via MCP. This broke audit trail
attribution — MCP-initiated executions were indistinguishable from direct
UI triggers.

Added `elif x_via_mcp: triggered_by = "mcp"` branch to mirror the
identical pattern already working in the /chat endpoint. Covers both sync
and async execution paths since they share the same variable. Updated
TestTriggeredByField tests to cover the new MCP branch explicitly.

Fixes #473

Co-Authored-By: Claude <[email protected]>
@vybe
vybe merged commit a333e77 into main Apr 23, 2026
@trinity-ability trinity-ability mentioned this pull request Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: MCP sync execution recorded as triggered_by=manual instead of mcp

1 participant