Repository navigation
fix(execution): MCP sync task triggered_by=mcp attribution (#473) - #475
Merged
Merged
Conversation
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]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/taskendpoint always wrotetriggered_by = "manual"for non-agent callers, even when the request came through MCPelif x_via_mcp: triggered_by = "mcp"branch to mirror the identical pattern already working in/chatChanges
src/backend/routers/chat.py— 3-line fix at thetriggered_bydetermination block inexecute_parallel_tasktests/test_self_execute.py— Addedtest_triggered_by_mcp_for_mcp_user_calls; updated existing tests to includex_via_mcpin the logic under testTest Plan
TestTriggeredByField(4 tests):pytest tests/test_self_execute.py::TestTriggeredByField -v— all passtest_self_execute.pysuite (22 tests) — all pass/taskvia MCP client, verifyschedule_executions.triggered_by = "mcp"in DBFixes #473
🤖 Generated with Claude Code