feat(chat): add @agent mentions with open_in_agent tool#3093
feat(chat): add @agent mentions with open_in_agent tool#3093viktormarinho merged 7 commits intomainfrom
Conversation
🧪 BenchmarkShould we run the Virtual MCP strategy benchmark for this PR? React with 👍 to run the benchmark.
Benchmark will run on the next push after you react. |
Release OptionsSuggested: Minor ( React with an emoji to override the release type:
Current version:
|
There was a problem hiding this comment.
4 issues found across 20 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/mesh/src/api/routes/decopilot/built-in-tools/open-in-agent.ts">
<violation number="1" location="apps/mesh/src/api/routes/decopilot/built-in-tools/open-in-agent.ts:61">
P2: `idempotentHint` is incorrectly set to `true` for a state-creating tool; retries can create duplicate tasks.</violation>
<violation number="2" location="apps/mesh/src/api/routes/decopilot/built-in-tools/open-in-agent.ts:221">
P1: `mcpClient` is not closed on error paths; move cleanup to a `finally` so the connection is always released.</violation>
</file>
<file name="apps/mesh/src/web/components/chat/derive-parts.ts">
<violation number="1" location="apps/mesh/src/web/components/chat/derive-parts.ts:294">
P3: `extractAgentMentions` is introduced but not used anywhere in the repository, adding dead code to maintain.</violation>
</file>
<file name="apps/mesh/src/web/components/chat/message/parts/tool-call-part/open-in-agent.tsx">
<violation number="1" location="apps/mesh/src/web/components/chat/message/parts/tool-call-part/open-in-agent.tsx:44">
P2: Remove the client-side debug `console.log` that prints tool output; it can leak task data in production browser consoles.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
apps/mesh/src/api/routes/decopilot/built-in-tools/open-in-agent.ts
Outdated
Show resolved
Hide resolved
apps/mesh/src/api/routes/decopilot/built-in-tools/open-in-agent.ts
Outdated
Show resolved
Hide resolved
apps/mesh/src/web/components/chat/message/parts/tool-call-part/open-in-agent.tsx
Outdated
Show resolved
Hide resolved
Adds agent mentions to the chat input (`@` trigger) that delegate work to other agents via a new `open_in_agent` built-in tool. Also unifies prompts and resources under a single `/` trigger. - `@` trigger shows agent dropdown with icons (via AgentAvatar) - `/` trigger shows unified prompts + resources dropdown - New `open_in_agent` server-side tool: validates agent, creates thread, saves user message, runs agent in background - Custom tool call renderer with clickable navigation card - Agent mention nodes styled in violet, slash mentions in amber Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ now shows "Agents" and "Resources" categories first. Selecting a category drills into the items list. Also fixes toolsFromMCP destructuring in open_in_agent background runner. - New AtMention component with category → items drill-in navigation - useSuggestion supports onSelect returning false to keep menu open - @ resources use readResource and insert as mention nodes - derive-parts handles both agent and resource @ mentions - Removed old mention-agents.tsx (replaced by mention-at.tsx) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Reset mode to "categories" when @ menu closes (onOpenChange callback) - Add ↵ kbd badge on drillable category items - Add onOpenChange prop to Suggestion/useMentionState Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
946766a to
1147b4c
Compare
When at the top-level category view, typing now searches across both agents and resources simultaneously instead of just filtering the two category names. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each call creates a new thread and fires a background agent run, so retries would produce duplicates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Backend tool now only validates the agent and creates an empty thread. The frontend component starts the agent run via the standard decopilot/stream endpoint on render, with idempotency via a module-level Set (re-renders) and sessionStorage (page refreshes). This removes the bespoke runAgentInBackground server-side logic and lets the existing stream infrastructure handle the agent run. Also moves open_in_agent outside the provider gate so it works with Claude Code agents too. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/mesh/src/api/routes/decopilot/built-in-tools/open-in-agent.ts">
<violation number="1" location="apps/mesh/src/api/routes/decopilot/built-in-tools/open-in-agent.ts:63">
P2: The tool still requires `context` but execute ignores it and creates an empty thread. That drops the supplied context, so the delegated agent can start without the intended task details. Either persist the context to the thread or remove/relax the `context` field and update the description to match.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| description, | ||
| inputSchema: zodSchema(OpenInAgentInputSchema), | ||
| needsApproval, | ||
| execute: async ({ agent_id }, options) => { |
There was a problem hiding this comment.
P2: The tool still requires context but execute ignores it and creates an empty thread. That drops the supplied context, so the delegated agent can start without the intended task details. Either persist the context to the thread or remove/relax the context field and update the description to match.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mesh/src/api/routes/decopilot/built-in-tools/open-in-agent.ts, line 63:
<comment>The tool still requires `context` but execute ignores it and creates an empty thread. That drops the supplied context, so the delegated agent can start without the intended task details. Either persist the context to the thread or remove/relax the `context` field and update the description to match.</comment>
<file context>
@@ -67,16 +54,15 @@ export function createOpenInAgentTool(
inputSchema: zodSchema(OpenInAgentInputSchema),
needsApproval,
- execute: async ({ agent_id, context }, options) => {
+ execute: async ({ agent_id }, options) => {
const startTime = performance.now();
try {
</file context>
What is this contribution about?
Adds
@agentmentions to the chat input for cross-agent collaboration. Users can type@to see a dropdown of available agents, select one, and the AI will call the newopen_in_agentbuilt-in tool to create a task in the target agent and run it in the background. A clickable card renders in the assistant response to navigate to the agent's task.Also restructures mention triggers:
/now shows both prompts and resources in a unified dropdown, while@is dedicated to agents.Key changes:
@trigger: Agent mention dropdown with icons (AgentAvatar), violet-styled chips/trigger: Unified prompts + resources dropdown (replaces separatemention-prompts.tsxandmention-resources.tsx)open_in_agentbuilt-in tool (server-side): Validates agent, creates thread, saves user message, runs agent in background via fire-and-forgetOpenInAgentPartrenderer: Clickable card in assistant response that navigates to/$org/$agentId/?taskId=$taskIdallowprop toSuggestioncomponent for trigger customizationScreenshots/Demonstration
How to Test
bun run dev@— agent dropdown should appear with iconsopen_in_agenttool — a card with the agent icon appears/— should show both prompts and resources in one dropdownReview Checklist
Summary by cubic
Adds
@agentmentions to delegate work across agents via the newopen_in_agenttool, and rebuilds@into a two‑level menu (Agents, Resources) with top‑level search./is unified for prompts + resources, and delegated tasks render as a clickable card that also starts the agent run on the frontend.New Features
@trigger: two-level menu with icons and ↵ hint; typing at top level searches agents and resources; selecting an agent inserts a violet chip and delegates viaopen_in_agent; selecting a resource inserts it inline.open_in_agenttool: validates the agent, creates an empty thread, returnstask_id; marked non‑idempotent to avoid duplicate threads on retries.OpenInAgentPartrenders a card that starts the agent run viadecopilot/stream(idempotent via a module Set +sessionStorage) and navigates to/$org/$agentId/?taskId=$taskId; collapses 3+ tool calls into one expandable row./trigger: unified dropdown for prompts and resources; keeps the prompt-args dialog.Refactors
userId;open_in_agentis outside the provider gate (works with Claude Code) and excluded from subagent tool sets.SuggestionsupportsallowandonOpenChange;derive-partsdistinguishes agent vs resource@mentions and inserts clear hints foropen_in_agentcalls.extractAgentMentionsexport to satisfy knip.Written for commit 4b78d33. Summary will update on new commits.