Repository navigation
fix(agents): tell two people's same-named agents apart - #571
Conversation
The server identified an MCP agent only by the agent_name it sent, so two agents with one name on a canvas merged: one presence, and one agent's set_status or disconnect ended the other's tasks, across accounts too. An outside agent is now its account, its MCP session and its name, hashed into an opaque agentKey on the actor, its presence and its tasks (tasks.agent_key, migration 0060). /mcp stays stateless but hands each initialize a fresh Mcp-Session-Id that clients send back; a client that does not is known by its account. Resident roles keep their name as identity. One owner's same-named agents read "Claude", "Claude 2". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The changes affect MCP agent work and navigation within shared canvases. Fix the resident feedback claim before merging so outside agents receive their promised first chance to respond. FindingsSummaryThe PR separates outside agents by account and name, then carries their key through presence, tasks, stored task rows, and frame navigation.
|
…perks (doop-design#571) * feat(billing): make upgrading to Pro easy to find, and give Pro real perks Upgrade to Pro is now one modal reachable from the rail, the account menu, Settings → Plan, the canvas Help menu and ⌘K, and any `?upgrade` link. It creates the workspace at checkout (named after payment), sells seats as a minimum, and lists the plans as short cards with a full comparison folded underneath. Team is renamed Pro in the UI; the plan id stays `team`. Pro lifts Free's limits: uploads to 100 MB instead of 5, and font libraries past two families. Pro also gets priority support. Billing off, nothing is limited. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(billing): address review: seat changes wait for Stripe, never reuse a canceled workspace - PUT /billing/seats answers once Stripe has the quantity, and puts the old choice back (502) when Stripe refuses. - The upgrade modal only reuses workspaces that never had a plan; a canceled one is reactivated from its own billing page. - The billing pane edits the seat minimum itself (down to 1), so a minimum can be released as people leave. - The canvas Upgrade action is enabled and shown only where billing is on and the account is Free (offersUpgrade, shared with the rail and account menu). - Settings → Plan with billing off shows the self-hosted allowance, not Free. - A font upload stores its file only after the in-queue checks pass, so a refused family leaves no asset behind. - The naming prompt is checked on every load that shows the workspace paid, not only in the checkout return's sync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(billing): run a seat change and its rollback on the workspace's seat queue A failed change restored its old value outside the queue, so it could undo a later change that was waiting for Stripe. The choice, the Stripe update and the rollback now run as one step of the per-workspace seat chain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: give the account menu's me mock offersUpgrade Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit fc7f2e56125aa474171bf322f084d032ebf7766d)
taskFrameId still looked up a running task's presence and stream by name, so with two agents called "Claude" a task click could fly to the other agent's frame. The store also kept only a stream actor's name and colour, which made locatePresence's identity match miss a streaming outside agent. Stream actors now keep agentKey, and both lookups match on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PostHog's custom_agent_connected (one per initialize) shows Codex and the openai-mcp clients starting a session every few seconds and Claude Code in bursts, so a session-scoped key split one agent into many. The key is now account + name; one person's same-named agents stay one agent, and the Mcp-Session-Id minting and the "Claude 2" label go. Review follow-ups: feedback on an outside agent's task waits a minute for that agent before any agent may take it; get_feedback and delivered feedback say whose work it is about; isAgentsTask is the one matching rule; stream actors pass through whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| * whose work it is about has had its minute, and its own feedback at once. | ||
| * Resident roles (no key) are routed by `targetAgent` and never wait. */ | ||
| function ownerFirst(f: TaskFeedback, agent: Pick<Actor, 'name' | 'agentKey'>, now: number): boolean { | ||
| if (!f.agentKey || !agent.agentKey || f.agentKey === agent.agentKey) return true |
There was a problem hiding this comment.
ownerFirst lets resident agents skip the new one-minute wait because they have no agentKey. When someone replies to an outside Claude's task, addTaskFeedback immediately wakes the resident runner. If a model is available, Doop can claim the reply before Claude's next call, so Claude never receives the requested change. Apply the wait to feedback carrying another agent's key, including when the caller is a resident.
There was a problem hiding this comment.
Right, fixed in 7a6bd83. The wait now lives in feedbackFor, so it holds for every agent other than the one whose work the feedback is about, residents included. pendingWorkAgents leaves waiting feedback out, so a sweep doesn't run for it early, and addTaskFeedback wakes the residents again once OWNER_FIRST_MS is up. Covered by 'makes the resident agents wait the minute too' in tests/agentIdentity.test.ts.
| const face = ( | ||
| <PresenceFace name={p.name} color={p.color} kind={p.kind} brand={p.brand} glaze={active} glazeDelay={glazeDelay} /> | ||
| ) | ||
| const face = <PresenceFace name={p.name} color={p.color} kind={p.kind} glaze={active} glazeDelay={glazeDelay} /> |
There was a problem hiding this comment.
Removing brand={p.brand} makes same-named agents share the first matching presence's icon. Without an explicit brand, AgentIcon looks it up by name. If two people's agents use the same name but connect through different products, both faces show the first product's mark. Keep passing each presence's brand through PresenceFace so people can tell them apart.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Good catch: that was an accident, not intended. I reverted this file from a stale local main and lost brand. It's restored to the PR's base in 7a6bd83, so the PR no longer touches PeerAvatars.tsx.
Feedback on an outside agent's task waited a minute for that agent, but the resident agents skipped the wait and were woken at once, so Doop could take a reply meant for Claude. The wait now holds for every other agent (feedbackFor, pendingWorkAgents), and the residents are woken again when it ends. Also restores PeerAvatars' brand icons, dropped by a revert taken from a stale local main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt-identity # Conflicts: # .context/TECHSTACK.md # server/db/migrations/meta/0060_snapshot.json # server/db/migrations/meta/_journal.json
Problem
The server identified an outside (MCP) agent only by the
agent_nameit sent, so two agents with the same name on one canvas became one agent:agentPresences/agentTouch).sameAgent()matched onagentName, so one agent'sset_statusclosed the other's open task, andendAgentTasks(on presence expiry) ended both, failing claimed cards as "disconnected".Fix
An outside agent is now its account + its name, hashed into an opaque
agentKey(shared/agentIdentity.ts,mcpAgentKeyinserver/mcp.ts).agentKeyis onActor,Presence(the presence map is keyed by it andclientIdisagent:<key>) andAgentTask(tasks.agent_key, migration0060_agent_key). Boot already ends open non-card tasks, so legacy keyless rows need no backfill.isAgentsTaskis the single matching rule. Set-status and auto tasks,endAgentTasks, edit-burst attribution, the guidelines nudge, the resident status lookup and Live Activity runs all use it, and so do the editor's fly-tos:taskFrameId,locatePresenceandGhostFrames(stream actors now keep their key).OWNER_FIRST_MS(a minute, the presence lifetime) for that agent before any agent may take it.get_feedbackand delivered feedback say whose work it is: "your", "another Claude's" or "Ben's".Why not the MCP session
The first version also put an
Mcp-Session-Id(minted oninitialize) into the key, to separate one person's two sessions. PostHog'scustom_agent_connected(one event perinitialize, last 30 days) shows that would split agents apart:codex-mcp-clientand theopenai-mcpclients start a new session every 1–5s (median), about once per tool call.claude-codere-initializes in bursts (36% of gaps under a minute).So one person's two same-named agents stay one agent, a documented limit. No session id is issued.
Tests
tests/agentIdentity.test.ts: key properties; one agent's status or disconnect leaves the other's tasks open; an outside "Doop" leaves the resident role alone; feedback goes to its own agent first, then to anyone after the minute.tests/agentIdentityHttp.test.ts: real server and SDK client. Two accounts' "Claude" get two presences and two open tasks; one account's two connections are one agent;get_feedbacknames whose work it is.tests/locate.test.ts: with two Claudes, each face and each task goes to its own agent's frame.Full local suite passes except
serverListen.test.ts, which fails the same way on a cleanHEADon this Mac (IPv6 listen timeouts).🤖 Generated with Claude Code