Skip to content

feat(comment): show which agent posted a comment - #2471

Merged
gregberge merged 2 commits into
mainfrom
greg/arg-496-let-the-agent-identify-itself-in-mcp-cli
Aug 13, 2026
Merged

gregberge merged 2 commits into
mainfrom
greg/arg-496-let-the-agent-identify-itself-in-mcp-cli

Conversation

@gregberge

Copy link
Copy Markdown
Member

Closes ARG-496. Part 2 of 2 — the CLI half is argos-ci/argos-javascript#367. They ship independently: the backend reads the header whatever CLI version sent it.

An agent acts with its user's own credentials, so a comment Claude Code or an MCP client writes is indistinguishable from one the person typed. This records which agent was behind the request and marks the comment with it.

agent-comment-badge.png

Two comments, same author. Only the one Claude Code posted is marked.

How a request is attributed

src/agent/request.ts resolves an agent from whichever signal the surface carries:

  • CLI — the agent/<name> token in the User-Agent.
  • MCP — the OAuth client behind the access token, via its knownAppId. An OAuth client that isn't the first-party CLI is taken to be an agent even when the known-apps registry doesn't recognize it, since OAuth exists here to serve the CLI and MCP clients and MCP is an agent protocol. Those store unknown and render as a generic bot: we still know it was an agent, we just can't name it.

Everything else — the web app, a script, a bare personal access token — resolves to null.

Names are matched against a curated registry (src/agent/registry.ts) rather than stored verbatim. A self-asserted name is untrusted input (AI_AGENT is whatever the caller sets), and rendering one next to a real person's avatar is a spoofing vector. Ids are shared with oauth/known-apps.ts where the same product appears in both, so the frontend keys one logo map by them.

The rest

  • Migration + comments.agent, wired through createComment.
  • Comment.agent { id, name } on GraphQL and REST.
  • CommentAgentBadge on the author's avatar, matching the existing avatar-badge pattern in BuildReviewersStatusList. The logo map moved to containers/brand-logos.tsx, now shared with OAuthAppLogo.

Worth a look during review

An unrelated MCP bug, fixed here. Comment.query().insert() returns a model carrying only the columns written, so resolvedAt / editedAt came back undefined and createBuildComment over MCP failed its own output-schema validation. Switched to insertAndFetch. That tool was broken before this branch; the new MCP e2e test is what surfaced it.

The second commit is a real-world correction. Running the built CLI against a local echo server showed Claude Code sets AI_AGENT=claude-code_2-1-227_agent — a version suffix the registry didn't match, so the agent most likely to post a comment fell back to the generic bot. resolveReportedAgentId now strips the version (_, and the @ the convention documents) before the lookup.

Verified

pnpm run static-checks, unit (654) and integration (1189) suites all green.

New coverage:

  • src/agent/request.test.ts — header parsing and the resolution order, including the versioned names agents really report.
  • comments.e2e.test.ts — a comment posted with the exact User-Agent the CLI sends today, an unrecognized agent, and a person posting directly.
  • mcp.e2e.test.ts — a comment through the MCP loopback, attributed from the OAuth client, recognized and not.
  • project-tests.spec.ts — the badge on an agent comment and not on the one the same person typed, plus a screenshot.

One MCP scope test flaked once under full-suite load (body.result undefined) and passed on re-run and in isolation — unrelated to this change.

Not included

User-facing docs. They live in the docs repo and the issue didn't scope them; happy to follow up with a page on agent attribution.

🤖 Generated with Claude Code

gregberge and others added 2 commits August 13, 2026 21:52
An agent acts with its user's own credentials, so a comment Claude Code or
an MCP client writes is indistinguishable from one the person typed. Record
the agent behind the request — the CLI's `agent/<name>` User-Agent token, or
the OAuth client behind an MCP tool call — and mark the comment with the
agent's logo, or a generic bot, on the author's avatar.

Also switches the insert to `insertAndFetch`: `insert` returned a model
missing every database-defaulted column, so `createBuildComment` over MCP
failed its own output-schema validation on a null `resolvedAt`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude Code sets AI_AGENT to `claude-code_2-1-227_agent`, and the AI_AGENT
convention documents `devin@1`. Both reached the registry whole and resolved
to the generic bot, so the one agent most likely to post a comment lost its
own logo. Strip the version before the lookup.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@argos-ci

argos-ci Bot commented Aug 13, 2026

Copy link
Copy Markdown

1 screenshot uploaded by Argos

NamePreview
agent-comment-badge.png
A comment posted through Claude Code, next to one the same person typed. The agent's mark sits on the author's avatar; agents we don't recognize get a generic bot.
agent-comment-badge.png

Uploaded with Argos ↗︎. This comment is updated in place.

@linear-code

linear-code Bot commented Aug 13, 2026

Copy link
Copy Markdown

ARG-496

@argos-ci

argos-ci Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
argos/default (Inspect) 👍 Approved by Greg Bergé 1 changed, 2 added, 1 ignored Aug 13, 2026, 8:06 PM
storybook/default (Inspect) ✅ No changes detected - Aug 13, 2026, 8:05 PM
Deployment Status Branch Updated (UTC)
storybook/preview (Open) Ready greg/arg-496-let-the-agent-identify-itself-in-mcp-cli Aug 13, 2026, 8:04 PM

@gregberge
gregberge requested a review from jsfez August 13, 2026 20:07
@gregberge
gregberge merged commit a9a3840 into main Aug 13, 2026
16 checks passed
@gregberge
gregberge deleted the greg/arg-496-let-the-agent-identify-itself-in-mcp-cli branch August 13, 2026 20:54
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.

1 participant