Skip to content

fix(api): log skipped agent self-mentions in comments - #791

Merged
pikann merged 1 commit into
Paca-AI:masterfrom
kayahk:fix/log-self-mention-skip
Nov 19, 2026
Merged

pikann merged 1 commit into
Paca-AI:masterfrom
kayahk:fix/log-self-mention-skip

Conversation

@kayahk

@kayahk kayahk commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

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.WarnContext at both skip sites — task comments and doc comments — matching the existing comment mention trigger failed / doc comment mention trigger failed conventions. 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.

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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 — triggerMentionedAgent logs comment mention skipped: agent mentioned itself with the project, agent and task ids, then still returns true so no conversation or notification is created.
  • Doc comments — the matching branch in handleMentions logs the same warning with document_id; both new *AgentID dereferences sit behind existing nil checks, so they cannot panic.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 pikann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for the contribution! 🚀

@pikann
pikann merged commit 2cfb7b8 into Paca-AI:master Nov 19, 2026
6 checks passed
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.

Agent self-mentions in comments are silently dropped

2 participants