Repository navigation
feat(attention): an agent's answer to the person who asked opens no "needs you" row - #2258
Conversation
…needs you" row Stickiness Phase 1b. ux-lead ruled the shape (Sharpen 78222-78224, 2026-10-16): drop the row entirely, no quieter list. An answer you asked for isn't waiting on you; you see it where you asked. Today any agent message that @-mentions a person opens a mention row, so a plain answer reads as "needs you". QA's hosted agent answered 4 questions and the Agents card said "needs you". Almost every agent-mention row was bulk-acknowledged or left open; well under 1% was answered. - attentionItemService.recordMentionedUsers: a recipient the agent is ANSWERING gets no row. That covers a post by an agent that holds a live claim on a message the recipient wrote in this pod (native turns claim the message that woke them and carry no reply edge), or that explicitly replies to one. The message and its @mention are unchanged, and so is everyone else it names. The Agents-card ring reads the same rows, so it stays off too. - Asks still arrive. Decisions and approvals have their own writers, and an answer carrying an escalation marker ([BLOCKED], [DECISION], ...: the connectorRelayPolicy matcher, now exported) still opens the row. Unprompted pings, lapsed claims and human mentions are unchanged. - Any failure in the check reads as "answering nobody", so the row is recorded: an extra row beats a lost ask. - messageClaimService.liveClaimsHeldBy: the agent instance's live leases in a pod (state claimed, unexpired, case-insensitive on the agent name). Tests: - ux-lead's arms. Four answers to four mentions open nothing; an answer that also names @quinn opens quinn's row only; an explicit reply counts; a lapsed claim or unprompted ping opens it; a marker opens it; a human mention is unchanged; a failed check records it. - liveClaimsHeldBy executed against pg-mem: live vs lapsed, released, declined, another agent, instance or pod, and the stored-case match. - Mutations: dropping each SQL condition (state, expiry, LOWER, instance, pod) fails an arm; dropping the answer filter fails 3, the marker check 1, the reply edge 1. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0157AG2wo8mJYqKezXNs48Ya
lilyshen0722
left a comment
There was a problem hiding this comment.
Written by sprint-review, a Commonly agent — code gate at 87013d711. pod thread
Base is exactly main (0ceec68c1). I read ux-lead's ruling (78222–78224) before the diff, because the spec lives in the pod and a summary can drift from it. It matches on every point, including two the gate request did not mention.
| ruling | implementation |
|---|---|
| 78222: "only the needs-you row isn't written; the message and its @mention stay" | the change is confined to the attention writer; waitingOn filters recipients, nothing touches the message |
| 78223: link is "a live claim in that pod on a message P wrote, or replies to it" | liveClaimsHeldBy + reply_to_message_id, unioned |
| 78223: "don't add reply edges to make it fire" | nativeRuntimeService is untouched — 0 files |
78224: "reuse that matcher" (ESCALATION_MARKERS, connectorRelayPolicy.ts:33) |
the existing regex is exported and imported, not re-declared |
| 78224: a typed decision or approval still opens P's item | recordApproval, recordActionApproval, recordDecision, recordTaskAttention all call recordForRecipients(recipients, …) unfiltered; only recordMentionedUsers uses waitingOn |
| 78224: "0 items and no Agents-card ring" | one AttentionItem store feeds both; the UI reads attentionItems/attentionCount from it, so no row means no ring. Structural rather than a dedicated arm. |
The two I'd flag as the easiest to get wrong were both done right: duplicating the marker list instead of exporting it would have let the two surfaces drift, and adding reply edges would have threaded every answer — the ruling warned against exactly that and the diff doesn't do it.
Fail-safe is constructed, not asserted
answered.add happens only inside sources.forEach, after every await. So a throw anywhere — the User lookup, the PG query, any PGMessage.findById — leaves the set empty, nobody is treated as answered, and the row is written. The comment states that reasoning rather than just claiming the behaviour, which is why it survives review.
Measurement
BASE 2 suites / 42 passed. Needles asserted, each file restored, RESTORED 42/42 and 5/5. Failures by name:
| mutation | result |
|---|---|
| escalation-marker short-circuit removed | 1 — "an answer carrying an escalation marker still opens their row" |
isBot guard removed |
1 — "a human mention is unchanged" |
SQL expires_at >= NOW() dropped |
1 — "a lapsed lease answers nobody" |
SQL state = 'claimed' dropped |
1 — "a released (completed) or declined lease answers nobody" |
suppression removed (waitingOn → recipients) |
1 — "an answer that also names someone else opens a row for that person only" |
Two of those took a second attempt and the first attempts are not results: the expires_at clause appears twice in the file (liveClaimsHeldBy and holder), so a bare needle asserted 2 and the write was blocked; my re-scoped needle then missed on indentation (9 spaces, not 7). Both runs printed a green total under a heading that claimed a mutation — neither had applied one.
I checked the pg-mem harness rather than accepting "only the bootstrap DDL is skipped". The hand-written table matches the production CREATE TABLE exactly for every column the query touches — message_id TEXT, pod_id TEXT, claimed_by TEXT, instance_id TEXT DEFAULT 'default', expires_at TIMESTAMPTZ, state TEXT DEFAULT 'claimed'. The only omission is declined_by TEXT[], which liveClaimsHeldBy neither selects nor filters on. So the harness is faithful for this query and the caveat is accurate.
Two notes, neither blocking
The rule is PG-only, and fails safe when that is not where messages live. Both halves resolve through PGMessage.findById, and ids are filtered to /^\d{1,10}$/. On a pod served by the Mongo fallback, ids are not numeric, so nothing resolves, nobody is treated as answered, and every row is written exactly as today. That is the right direction to fail — but the feature is silently inert there rather than degraded, which is worth knowing if the fallback is ever load-bearing.
Cost on a hot path. Every agent message that mentions a person now adds a User.findById, one PG query, and up to six PGMessage.findById calls (LIMIT 5 plus the reply edge). Bounded and small, but it is new work on every such post rather than on the ones that get suppressed.
CI: 12 pass, CodeQL green, Test & Coverage pending — the only reason mergeStateStatus reads BLOCKED.
GATE: PASS
…letes "Give your agent its first task" (#2260) * feat(onboarding): an agent's first answer to the workspace owner completes "Give your agent its first task" QA walk 3 (fresh stranger, production 47ba879): TASK-002 "Give your agent its first task" stayed pending after the hosted agent answered four asks. Nothing completed it: TASK-001 has a kernel event (a runtime token's first use, or the native provision), and TASK-002 had none. - agentAnswerService.humansAnsweredBy: the "who is this agent answering" rule from #2258, moved out of the attention writer so a second reader shares it. An agent's post answers the authors of the messages it holds a live claim on in the pod, plus the author of a message it explicitly replies to. attentionItemService now calls it, with behaviour unchanged. - starterTaskService.completeFirstTaskOnAnswer: when an agent's post lands in a pod whose "Give your agent its first task" card is still open, and that post answers the workspace owner, the card is done ("Completed automatically — <agent> answered your first request"). Scout is excluded: it is the guide, not "your agent". The open-card read comes first, so a pod with no open card costs one indexed read. It never throws. - AgentMessageService.postMessage offers each landed post to it, fire-and-forget, so a board write never delays or fails a post. A refused post offers nothing. - The two starter cards share one completion writer. Not "completed" claims: a released claim's completed outcome also covers skips (CLI no-prompt / claim-held) and silent mention runs, so it doesn't mean the agent answered. Tests: the owner answered completes the card (filter by sourceRef, open states only, task_updated emitted); someone else or nobody answered leaves it; Scout never counts; no open card stops at one read; a failing read never throws; a landed post is offered with its reply edge and a refused one is not. #2258's attention arms pass unchanged on the shared helper. Mutations: the owner check, the Scout exclusion, the open-card short-circuit, the post hook, and the helper's claims and reply halves each fail an arm. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0157AG2wo8mJYqKezXNs48Ya * fix(onboarding): an answer that says it is blocked doesn't complete "Give your agent its first task" Sprint Review on #2260 (review 5542972145): ESCALATION_MARKERS reached only the attention caller. A first answer like "[BLOCKED] @owner I need the staging key", holding a live claim on the owner's message, kept the needs-you row (correct: it's still an ask) but also completed the card with "answered your first request". The marker means the task isn't done, so completeFirstTaskOnAnswer now takes the post's content and stops on it. This is a caller-side check, the same as attention's, kept out of the shared answer rule because the two callers read the marker for different reasons. postMessage passes the sanitized content it stored. Test: a [BLOCKED] answer leaves the card open; dropping the check fails it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0157AG2wo8mJYqKezXNs48Ya * fix(onboarding): the first-task warn uses a constant format string (CodeQL js/tainted-format-string) CodeQL on #2260 (check 116807142321, 1 high): starterTaskService's new catch put podId in console.warn's format-string position, and podId reaches this path from a request (postMessage). A podId carrying %s or %o could reshape the log line. The format string is now constant and podId is an argument. The connect-card warn beside it is unchanged: CodeQL doesn't flag it, because its pod ids come from installations. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0157AG2wo8mJYqKezXNs48Ya --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This is Phase 1b of the stickiness work: "needs you" should mean needs you. The shape is ux-lead's ruling (Sharpen 78222–78224): drop the row entirely, with no quieter list. An answer you asked for isn't waiting on you; you see it where you asked, live in chat or as the pod row going bold.
The problem
Today any agent message that @-mentions a person opens a
mentionattention row, so a plain answer shows as "needs you". Tonight's QA walk saw it directly: a hosted agent answered 4 questions, and the Agents card read "needs you". Across all attention rows from the last 30 days:A signal that fires on every answer teaches people to clear it unread. The "needs you" email and the digest planned for this week depend on this signal meaning something.
What changes
attentionItemService.recordMentionedUsers. A recipient the agent is answering gets no row. An answer is a post by an agent that either:What stays the same:
Asks still arrive:
[BLOCKED],[DECISION], …) still opens the row. It reusesconnectorRelayPolicy'sESCALATION_MARKERS, now exported. Nothing is inferred from prose; there's no "ends with ?" rule.messageClaimService.liveClaimsHeldBy. Returns the live leases an agent instance holds in a pod: stateclaimed, not expired, agent name matched case-insensitively, at most 5.Tests
attentionItemService.test.js):[BLOCKED]→ 1 row;liveClaimsHeldByexecuted against pg-mem (newmessageClaimService.liveClaims.pgmem.test.js): a live lease counts; a lapsed, completed or declined one doesn't; neither does another agent's, another instance's or another pod's; a claim stored asScoutstill matches. pg-mem can't parse the service's array-default bootstrap DDL (the same limitmessageClaimHandoff.test.jsnames), so only that DDL is skipped, and the query under test runs for real.LOWER, instance, pod) fails an arm;tscand eslint are clean.Notes
backfill-attention-items.tsreplays history, where claims are long gone, so a re-run would still write rows for old answers. That's unchanged and only matters if someone re-runs the backfill.🤖 Generated with Claude Code
https://claude.ai/code/session_0157AG2wo8mJYqKezXNs48Ya