Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

fix(coding-agent): show only message text for expanded sent agent messages (#772)

Sebastian Müllerb817a089b23a
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md
index 83cd6fefc6..491582a358 100644
--- a/packages/coding-agent/CHANGELOG.md
+++ b/packages/coding-agent/CHANGELOG.md
@@ -2,6 +2,7 @@
## [Unreleased]
+- Changed sent agent messages in the IPython cell UI to show only the message text with a `╰─` gutter when expanded, matching received messages, and hid the raw `agent_message.send` receipt dictionary.
- Fixed Homebrew installs attempting to self-update their versioned Cellar keg instead of directing users to `brew upgrade prime-agent` ([#844](https://github.com/PrimeIntellect-ai/prime-agent/issues/844))
## [0.7.1] - 2026-08-07
diff --git a/packages/coding-agent/package.json b/packages/coding-agent/package.json
index 5db7f6d762..bb0570e403 100644
--- a/packages/coding-agent/package.json
+++ b/packages/coding-agent/package.json
@@ -44,7 +44,7 @@
"postinstall": "node postinstall.cjs",
"prepublishOnly": "npm run clean && npm run build",
"bundle": "node scripts/bundle.mjs",
- "test:kernel": "vitest --run --no-file-parallelism --tagsFilter kernel-heavy test/acp-kernel-features.test.ts test/acp-cold-cli.test.ts test/kernel-state-roundtrip.test.ts"
+ "test:kernel": "vitest --run --no-file-parallelism --tagsFilter kernel-heavy test/acp-kernel-features.test.ts test/acp-cold-cli.test.ts test/kernel-goal-skill.test.ts test/kernel-state-roundtrip.test.ts"
},
"dependencies": {
"@agentclientprotocol/sdk": "^1.3.0",
diff --git a/packages/coding-agent/src/modes/interactive/components/agent-message.ts b/packages/coding-agent/src/modes/interactive/components/agent-message.ts
index d18363245c..532b1eef11 100644
--- a/packages/coding-agent/src/modes/interactive/components/agent-message.ts
+++ b/packages/coding-agent/src/modes/interactive/components/agent-message.ts
@@ -16,20 +16,39 @@ function collapseText(text: string): string {
return text.replace(/\s+/g, " ").trim();
}
+/** `◆ <label> · <participant>[ · <preview>]` summary line shared by received and sent agent-message UI. */
+export function agentMessageSummaryLine(label: string, participant: string, preview?: string): string {
+ const parts = [`${theme.fg("accent", "◆")} ${theme.fg("muted", label)}`, theme.fg("muted", participant)];
+ if (preview) {
+ parts.push(theme.fg("muted", preview));
+ }
+ return parts.join(theme.fg("dim", " · "));
+}
+
+/** Single-line message preview sized to fit after the summary-line prefix. */
+export function agentMessagePreview(prefixWidth: number, message: string): string {
+ return truncateToWidth(collapseText(message), Math.max(20, 100 - prefixWidth));
+}
+
+/** `╰─`-guttered message body lines shared by received and sent agent-message UI. */
+export function agentMessageBodyLines(message: string, width: number): string[] {
+ const safeWidth = Math.max(1, width);
+ const textWidth = Math.max(1, safeWidth - 4);
+ const bodyLines = message.split("\n").flatMap((line) => {
+ const wrapped = wrapTextWithAnsi(line, textWidth);
+ return wrapped.length > 0 ? wrapped : [""];
+ });
+ return bodyLines.map((line, index) => {
+ const prefix = index === 0 ? theme.fg("dim", "╰─ ") : " ";
+ return truncateToWidth(` ${prefix}${theme.fg("customMessageText", line)}`, safeWidth, "");
+ });
+}
+
class AgentMessageBodyComponent implements Component {
constructor(private readonly message: string) {}
render(width: number): string[] {
- const safeWidth = Math.max(1, width);
- const textWidth = Math.max(1, safeWidth - 4);
- const bodyLines = this.message.split("\n").flatMap((line) => {
- const wrapped = wrapTextWithAnsi(line, textWidth);
- return wrapped.length > 0 ? wrapped : [""];
- });
- return bodyLines.map((line, index) => {
- const prefix = index === 0 ? theme.fg("dim", "╰─ ") : " ";
- return truncateToWidth(` ${prefix}${theme.fg("customMessageText", line)}`, safeWidth, "");
- });
+ return agentMessageBodyLines(this.message, width);
}
invalidate(): void {}
@@ -74,22 +93,19 @@ export class AgentMessageComponent extends Container {
}
private headerText(): string {
- const icon = theme.fg("accent", "◆");
- const title = theme.fg("muted", "Agent message received");
+ const label = "Agent message received";
const participant = formatAgentMessageParticipant(
"received",
this.message.details.fromRelationship,
this.message.details.from,
);
- const sender = theme.fg("muted", participant);
- const separator = theme.fg("dim", " · ");
if (this.expanded) {
- return `${icon} ${title}${separator}${sender}`;
+ return agentMessageSummaryLine(label, participant);
}
- const prefixWidth = visibleWidth(`◆ Agent message received · ${participant} · `);
- const preview = truncateToWidth(collapseText(this.message.details.message), Math.max(20, 100 - prefixWidth));
+ const prefixWidth = visibleWidth(`◆ ${label} · ${participant} · `);
+ const preview = agentMessagePreview(prefixWidth, this.message.details.message);
const hint = theme.fg("dim", ` (${keyText("app.tools.expand")} to expand)`);
- return `${icon} ${title}${separator}${sender}${separator}${theme.fg("muted", preview)}${hint}`;
+ return `${agentMessageSummaryLine(label, participant, preview)}${hint}`;
}
}
diff --git a/packages/coding-agent/src/modes/interactive/components/ipython-cell.ts b/packages/coding-agent/src/modes/interactive/components/ipython-cell.ts
index 20aea1d345..ff9cf98be2 100644
--- a/packages/coding-agent/src/modes/interactive/components/ipython-cell.ts
+++ b/packages/coding-agent/src/modes/interactive/components/ipython-cell.ts
@@ -13,6 +13,7 @@ import { parseIpythonBashCell } from "../../../core/tools/ipython-cell-code.js";
import { shortenPath } from "../../../core/tools/render-utils.js";
import { getLanguageFromPath, highlightCode, theme } from "../theme/theme.js";
import { getWorkingPulseFrame, WORKING_ICON_FRAMES, workingIconFrame } from "../theme/working-icon.js";
+import { agentMessageBodyLines, agentMessagePreview, agentMessageSummaryLine } from "./agent-message.js";
import { normalizeErrorDetails, summarizeErrorDetails } from "./collapsible-error.js";
import { renderDiffSeparator, renderRichDiff } from "./diff.js";
import { keyHint } from "./keybinding-hints.js";
@@ -238,6 +239,23 @@ function isEditConfirmation(text: string | undefined, diffs: readonly DiffDispla
return diffs.some((diff) => stripped === `Edited ${diff.path}`);
}
+/**
+ * True when `text` is the `agent_message.send` receipt dict for one of the sent
+ * messages already summarized above the output, so the raw receipt isn't shown.
+ * Matches only a single-receipt repr — the receipt dict always starts with its
+ * `id` key — so broadcast `{'receipts': [...]}` results (which can carry error
+ * entries with no summary line) and results that merely mention an ID still render.
+ */
+function isAgentMessageReceipt(text: string | undefined, messages: readonly SentAgentMessageDisplay[]): boolean {
+ if (!text || messages.length === 0) {
+ return false;
+ }
+ const stripped = stripReprQuotes(text);
+ return messages.some(
+ (message) => stripped.startsWith(`{'id': '${message.id}'`) || stripped.startsWith(`{"id": "${message.id}"`),
+ );
+}
+
function readErrorDetails(value: unknown): IpythonErrorDetails | undefined {
if (!value || typeof value !== "object") {
return undefined;
@@ -437,10 +455,14 @@ export class IPythonCellComponent implements Component {
const input = body.filter((line) => line.trim().length > 0).length;
const hasDiffs = (details.diffs?.length ?? 0) > 0;
- const structured = [details.stdout, details.stderr, details.result]
+ const sentMessages = details.sentAgentMessages ?? [];
+ const result = isAgentMessageReceipt(details.result, sentMessages) ? undefined : details.result;
+ const structured = [details.stdout, details.stderr, result]
.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
.join("\n");
- const outputText = (structured || textFromBlocks(this.state.content)).trim();
+ const blocksText = textFromBlocks(this.state.content);
+ const fallback = isAgentMessageReceipt(blocksText, sentMessages) ? "" : blocksText;
+ const outputText = (structured || fallback).trim();
const output = hasDiffs || !outputText ? 0 : outputText.split("\n").length;
const segments: string[] = [];
@@ -531,6 +553,7 @@ export class IPythonCellComponent implements Component {
let renderedTextOutput = false;
const diffs = details.diffs ?? [];
+ const sentMessages = details.sentAgentMessages ?? [];
const startOutput = (): void => {
if (outputStarted) {
@@ -553,7 +576,11 @@ export class IPythonCellComponent implements Component {
renderedTextOutput = true;
this.renderOutputText(lines, width, normalizeErrorDetails(details.stderr), "err");
}
- if (details.result?.trim() && !isEditConfirmation(details.result, diffs)) {
+ if (
+ details.result?.trim() &&
+ !isEditConfirmation(details.result, diffs) &&
+ !isAgentMessageReceipt(details.result, sentMessages)
+ ) {
startOutput();
renderedTextOutput = true;
this.renderOutputText(lines, width, normalizeErrorDetails(details.result), "out");
@@ -564,7 +591,7 @@ export class IPythonCellComponent implements Component {
renderedTextOutput = true;
this.renderOutputText(lines, width, traceback.output, "out");
}
- } else if (text.trim()) {
+ } else if (text.trim() && !isAgentMessageReceipt(text, sentMessages)) {
startOutput();
renderedTextOutput = true;
this.renderOutputText(lines, width, normalizeErrorDetails(text), this.state.isError ? "err" : "out");
@@ -610,19 +637,29 @@ export class IPythonCellComponent implements Component {
}
}
+ // Summary line per message; expanding shows the message text in a `╰─` gutter
+ // instead of the collapsed preview, matching received agent-message UI.
private renderSentAgentMessages(lines: string[], width: number, messages: readonly SentAgentMessageDisplay[]): void {
for (const message of messages) {
const label = message.deliveryStatus === "delivered" ? "Agent message sent" : "Agent message queued";
const recipient = formatAgentMessageParticipant("sent", message.receiverRole, message.target);
- const text = message.message.replace(/\s+/g, " ").trim();
- const line =
- theme.fg("accent", "◆") +
- ` ${theme.fg("muted", label)}` +
- theme.fg("dim", " · ") +
- theme.fg("muted", recipient) +
- theme.fg("dim", " · ") +
- theme.fg("muted", text);
- this.addPlain(lines, truncateToWidth(line, Math.max(1, width - 1), "…"));
+ if (this.state.expanded) {
+ this.addBlank(lines, width);
+ this.addPlain(
+ lines,
+ truncateToWidth(agentMessageSummaryLine(label, recipient), Math.max(1, width - 1), "…"),
+ );
+ for (const bodyLine of agentMessageBodyLines(message.message, width)) {
+ lines.push(bodyLine);
+ }
+ continue;
+ }
+ const prefixWidth = visibleWidth(`◆ ${label} · ${recipient} · `);
+ const preview = agentMessagePreview(prefixWidth, message.message);
+ this.addPlain(
+ lines,
+ truncateToWidth(agentMessageSummaryLine(label, recipient, preview), Math.max(1, width - 1), "…"),
+ );
}
}
diff --git a/packages/coding-agent/test/kernel-goal-skill.test.ts b/packages/coding-agent/test/kernel-goal-skill.test.ts
index b72c87af6b..239ffa3518 100644
--- a/packages/coding-agent/test/kernel-goal-skill.test.ts
+++ b/packages/coding-agent/test/kernel-goal-skill.test.ts
@@ -16,7 +16,7 @@ function bundledGoalSkill(): PythonSkillRuntimeInfo {
};
}
-describe("goal skill over the kernel host bridge", () => {
+describe("goal skill over the kernel host bridge", { tags: ["kernel-heavy"] }, () => {
let tempDir: string;
let provisioner: IpythonKernelProvisioner | undefined;
@@ -129,16 +129,11 @@ except RuntimeError as error:
provisioner = new IpythonKernelProvisioner(tempDir, {
pythonSkills: [bundledGoalSkill()],
hostHandlers: {
- "goal.get": async () => ({ goal: null, remaining_tokens: null, completion_budget_report: null }),
+ "goal.get": async () => ({ status: "partial" }),
},
});
const manager = await provisioner.ensure();
- type CommSender = { sendCommMessage: (commId: string, data: Record<string, unknown>) => Promise<void> };
- const kernel = manager as unknown as CommSender;
- const originalSend = kernel.sendCommMessage.bind(manager);
- kernel.sendCommMessage = (commId, _data) => originalSend(commId, { status: "partial" });
-
const result = await manager.execute(`
try:
await goal.get()
diff --git a/packages/coding-agent/test/suite/regressions/4531-agent-message-ui.test.ts b/packages/coding-agent/test/suite/regressions/4531-agent-message-ui.test.ts
index e03b08fe2a..1493055708 100644
--- a/packages/coding-agent/test/suite/regressions/4531-agent-message-ui.test.ts
+++ b/packages/coding-agent/test/suite/regressions/4531-agent-message-ui.test.ts
@@ -534,4 +534,145 @@ describe("ENG-4531 agent message UI", () => {
]);
expect(rendered).not.toContain("Agent message received");
});
+
+ it("expands sent messages to the message text without the receipt metadata", () => {
+ const receipt =
+ "{'id': 'agentmsg_4531_delivered',\n" +
+ " 'source': 'agent_message',\n" +
+ " 'target': {'activeSessionId': 'worker-active', 'sessionId': 'worker-session'},\n" +
+ " 'message': 'Continue with shard eight.\\nThen report back.',\n" +
+ " 'deliveryStatus': 'delivered',\n" +
+ " 'deliveryMode': 'steer'}";
+ const component = new IPythonCellComponent({
+ code: 'await agent_message.send("Continue with shard eight.", receiver_role="parent")',
+ executionStarted: true,
+ argsComplete: true,
+ expanded: true,
+ details: {
+ status: "ok",
+ result: receipt,
+ sentAgentMessages: [
+ {
+ id: "agentmsg_4531_delivered",
+ message: "Continue with shard eight.\nThen report back.",
+ deliveryStatus: "delivered",
+ receiverRole: "parent",
+ target: {
+ activeSessionId: "worker-active",
+ sessionId: "worker-session",
+ sessionName: "Worker",
+ },
+ },
+ ],
+ },
+ });
+
+ const rendered = stripAnsi(component.render(120).join("\n"));
+ const lines = rendered.split("\n").filter((line) => line.trim().length > 0);
+ expect(lines).toEqual([
+ expect.stringContaining("python"),
+ expect.stringContaining("await agent_message.send"),
+ " ◆ Agent message sent · to parent Worker",
+ " ╰─ Continue with shard eight.",
+ " Then report back.",
+ ]);
+ expect(rendered).not.toContain("deliveryStatus");
+ expect(rendered).not.toContain("agentmsg_4531_delivered");
+ expect(stripAnsi(component.render(120).join("\n"))).not.toContain("· Continue with shard eight.");
+ });
+
+ it("keeps broadcast receipt lists with failed deliveries visible next to sent messages", () => {
+ const receipts =
+ "{'receipts': [{'id': 'agentmsg_4531_broadcast',\n" +
+ " 'deliveryStatus': 'delivered',\n" +
+ " 'message': 'Status check.'},\n" +
+ " {'target': 'worker-two', 'error': 'session is inactive'}]}";
+ const component = new IPythonCellComponent({
+ code: 'await agent_message.send("all", "Status check.")',
+ executionStarted: true,
+ argsComplete: true,
+ expanded: true,
+ details: {
+ status: "ok",
+ result: receipts,
+ sentAgentMessages: [
+ {
+ id: "agentmsg_4531_broadcast",
+ message: "Status check.",
+ deliveryStatus: "delivered",
+ receiverRole: "child",
+ target: {
+ activeSessionId: "worker-active",
+ sessionId: "worker-session",
+ sessionName: "Worker",
+ },
+ },
+ ],
+ },
+ });
+
+ const rendered = stripAnsi(component.render(120).join("\n"));
+ expect(rendered).toContain(" ◆ Agent message sent · to child Worker");
+ expect(rendered).toContain("'error': 'session is inactive'");
+ });
+
+ it("keeps results that merely mention a sent-message id visible", () => {
+ const component = new IPythonCellComponent({
+ code: "record_reply()",
+ executionStarted: true,
+ argsComplete: true,
+ expanded: true,
+ details: {
+ status: "ok",
+ result: "{'referenced_message': 'agentmsg_4531_ref', 'answer': 42}",
+ sentAgentMessages: [
+ {
+ id: "agentmsg_4531_ref",
+ message: "Ping.",
+ deliveryStatus: "delivered",
+ receiverRole: "parent",
+ target: {
+ activeSessionId: "worker-active",
+ sessionId: "worker-session",
+ sessionName: "Worker",
+ },
+ },
+ ],
+ },
+ });
+
+ const rendered = stripAnsi(component.render(120).join("\n"));
+ expect(rendered).toContain("'answer': 42");
+ });
+
+ it("keeps unrelated results visible next to sent messages", () => {
+ const component = new IPythonCellComponent({
+ code: 'await agent_message.send("Ping.", receiver_role="parent")\n"done"',
+ executionStarted: true,
+ argsComplete: true,
+ expanded: true,
+ details: {
+ status: "ok",
+ result: "'done'",
+ sentAgentMessages: [
+ {
+ id: "agentmsg_4531_result",
+ message: "Ping.",
+ deliveryStatus: "delivered",
+ receiverRole: "parent",
+ target: {
+ activeSessionId: "worker-active",
+ sessionId: "worker-session",
+ sessionName: "Worker",
+ },
+ },
+ ],
+ },
+ });
+
+ const rendered = stripAnsi(component.render(120).join("\n"));
+ expect(rendered).toContain(" ◆ Agent message sent · to parent Worker");
+ expect(rendered).toContain(" ╰─ Ping.");
+ expect(rendered).toContain("done");
+ });
});