fix(adapters): preserve truncated reply fetch context

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-07-13 02:15:32 +00:00
1 parent 9646cb1ec3
commit 0ff3712f2d
2 files changed
+31 -3

No files matched your search

@@ -884,6 +884,32 @@ describe("renderPaperclipWakePrompt", () => {
expect(prompt).toContain("Replying comment:\nThis is my reply.");
});
it("keeps reply fetch guidance when the inline original body budget is exhausted", () => {
const issueId = "11111111-1111-4111-8111-111111111111";
const replyTargetId = "22222222-2222-4222-8222-222222222222";
const prompt = renderPaperclipWakePrompt({
reason: "issue_commented",
issue: { id: issueId, identifier: "PAP-1581", title: "Handle a direct reply" },
commentWindow: { requestedCount: 1, includedCount: 1, missingCount: 0 },
comments: [{
id: "33333333-3333-4333-8333-333333333333",
issueId,
body: "This is my reply.",
replyToComment: {
id: replyTargetId,
body: "",
bodyTruncated: true,
author: { type: "agent", id: "agent-1" },
},
}],
fallbackFetchNeeded: false,
});
expect(prompt).toContain("Treat that earlier comment as the direct subject of this reply.");
expect(prompt).toContain(`GET /api/issues/${issueId}/comments/${replyTargetId}`);
expect(prompt).toContain("Replying comment:\nThis is my reply.");
});
it("renders the execution workspace branch guard only on non-resumed sessions", () => {
const payload = {
reason: "issue_assigned",
+5 -3
View File
@@ -679,6 +679,8 @@ function normalizePaperclipWakeComment(value: unknown): PaperclipWakeComment | n
const replyToComment = parseObject(comment.replyToComment);
const replyToAuthor = parseObject(replyToComment.author);
const replyToBody = asString(replyToComment.body, "");
const replyToId = asString(replyToComment.id, "").trim() || null;
const replyToBodyTruncated = asBoolean(replyToComment.bodyTruncated, false);
const body = asString(comment.body, "");
if (!body.trim()) return null;
return {
@@ -689,11 +691,11 @@ function normalizePaperclipWakeComment(value: unknown): PaperclipWakeComment | n
createdAt: asString(comment.createdAt, "").trim() || null,
authorType: asString(author.type, "").trim() || null,
authorId: asString(author.id, "").trim() || null,
replyToComment: replyToBody.trim()
replyToComment: replyToId || replyToBody.trim() || replyToBodyTruncated
? {
id: asString(replyToComment.id, "").trim() || null,
id: replyToId,
body: replyToBody,
bodyTruncated: asBoolean(replyToComment.bodyTruncated, false),
bodyTruncated: replyToBodyTruncated,
createdAt: asString(replyToComment.createdAt, "").trim() || null,
authorType: asString(replyToAuthor.type, "").trim() || null,
authorId: asString(replyToAuthor.id, "").trim() || null,