Repository navigation
fix(api): log skipped agent self-mentions in comments - #791
Conversation
An agent mentioning itself in a task or doc comment is silently dropped (anti-loop guard). That made API/MCP automation that re-dispatches a lost mention look broken: the comment posted, nothing happened, and neither logs nor the API showed why. Warn instead, matching the trigger-failure logging above it.
There was a problem hiding this comment.
ℹ️ No critical issues — one test-coverage note inline.
Approach: sound — the anti-loop guard is untouched, and both silent self-mention skips now emit a warning alongside the existing mention trigger failed logs.
Reviewed changes
- Task comments —
triggerMentionedAgentlogscomment mention skipped: agent mentioned itselfwith the project, agent and task ids, then still returnstrueso no conversation or notification is created. - Doc comments — the matching branch in
handleMentionslogs the same warning withdocument_id; both new*AgentIDdereferences sit behind existing nil checks, so they cannot panic.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
| // Log it: a silent skip here is indistinguishable from the mention | ||
| // doing nothing, which makes automation re-dispatch via mention | ||
| // (blocked by design for self-mentions) look broken. | ||
| slog.WarnContext(ctx, "comment mention skipped: agent mentioned itself", "project_id", in.ProjectID, "agent_id", *agentMember.AgentID, "task_id", in.TaskID) |
There was a problem hiding this comment.
The new line is never executed by the task-side self-mention test: TestActivitySvc_AddComment_AgentSelfMention_DoesNotRetrigger seeds its agent member as {ID: agentMemberID, MemberType: "agent"} with a nil AgentID, so the agentMember.AgentID == nil guard above returns false first — that test would still pass if this branch were deleted. Adding AgentID: &agentMemberID to the fixture in services/api/internal/service/task/activity_service_test.go makes both the guard and this log line actually run (the doc-side test already does).
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀

Fixes #790.
An agent mentioning itself in a task or document comment is silently dropped by the anti-loop guard. The guard is correct (a self-mention must not retrigger the agent's own conversation, or quoting its own comment could loop a turn forever) — but the silent skip is indistinguishable from the mention doing nothing, which makes automation acting in an agent's own identity (MCP/API re-dispatch) look broken.
This adds a
slog.WarnContextat both skip sites — task comments and doc comments — matching the existingcomment mention trigger failed/doc comment mention trigger failedconventions. Behavior is unchanged: the skip still happens, it is just observable.Tests: existing self-mention guard tests pass unchanged (
go test ./internal/service/task/ ./internal/service/doc/); log-only change, no new assertions needed.