The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(chat): keep a delegation report's [n] markers off the parent's sources
M3gA-Minddd0c71c8f66e
diff --git a/app/src/components/assistant-ui/markdown-text.tsx b/app/src/components/assistant-ui/markdown-text.tsxindex 3adf061faa..d629592890 100644--- a/app/src/components/assistant-ui/markdown-text.tsx+++ b/app/src/components/assistant-ui/markdown-text.tsx@@ -98,7 +98,14 @@ function transformAssistantUrl(url: string): string {return classifyHref(url) === 'workspace' ? '' : transformChatUrl(url);}-const MarkdownTextImpl = () => {+const NO_CITATIONS: readonly CitationSource[] = [];++/**+ * `citations={false}` renders text that is not this message's own answer (a+ * sub-agent's report shown on its delegation card): its `[n]` markers refer to+ * sources the enclosing message does not have, so they stay plain text.+ */+const MarkdownTextImpl = ({ citations = true }: { citations?: boolean }) => {// Math is GATED, not always-on, and the gate is `hasLatexContent` rather than// "contains a $". `remark-math` would otherwise read "$10 vs $20" as an inline// formula and eat the prose between them; the signature requires a real LaTeX@@ -129,7 +136,8 @@ const MarkdownTextImpl = () => {return EMPTY_MESSAGE_PARTS;}});- const sources = useMemo(() => sourcePartsToCitations(parts), [parts]);+ const messageSources = useMemo(() => sourcePartsToCitations(parts), [parts]);+ const sources = citations ? messageSources : NO_CITATIONS;const preprocess = (input: string): string => {const withCitations = linkifyCitationMarkers(input, sources.length);diff --git a/app/src/features/conversations/aui/SubagentTaskCard.test.tsx b/app/src/features/conversations/aui/SubagentTaskCard.test.tsxindex 7457ccc84e..5de0c16d45 100644--- a/app/src/features/conversations/aui/SubagentTaskCard.test.tsx+++ b/app/src/features/conversations/aui/SubagentTaskCard.test.tsx@@ -11,9 +11,13 @@ vi.mock('../../../components/assistant-ui/elements/task-card.aui', () => ({}));const append = vi.hoisted(() => vi.fn());+// The enclosing (parent) message's parts, as `MarkdownText` reads them.+const parentParts = vi.hoisted(() => ({ value: [] as unknown[] }));vi.mock('@assistant-ui/react', async importActual => ({...(await importActual<typeof import('@assistant-ui/react')>()),useAui: () => ({ thread: { append } }),+ useAuiState: (selector: (state: unknown) => unknown) =>+ selector({ message: { parts: parentParts.value } }),}));const dispatch = vi.hoisted(() => vi.fn());@@ -182,6 +186,41 @@ describe('SubagentTaskCard', () => {expect(await screen.findByTestId('subagent-report')).toBeInTheDocument();});+ it("leaves the report's [n] markers as text, not the parent turn's citations", async () => {+ parentParts.value = [+ { type: 'source', sourceType: 'url', id: 's1', url: 'https://parent.example/a' },+ ];+ try {+ render(+ <SubagentTaskCard+ type="tool-call"+ toolName="task"+ toolCallId="sub-citations"+ args={{} as never}+ argsText="{}"+ result={+ {+ status: 'complete',+ activity: { ...activity, status: 'success', output: 'Checked the docs [1].' },+ } as never+ }+ status={{ type: 'complete' }}+ addResult={() => {}}+ resume={() => {}}+ respondToApproval={async () => {}}+ />+ );+ fireEvent.click(screen.getByRole('button', { name: /Delegated to Researcher/i }));++ const report = await screen.findByTestId('subagent-report');+ await waitFor(() => expect(report.textContent).toContain('Checked the docs [1].'));+ expect(within(report).queryByRole('button')).toBeNull();+ expect(report.querySelector('a')).toBeNull();+ } finally {+ parentParts.value = [];+ }+ });+it('renders the awaiting-user reply box and lets the answer through the composer path', async () => {render(<SubagentTaskCarddiff --git a/app/src/features/conversations/aui/SubagentTaskCard.tsx b/app/src/features/conversations/aui/SubagentTaskCard.tsxindex e3136a74b5..0e658a3448 100644--- a/app/src/features/conversations/aui/SubagentTaskCard.tsx+++ b/app/src/features/conversations/aui/SubagentTaskCard.tsx@@ -253,7 +253,8 @@ export const SubagentTaskCard: ToolCallMessagePartComponent = ({// A failure's output stays on the card. A finished report goes inside the// disclosure instead, rendered as markdown with the chat's own renderer:// the parent's reply presents the same result, so the card stays a header- // row until the user expands it.+ // row until the user expands it. Its `[n]` markers are the child's, not+ // the parent turn's sources, so citation linking is off.const resultNode =resolved.output && state === 'failed' ? (<p className="m-0 whitespace-pre-wrap">{resolved.output}</p>@@ -262,7 +263,7 @@ export const SubagentTaskCard: ToolCallMessagePartComponent = ({resolved.output && state === 'done' ? (<div data-testid="subagent-report" className="text-sm"><TextMessagePartProvider text={resolved.output} isRunning={false}>- <MarkdownText />+ <MarkdownText citations={false} /></TextMessagePartProvider></div>) : null;