Skip to content

Commit 1ada725

Browse files
committed
fix: persist URL across status_set calls until explicitly replaced
Previously, calling status_set without a URL would clear the stored URL. Now, the URL persists until explicitly replaced with a different URL. - Updated StreamingMessageAggregator to preserve previous URL - Updated test to verify URL persistence behavior - Clarified tool description
1 parent ae89f17 commit 1ada725

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

src/utils/messages/StreamingMessageAggregator.status.test.ts

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
584584
expect(status?.url).toBe(testUrl);
585585
});
586586

587-
it("should persist URL until replaced with new status", () => {
587+
it("should persist URL across status updates until explicitly replaced", () => {
588588
const aggregator = new StreamingMessageAggregator("2024-01-01T00:00:00.000Z");
589589
const messageId = "msg1";
590590

@@ -621,7 +621,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
621621

622622
expect(aggregator.getAgentStatus()?.url).toBe(testUrl);
623623

624-
// Second status without URL - should clear URL
624+
// Second status without URL - should keep previous URL
625625
aggregator.handleToolCallStart({
626626
type: "tool-call-start",
627627
workspaceId: "workspace1",
@@ -642,9 +642,36 @@ describe("StreamingMessageAggregator - Agent Status", () => {
642642
result: { success: true, emoji: "✅", message: "Done" },
643643
});
644644

645+
const statusAfterUpdate = aggregator.getAgentStatus();
646+
expect(statusAfterUpdate?.emoji).toBe("✅");
647+
expect(statusAfterUpdate?.message).toBe("Done");
648+
expect(statusAfterUpdate?.url).toBe(testUrl); // URL persists
649+
650+
// Third status with different URL - should replace
651+
const newUrl = "https://github.com/owner/repo/pull/456";
652+
aggregator.handleToolCallStart({
653+
type: "tool-call-start",
654+
workspaceId: "workspace1",
655+
messageId,
656+
toolCallId: "tool3",
657+
toolName: "status_set",
658+
args: { emoji: "🔄", message: "New PR", url: newUrl },
659+
tokens: 10,
660+
timestamp: Date.now(),
661+
});
662+
663+
aggregator.handleToolCallEnd({
664+
type: "tool-call-end",
665+
workspaceId: "workspace1",
666+
messageId,
667+
toolCallId: "tool3",
668+
toolName: "status_set",
669+
result: { success: true, emoji: "🔄", message: "New PR", url: newUrl },
670+
});
671+
645672
const finalStatus = aggregator.getAgentStatus();
646-
expect(finalStatus?.emoji).toBe("");
647-
expect(finalStatus?.message).toBe("Done");
648-
expect(finalStatus?.url).toBeUndefined();
673+
expect(finalStatus?.emoji).toBe("🔄");
674+
expect(finalStatus?.message).toBe("New PR");
675+
expect(finalStatus?.url).toBe(newUrl); // URL replaced
649676
});
650677
});

src/utils/messages/StreamingMessageAggregator.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,12 @@ export class StreamingMessageAggregator {
523523
// Use output instead of input to get the truncated message
524524
if (toolName === "status_set" && hasSuccessResult(output)) {
525525
const result = output as { success: true; emoji: string; message: string; url?: string };
526+
// Preserve the previous URL if the new status doesn't provide one
527+
const previousUrl = this.agentStatus?.url;
526528
this.agentStatus = {
527529
emoji: result.emoji,
528530
message: result.message,
529-
...(result.url && { url: result.url }),
531+
url: result.url ?? previousUrl,
530532
};
531533
}
532534
}

src/utils/tools/toolDefinitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export const TOOL_DEFINITIONS = {
197197
"URL PARAMETER:\n" +
198198
"- Optional 'url' parameter links to external resources (e.g., PR URL: 'https://github.com/owner/repo/pull/123')\n" +
199199
"- Prefer stable URLs that don't change often - saving the same URL twice is a no-op\n" +
200-
"- URL persists until replaced by a new status",
200+
"- URL persists until replaced by a new status with a different URL",
201201
schema: z
202202
.object({
203203
emoji: z.string().describe("A single emoji character representing the current activity"),

0 commit comments

Comments
 (0)