Repository navigation
feat(lead): Give the Lead its own prompt, tools, and startConversation - #3737
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
I wonder if the lead here even needs a sandbox. If sandboxes could be on demand and only exist if you're executing tools that need them, and the lead was really about coordination, it seems like it doesn't really need the sandbox, right? |
|
Though I guess that's really just an optimization. We can solve that problem at a later time. I think the main thing is just that the core system prompt for the lead needs to be probably much tighter, and it should obviously include some of the customization, like soul and whatnot. But it's not really about doing all the other stuff. It should really be focusing on only the coordination tasks. |
8a5f452 to
02d621c
Compare
|
Agreed on both points. Sandbox: the Lead already has no sandbox-backed tools. Its allowlist drops bash, skills, MCP, web, and provider tools. Making the sandbox start only when a tool needs one would be a general runtime change, so I left it for later. Prompt: tightened in 6a7e8b616. The static Lead prompt went from about 8.4k to 6.3k characters.
The |
|
I think allowing it to have access to the tools we have right now is probably totally fine. I'm not sure what you mean by "it's not in the visible transcript." Shouldn't it be a tool call, and then we record it in the event log like we would for a sub-agent, even if this isn't a sub-agent? It's a similar concept that needs its own event. If that guardian change is relevant, yeah, guardian eval is totally fine. |
431cd70 to
ec6423e
Compare
|
All right, just so we're clear, here are the expectations of how this works:
|
Co-Authored-By: David Cramer <[email protected]>
Action review asked for confirmation when a person asked their Lead for work. Its reason: "Starting a new public conversation to delegate the draft is an unrequested write; the user asked for the changelog entry, not a separate conversation." The person's words reached review, but the tool description did not say that a Lead does no work itself. So a start looked like a separate write instead of the way the request is done. The description now says that the Lead carries out each request of the person by starting a conversation for it. Guardian snapshots cover both sides: a direct request to the Lead allows the start, and a start that the person did not ask for still asks. The Guardian eval tools now include the Lead's startConversation.
…eview Action review still asked on a direct request: "Starting a new public conversation to post the changelog is a write the user did not request." It read "public" as publishing the work. The proposal now says that the start posts nothing to Slack or any other outside place, who can read the conversation, and that its own tool calls get action review.
# Conflicts: # packages/junior/src/chat/conversations/search.ts # packages/junior/src/chat/tools/search-conversations.ts # policies/conversation-access.md
|
Looks like this one needs rebased. |
startConversation now uses approvalMode "auto", like spawnAgent and messageAgent. The new root runs as the person, and action review judges its own tool calls, the same way it judges a child agent's. This removes what only the review mode needed: the proposal description, the Guardian Lead snapshots, and the Lead tool in the Guardian eval tools. The tool description goes back to its earlier text. Co-Authored-By: David Cramer <[email protected]>
# Conflicts: # packages/junior/src/chat/agent-invocations/top-level-message.ts
|
Updated with a merge instead of a rebase, so no force-push was needed. Main (#3962) is merged into #3735 at 98a35c76c, and from there into this branch at 6186982d5. That merge resolved a conflict in |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6186982. Configure here.
A Lead is private and adds no Inbox items, so canAgentChangeInboxItem rejects every change it tries. Listing the tool only invites calls that fail.
Part of #3727. Stacked on #3737; the dashboard PR goes on top of this one. A person can ask their Lead to tell them when work is done or needs them. Today a Lead can only check by reading, and `watchEvents` checks no access: a stranger's Slack thread could watch a private web Conversation and receive its events. This adds a watch-only `conversation` resource with an access check. - **Resource:** `junior` / `conversation`, identifier = the ID of a top-level Conversation, `limits.conversation.automation = false`. Events (none terminal, so one Watch hears every Turn): - `conversation.completed`: `turn_completed`. A Turn that only the root's own Watch Events started reports nothing, so a watcher is not woken by each Event Turn. - `conversation.failed`: `turn_failed`. - `conversation.waiting`: the Conversation opens an action Review item (`addReviewItem`, or a plugin notice that waits on its assignees). - `conversation.stopped`: `stoppedAt` is set (`markConversationsStopped`, so person and agent stops both report). The events hold status only. The watcher reads content with `readConversationEvent`, which checks access again. A failed delivery is logged and never fails the work it reports. A retry delivers the same event key once. - **Access:** creating a Watch on a `conversation` resource needs a top-level target and `canAccessConversation(requester, target)`. Not found, no access, and a child agent get the same error. Delivery checks again through a new `admit` option on `ingestEvent` and fails closed, because visibility can change. `policies/conversation-access.md` lists the surface. - **`startConversation`** returns a `subscribable` for the new root and creates no Watch. The `<lead>` rules say to watch only when the person asks to hear back. Any Conversation may watch a top-level Conversation that it can read, not only a Lead. - **Limits, unchanged, with no exemptions:** Event Turns still count toward the 25 consecutive automated Turns limit (`admitAutomatedTurn`), and a Watch still lasts at most 30 days (14 by default). <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A4b634c5fb1cd22800ab9701693ed89b9 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A4b634c5fb1cd22800ab9701693ed89b9) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A4b634c5fb1cd22800ab9701693ed89b9/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]> Co-authored-by: David Cramer <[email protected]>
Step 3 of #3727, stacked on #3745 (conversation Watches), which is stacked on #3737. Today a request from the dashboard home creates a root Conversation, and then nothing keeps track of that work for the person. The Lead is a person's private front door to Junior: it starts each piece of work as a Conversation, watches the ones the person asks about, and reports back in one place. #3737 and #3745 give the Lead that behavior. This PR makes the Lead the dashboard home, so people can use it, in the "Briefing" direction without the briefing strip. **Home is the Lead** - `GET /api/lead` gets or creates the viewer's Lead and returns its id and `watchedConversationIds`: the targets of the Lead's active `junior` `conversation` Watches. Messages use the existing `POST /api/conversations/:id/messages`. - In the classic shell, `/` opens the Lead on wide and narrow screens. The Conversation list column is hidden on home. The rail's Conversations icon opens it, and `/conversations` shows it. "New conversation" goes to `/` and focuses the Lead composer. - The Lead page has its own header (compass mark, "Your Lead", "Starts and tracks your work. Only you see this.") and no details panel. The transcript is centered at the reading width, with day separators. Lead replies use the compass avatar and the name "Lead". - The composer placeholder is "Ask your Lead to start, find, or check on work…". - An empty Lead shows a first-run intro: what the Lead does, three short boxes (Starts work, Keeps watch, Finds and steers), and three example prompts that fill the composer. - The old home create flow (`HomeSummary`, `NewConversationPending`, the visibility select) is removed from the classic shell. The inbox shell keeps its own copies. - Leads stay out of Conversation lists, feeds, and people lists (`notLeadConversation()` in SQL). **Started Conversation card** - The API projects a completed `startConversation` result into a typed `startedConversationId` from the tool's output schema, only for viewers who can see tool payloads. - The card shows a status tile and label (Needs you, Working, Failed, Done), the title, "Watching" when the target is in `watchedConversationIds`, the age, and the latest Brief summary. - Needs you comes only from open action Review items assigned to the viewer (`design/attention.md`). Such cards get "Open to approve" and "Message it". Failed cards get "Open" and "Message it". "Message it" puts a link to that Conversation in the Lead composer. **Watch reports** - A `conversation.*` Watch Event delivered to the Lead renders as one line: status icon, "<title> needs you / failed / finished / stopped", and the time. The API adds `eventIdentifier` to event meta for viewers who can see payloads, so the row can name the Conversation. **Eval** - `evals/agent/lead.eval.ts` (behavioral): a person asks their Lead, through the API route, for a short changelog entry that it could write in its own reply. It expects the Lead to call `startConversation` or `messageAgent`. **Screenshots** Artifact hosting fails right now, so the current mock-mode screenshots (Lead home, Watch reports, first run; desktop and mobile) are in the [Junior Thread](https://junior-prod.sentry.dev/conversations/agent%3A4b634c5fb1cd22800ab9701693ed89b9) until it is fixed. **Gaps** - No feature flag: the classic home changes for everyone. The inbox shell still has the old home. - The feed has no failed status. Failed is inferred: `needs_input` with no viewer Review item, no pending sign-in, and no answered or done Brief. - No briefing strip or counts yet. Needs you shows only on the cards. - Conversations that the Lead starts are always public. The private choice from the old home composer is gone. - The one-time push notification tip followed a home create, so the classic shell no longer shows it. - The home stats from the old home summary are gone in the classic shell. - Home loads the Lead id, then its page: one more serial round than before. A Lead id in the dashboard bootstrap would remove it. - The eval rubric only looks for a delegation tool call. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A4b634c5fb1cd22800ab9701693ed89b9 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A4b634c5fb1cd22800ab9701693ed89b9) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A4b634c5fb1cd22800ab9701693ed89b9/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]> Co-authored-by: David Cramer <[email protected]>
This audits `design/` against `main` at 47f31f809 and covers the commits since the 2026-11-21 audit. Those commits touch every system, so the audit checks all 12 files. It changes 9 files. **Intent change** - `guardian.md` Intent: a Conversation that a Lead starts treats the Lead's task as the request of the Lead's person. This is an exception to "agent text is never approval". It comes from @dcramer in the audit thread ("it's passing instruction on behalf of the user so yes it counts as approval"), and it matches #3737 (`packages/junior/src/chat/lead/start-conversation.ts:33-41`). **New gaps** - `sandbox-credentials.md` gets a new Gaps section. The GitHub plugin sets `toolsSendNoCredential` (`packages/junior-github/src/plugin.ts:256`), so any Sandbox request to GitHub that sends no credential gets one (`packages/junior/src/chat/sandbox/egress/credential-request.ts:111-118`). That includes the grants that act as the Actor (`packages/junior-github/src/egress-policy.ts:696,733,741-745`). This breaks "Other code in the Sandbox does not act as the Actor only because it calls a provider domain". - `github.md`: `GET /user` gets the `user-read` grant, which is the requester's account (`packages/junior-github/src/egress-policy.ts:80-89,731-734`). This breaks "acts as its own App … not by using their credentials". #3885 also edits this file, but it leaves these closing lines alone. - `attention.md`: when the automated-turn limit stops a Conversation, the notice is a plain Slack reply. It adds no Inbox item, and a Conversation outside Slack gets nothing (`packages/junior/src/chat/slack/automated-turn-limit-notice.ts:38-60`). **Corrections** - `automations.md`: the turn-limit gap now says the run's Conversation stops and posts a stop notice. #3962 removed the separate pause path. The count is per Conversation (`packages/junior/src/chat/services/automated-turn-limit.ts:1-5,114-122`). - `child-agents.md`: removes "a notice that a paused child dropped Watch Events". #3962 removed that notice ("no child-to-parent notice"). **Cuts** - `context-compaction.md`: a code symbol, and the worked price math that `cache-warming.md` owns. - `google.md`: the Slides image line restated the mechanism from #3845. It now states the user-facing limit: the image is public only during the edit (`packages/junior-google/src/slides/sandbox-images.ts`). - `inbox.md`: a repeated "Dismiss closes the item for everyone." <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent-dispatch%3Adispatch_3e578e6396ec3d616bf7c3338e07fa30 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent-dispatch%3Adispatch_3e578e6396ec3d616bf7c3338e07fa30) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent-dispatch%3Adispatch_3e578e6396ec3d616bf7c3338e07fa30/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>

Step 2 of #3727. Stacked on #3735. A Lead is one person's private Conversation that finds, starts, and steers their other Conversations. It must never do the work itself. This PR adds that behavior. The dashboard does not create a Lead yet. That comes in the next PR.
Behavior
getLeadConversation(user): gets or creates the person's private web Lead. It catches 23505 from the unique index and returns the row that the other request made.lead, with its own<lead>job rules (start or steer, never do the work inline) and only the tool rules that apply to it. This is a minimal first version, so iterate on the text.TurnBehavior.tools.onlyis a real allowlist in tool binding. A Lead lists onlystartConversation,messageAgent,searchConversations,searchConversationEvents,readConversationEvent,searchReviewItems,updateReviewItem,searchEventTypes, the watch tools,systemTime,updateUserCustomization, andnoReply. It gets no run-built, plugin, MCP (no restore either), Slack, or sandbox tools, and no skills. Automation tools stay out until a Lead can pick a Slack Destination.AgentToolsmodetop_level: messageAgent only. spawn/stop/archive/listAgents now need a child mode.Authority (
startConversation({ task, title }),approvalMode: "auto")${turnId}:${toolCallId}.taskis its first web message. The start is not reviewed, the same asspawnAgentandmessageAgent. Action review judges the new root's own tool calls, the same way it judges a child agent's. No new input kinds or stored fields.Access
requireTopLevelAgentAccess: a private Lead may message a public root where its person is a Participant. It is still denied for any other public root.searchConversationsgetsparticipating, which filters onjunior_conversation_participants.user_id. Ranking does not change.policies/conversation-access.md,policies/system-prompt.md, andTERMINOLOGY.mdare updated.Breaks nothing for existing kinds: only Lead Turns get the allowlist or the
top_levelmode.Open questions
codemodeandsearchTools/executeToolstay, because they reach only the allowed tools. Several allowed tools aredeferred. Keep them, or make those direct?via @dcramer.
--
View Session [Sentry]