fix(antigravity): give the follow-up after a swarm its result, and say each thing once in the thread (#22893)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - A task thread shows an agent's runs, and each new run starts from
the task's saved context
> - A second hands-on check of Google Antigravity `/swarm` runs (after
#22886) still found gaps
> - The first ordinary follow-up after a swarm was slow: it spent
minutes searching the instance's run logs to learn what the swarm did
> - The thread also showed each file twice, lost the "Swarm" note after
a reload, and read "Swarm Swarm started…"
> - This pull request gives the next run the swarm's result in its
opening context and removes the prompt's pointer to run records, and it
fixes the four thread problems
> - The benefit is a faster follow-up after a swarm and a thread that
says each thing once

## Linked Issues or Issue Description

Refs #22886

**What happened?**
1. After a finished `/swarm`, the ordinary follow-up "append three to
v1.txt" took 4 min 6 s (an earlier one took 5.5 min). The agent read the
server's raw run log of the swarm run with about 20 shell commands,
searched the instance folder, and listed processes. Other follow-ups
took 41 s and 105 s.
2. Each file showed twice: the run's file card, and a second card under
the final reply (from the reply's "Download: v1.txt" link). This also
happened on the ordinary follow-up.
3. The "Swarm" note on the user's message showed while live, but not
after a page reload.
4. Swarm activity rows read "Swarm Swarm started in the task folder…",
with the word twice.

**Expected behavior**
1. The follow-up starts with what the swarm did, so it has no reason to
search for it.
2. Each file shows once per run, as the run's file card.
3. The "Swarm" note shows after a reload.
4. A swarm row reads its sentence once.

**Steps to reproduce**
1. Send `/swarm Create v1.txt containing "one" and v2.txt containing
"two", one helper per file, then verify both.` to a Google Antigravity
agent.
2. When it finishes, look at the files and the activity rows, then
reload the page.
3. Send the ordinary follow-up `append three to v1.txt` and time it.
4. Put another task in Plan mode and send `/swarm do something`.

## What Changed

- Follow-up context (cause of item 1). A swarm runs in the Antigravity
CLI, and an ordinary turn runs on the registry route. The ordinary route
cannot reopen the swarm's conversation, so the Runner refuses the saved
session and the server starts a fresh one. That fresh session gets the
same wake prompt as any other turn. Before this change, its only record
of the swarm was the task continuation summary, and that summary listed
no files ("No file or route paths were detected"; the path detector only
knows repository folders such as `server/`). It also gave three run ids
and said "Detailed shell/tool commands remain in the run log and
transcript." The agent followed that line: its first searches matched
the swarm's run id, and an earlier follow-up searched for
`transcript*.jsonl` files. An ordinary follow-up after an ordinary turn
gets the same prompt, but it resumes its own conversation, so it already
knows what it did.
- `issue-continuation-summary.ts` (shared by every harness): a new
"Files Delivered" section lists, by name, the files the run handed in as
deliverables (applied or duplicate receipts), newest first, and keeps
earlier runs' names. These names are kept apart from "Files / Routes
Touched", because a deliverable's name is not always its path. The run's
own checks are listed, read through the shared accepted-result reader.
The summary contains no run ids, adapter names or log locations. The
"Commands Run" section is removed: it held only the run id and the log
pointer. The summary reaches the next turn through the existing
mechanism (the wake prompt's "Issue continuation summary" and the
continuation evidence).
- Server: `GET /issues/:id/recent-comments` and both chat bootstrap
routes now add the swarm marker with the same shared rule
(`withAntigravitySwarmMarkers`) as the comment list, the single comment
and the POST response. A cold task page reads this recent window, so the
marker was missing after a reload.
- UI: a reply does not show a second card for a file that its own run
already shows as a file card. The reply text and its links do not
change. A later run's reply that links the same file still shows the
file.
- UI: a swarm progress row shows its sentence without the "Swarm" label.
A failed or stopped row keeps its label and marker. Live and settled
rows use the same rule.

Not changed, by investigation:
- "Check passed cat v1.txt one\nthree" and "verifier check on swarm
board #6": the model wrote both strings in its `paperclip_finish` call.
The Runner's first record of the result already holds the literal
backslash and the board number, so this is model text, not Paperclip's
presentation.
- The inline "Download: v1.txt" links in the reply are the model's own
words, so they stay.
- No read-confinement policy is added. The agent finds the instance
folder from its working directory, not from the prompt.
- A refused send still shows its reason twice (inline under the composer
and as a toast). Each attempt to remove the toast missed a send path,
which could leave a refusal with no visible reason. A repeated reason is
better than a missing one, so this PR does not change the toast.

## Verification

- Red/green `server/src/__tests__/issue-continuation-summary.test.ts`: a
swarm's accepted result (from a live run, with ids replaced) is built
into the summary and rendered into the follow-up's wake prompt. The
prompt contains the hand-in summary, `v1.txt` and `v2.txt` under "Files
Delivered" (one with a different content reference and a duplicate
receipt), and the verifier check. A later run lists its own delivered
file first. A full path list still takes the latest run's path first. It
contains no run id, "run log", "transcript", attachment path, digest or
adapter name. A later run keeps the files listed. This failed before the
change.
- Red/green `server/src/__tests__/issue-chat-bootstrap-routes.test.ts`
(embedded Postgres): for an ordinary task and a conversation, a recorded
`/swarm` request carries `nativeCommand: "swarm"` on `GET /comments`,
`GET /comments/:id`, `GET /recent-comments`, `GET
/issues/:ref/chat-bootstrap` and the batch chat bootstrap. It failed on
`recent-comments` before the change.
- Red/green `ui/src/components/TaskChatThread.test.tsx`: a reply that
links its run's file shows no second card; a later run's reply still
shows it. It failed before the change.
- Red/green `ui/src/components/task-chat/antigravity-thread.test.tsx`:
the live swarm fixture's rows read "Swarm started in the task folder…"
(no doubled word), and live rows equal settled rows.
- Focused suites: UI `TaskChatThread.test.tsx` and
`src/components/task-chat` (925 tests), server bootstrap routes (19
tests) and continuation summary (7 tests) pass. UI and server typechecks
pass.
- Not proved without a live run: that the next follow-up after a swarm
is faster. The tests prove the opening input; the agent's behavior with
that input needs a live Antigravity run.

## Risks

- The continuation summary wording changes for every harness that runs
on a task (every adapter whose finished run refreshes the summary, not
only Antigravity): no run ids, no adapter name, no "Commands Run"
section, and a new "Files Delivered" section when the run registered
deliverables. Nothing in the code parses those lines. Older saved
summaries keep their text until the next run refreshes them.
- One extra indexed activity-log query for each recent-comments or
chat-bootstrap read (the same query the comment list already runs). The
bootstrap budget test still passes.
- The second-card rule matches only a file whose card belongs to the
same run as the reply.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, test runs).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DottaandClaude Opus 5.5 authored and GitHub committed 2026-11-25 02:50:44 -06:00
1 parent 3fbf872d9e
commit 5347c01de5
16 files changed
+234 -44

No files matched your search

@@ -0,0 +1,3 @@
import { createContext } from "react";
export const RunFileCardsContext = createContext<ReadonlyMap<string, string>>(new Map());
@@ -33,6 +33,7 @@ import {
AttachmentTrigger,
} from "@/components/ui/attachment";
import {
attachmentIdFromUrl,
extractAttachmentRefs,
extractImageRefs,
fileKindForAttachment,
@@ -44,6 +45,7 @@ import {
} from "./task-chat-attachments";
import { TaskChatBubbleActions } from "./TaskChatBubbleActions";
import { TaskChatSystemNotice } from "./TaskChatSystemNotice";
import { RunFileCardsContext } from "./RunFileCardsContext";
import type { TaskChatMessageItem } from "./task-chat-model";
import { safeNavigableUrl } from "@/lib/safe-url";
@@ -171,6 +173,7 @@ function TaskChatBubbleContent({
? <CoordinatorRelativeTime value={recordedTimestamp} /> : item.timestamp;
const { enabled: artifactsV1 } = useArtifactsV1Enabled();
const openText = useContext(TextAttachmentContext);
const runFileCards = useContext(RunFileCardsContext);
// Task attachments share the page gallery; standalone images retain the bubble viewer.
const openIssueGallery = useContext(IssueGalleryContext);
const [lightboxSrc, setLightboxSrc] = useState<string | null>(null);
@@ -239,15 +242,19 @@ function TaskChatBubbleContent({
openPath: attachment.openPath,
downloadPath: attachment.downloadPath,
}));
const notRunFileCard = (ref: AttachmentRef) => {
const id = ref.id ?? attachmentIdFromUrl(ref.url);
return !(item.author === "agent" && item.sourceRunId && id && runFileCards.get(id) === item.sourceRunId);
};
const imageRefs = uniqueAttachmentRefs([
...hydratedEmbeddedRefs,
...hydratedLinkedRefs.filter(isImageAttachment),
...boundAttachmentRefs.filter(isImageAttachment),
]);
]).filter(notRunFileCard);
const attachmentRefs = uniqueAttachmentRefs([
...hydratedLinkedRefs.filter((ref) => !isImageAttachment(ref)),
...boundAttachmentRefs.filter((ref) => !isImageAttachment(ref)),
]);
]).filter(notRunFileCard);
const mediaRefs = [...imageRefs, ...attachmentRefs.filter((ref) => isVideoLikeOutput(ref.contentType, ref.name))];
const galleryItems: GalleryMediaItem[] =
lightboxSrc !== null && !mediaRefs.some((ref) => ref.url === lightboxSrc)
@@ -31,7 +31,7 @@ import {
import { TaskChatUsageReadout } from "./TaskChatUsageReadout";
import { TaskChatReasoningSummary } from "./TaskChatReasoningSummary";
import { latestReasoningHeadline } from "./reasoning-summary";
import { retriedLabel, SUBJECT_FAMILIES, subjectRowLabel, toolActivityPresentation, type ToolIcon } from "./tool-taxonomy";
import { retriedLabel, sentenceRowLabel, SUBJECT_FAMILIES, subjectRowLabel, toolActivityPresentation, type ToolIcon } from "./tool-taxonomy";
import { useTaskChatShimmer } from "./TaskChatShimmer";
import { TaskChatDiffCounts, TaskChatDiffView } from "./TaskChatDiffView";
import { useTaskReferenceLabel, withTaskReference } from "./task-reference";
@@ -124,9 +124,11 @@ function presentation(item: Activity, active: boolean, taskLabel?: string): Acti
// A finished command needs no verb at all: the icon and "$" say it ran.
// A failure or stop keeps its marker ("Read · failed") unless an exit
// chip already says how a command ended. Live rows use the same helper.
const verb = subject && SUBJECT_FAMILIES.has(tool.family)
? subjectRowLabel(label, terminal && !running && (item.status === "completed" || item.exitCode != null))
: label;
const verb = subject && tool.sentenceSubject
? sentenceRowLabel(label)
: subject && SUBJECT_FAMILIES.has(tool.family)
? subjectRowLabel(label, terminal && !running && (item.status === "completed" || item.exitCode != null))
: label;
// Exit 0 is only news for commands; for reads and searches it is noise.
const exitCode = item.exitCode ?? null;
const shownExit = exitCode === 0 && !terminal ? null : exitCode;
@@ -64,27 +64,27 @@ describe("an Antigravity swarm run's task thread", () => {
it("reads in plain language after the run", () => {
expect(settled()).toEqual([
"Swarm Swarm started in the task folder with Gemini 3.8 Flash (Low) on Google's default channel (Antigravity CLI 1.5.15). Helper changes inside the task folder are approved automatically; anything else is blocked.",
"Swarm This swarm runs on the Google account of this agent's Google connection.",
"Swarm Goal: Create and verify u1.txt and u2.txt",
"Swarm Started helper writer1: Create a file named u1.txt in the current workspace directory containing exactly \"one\"",
"Swarm Started helper writer2: Create a file named u2.txt in the current workspace directory containing exactly \"two\"",
"Swarm Started helper verifier: You are the verifier",
"Swarm Started a helper that watches for stalls",
"Swarm Checked on the helpers",
"Swarm Checked on the helpers",
"Swarm started in the task folder with Gemini 3.8 Flash (Low) on Google's default channel (Antigravity CLI 1.5.15). Helper changes inside the task folder are approved automatically; anything else is blocked.",
"This swarm runs on the Google account of this agent's Google connection.",
"Goal: Create and verify u1.txt and u2.txt",
"Started helper writer1: Create a file named u1.txt in the current workspace directory containing exactly \"one\"",
"Started helper writer2: Create a file named u2.txt in the current workspace directory containing exactly \"two\"",
"Started helper verifier: You are the verifier",
"Started a helper that watches for stalls",
"Checked on the helpers",
"Checked on the helpers",
// The CLI's first reads used a relative path and were refused; the same reads then succeeded.
"Read · retried u1.txt",
"Read · retried u2.txt",
"Read u1.txt",
"Read u2.txt",
"Swarm Coordinator: All files u1.txt and u2.txt created and verified successfully",
"Coordinator: All files u1.txt and u2.txt created and verified successfully",
"$ shasum -a 256 u1.txt u2.txt; wc -c u1.txt u2.txt",
// One row per file, with the file's name, never the bridge's arguments or a digest.
"Attached u1.txt",
"Attached u2.txt",
"Swarm Files changed in the task folder: u1.txt, u2.txt",
"Swarm Token usage is the coordinator's total and includes the helpers; Google does not report it per helper",
"Files changed in the task folder: u1.txt, u2.txt",
"Token usage is the coordinator's total and includes the helpers; Google does not report it per helper",
]);
});
@@ -69,3 +69,12 @@ export function groupImageResources<T extends TaskChatItem>(items: readonly T[])
}
return rows;
}
export function runFileCardAttachments(products: readonly IssueWorkProduct[]): ReadonlyMap<string, string> {
const byAttachment = new Map<string, string>();
for (const product of products) {
const attachmentId = fileRowSourceFromWorkProduct(product)?.attachmentId;
if (attachmentId && product.createdByRunId) byAttachment.set(attachmentId, product.createdByRunId);
}
return byAttachment;
}
@@ -30,6 +30,7 @@ import {
humanizeToolName,
isGenericToolName,
retriedLabel,
sentenceRowLabel,
SUBJECT_FAMILIES,
subjectRowLabel,
toolActivityPresentation,
@@ -140,6 +141,16 @@ export function providerActivityPresentation(item: TaskChatProviderActivityItem)
// "$ npm test" (TaskChatRunnerActivityGroup's tool rows).
// Settled rows classify by the name alone (TaskChatRunnerActivityGroup).
const settled = toolActivityPresentation({ name, target });
if (settled.sentenceSubject && subject && boundedActivity === subject) {
return {
icon: settled.icon,
runningLabel: sentenceRowLabel(settled.runningLabel),
completedLabel: sentenceRowLabel(settled.completedLabel),
failedLabel: sentenceRowLabel(settled.failedLabel),
interruptedLabel: sentenceRowLabel(settled.interruptedLabel),
detail: [subject, source].filter(Boolean).join(" · "),
};
}
const concrete = Boolean(boundedActivity && (boundedActivity === subject || boundedActivity === meaningfulToolDetail(target)))
&& SUBJECT_FAMILIES.has(settled.family);
if (concrete) {
@@ -157,7 +157,7 @@ export interface AttachmentRef {
downloadPath?: string;
}
function attachmentIdFromUrl(url: string): string | null {
export function attachmentIdFromUrl(url: string): string | null {
return /\/api\/(?:attachments|assets)\/([^/?]+)\/content/.exec(url)?.[1] ?? null;
}
+9 -2
View File
@@ -79,6 +79,7 @@ export interface ToolActivityPresentation {
technicalName?: string;
confidence: ToolClassificationConfidence;
summaryGroup: ToolSummaryGroup;
sentenceSubject?: boolean;
}
/** Families whose rows read as "<verb> <subject>", for example "Read README.md". */
@@ -95,6 +96,10 @@ export function subjectRowLabel(label: string, settledCommand: boolean): string
return `${action!.split(" ")[0]}${marker ? ` · ${marker}` : ""}`;
}
export function sentenceRowLabel(label: string): string {
return label.includes(" · ") ? label : "";
}
/** "Read · failed" → "Read · retried", for a failure a later call of the same tool recovered. */
export function retriedLabel(failedLabel: string): string {
return failedLabel.replace(/ · failed$/, " · retried");
@@ -167,9 +172,10 @@ interface ExactAction {
completed?: string;
group?: ToolSummaryGroup;
family?: ToolFamily;
sentence?: boolean;
}
const group = (key: string, singular: string, plural: string): ToolSummaryGroup => ({ key, singular, plural });
const group =(key: string, singular: string, plural: string): ToolSummaryGroup => ({ key, singular, plural });
const EXACT_ACTIONS: Record<string, ExactAction> = {
bash: { action: "run" },
@@ -227,7 +233,7 @@ const EXACT_ACTIONS: Record<string, ExactAction> = {
// With the file as its subject the row reads "Attached u1.txt".
register_deliverable: { action: "create", running: "Attaching a file", completed: "Attached a file" },
// Antigravity's swarm progress lines; the subject is the whole plain sentence.
swarm_update: { action: "other", running: "Swarm", completed: "Swarm", family: "agent", group: group("swarm_update", "swarm update", "swarm updates") },
swarm_update: { action: "other", running: "Swarm", completed: "Swarm", family: "agent", sentence: true, group: group("swarm_update", "swarm update", "swarm updates") },
finish_task: { action: "finish", running: "Reporting completion", completed: "Reported completion" },
paperclip_finish: { action: "finish", running: "Reporting completion", completed: "Reported completion" },
block_task: { action: "block", running: "Reporting a blocker", completed: "Reported a blocker" },
@@ -439,6 +445,7 @@ export function toolActivityPresentation(input: ToolActivityPresentationInput):
technicalName: rawName || undefined,
confidence,
summaryGroup,
...(exact?.sentence ? { sentenceSubject: true } : {}),
};
}