diff --git a/server/src/services/native-runtime/native-completion-feedback.test.ts b/server/src/services/native-runtime/native-completion-feedback.test.ts index df586909b15..84a29733671 100644 --- a/server/src/services/native-runtime/native-completion-feedback.test.ts +++ b/server/src/services/native-runtime/native-completion-feedback.test.ts @@ -211,6 +211,27 @@ describe("native final-response feedback", () => { expect(feedback).toContain("When compatible with the requested response format"); expect(feedback).not.toContain("publish secrets"); }); + it("guides ordinary resource reports to use returned hrefs as Markdown links without inventing them", async () => { + const value = await fixture(); + await db.delete(issueDocuments).where(eq(issueDocuments.issueId, value.issueId)); + await db.update(issues).set({ title: "Install the accepted team", description: "Install the accepted team." }).where(eq(issues.id, value.issueId)); + const feedback = await nativeCompletionFeedback(db, value.runId, { ...done, summary: "Team installed." }); + expect(feedback).toContain("usable Markdown links [name](href)"); + expect(feedback).toContain("resourceLinks or resource hrefs actually returned by tools"); + expect(feedback).toContain("not only backtick-wrapped paths"); + expect(feedback).toContain("Do not guess routes or invent links"); + expect(feedback).not.toContain("/agents/"); + expect(feedback).not.toContain(value.saved.documentHref); + }); + it("keeps an exact requested final format ahead of conditional resource-link guidance", async () => { + const value = await fixture(); + await db.update(issues).set({ description: "Reply with exactly OK." }).where(eq(issues.id, value.issueId)); + const report = { ...done, summary: "OK" }; + const feedback = await nativeCompletionFeedback(db, value.runId, report); + expect(feedback).toContain("Follow the user's explicitly requested final-response format, including an exact response when requested"); + expect(feedback).toContain("When compatible with the requested response format, present any created or updated Paperclip resources you cite"); + expect(report.summary).toBe("OK"); + }); it("does not link stale saved revisions", async () => { const value = await fixture(); await documentService(db).upsertIssueDocument({ format: "markdown", issueId: value.issueId, key: "output", title: "Updated", body: "New version", @@ -303,7 +324,7 @@ describe("native final-response feedback", () => { completionClaim: { ...done.completionClaim, objectiveSatisfied: false }, blocker: { reasonCode: "missing_access", reason: "Missing release access", owner: { name: "Release Owner", kind: "user" }, unblockAction: "Grant deployment access", scope: "task_wide" }, }); - expect(feedback).toContain("Explain why work cannot continue"); + expect(feedback).toBe("Blocker report accepted. Explain why work cannot continue, name the blocker owner and give the unblock action in your final response; do not describe the task as completed."); expect(feedback).not.toContain("Describe the completed work"); }); }); diff --git a/server/src/services/native-runtime/native-completion-feedback.ts b/server/src/services/native-runtime/native-completion-feedback.ts index 2ca635ca02e..e43b964d15c 100644 --- a/server/src/services/native-runtime/native-completion-feedback.ts +++ b/server/src/services/native-runtime/native-completion-feedback.ts @@ -355,5 +355,5 @@ export async function nativeCompletionFeedback( const links = await savedDocumentLinks(db, run, issue); const documentGuidance = links.length ? ` When compatible with the requested response format, include these clickable links to this run's saved documents in your final response: ${links.join(" ")}` : ""; - return "Completion report accepted. Task status will be committed after this turn and workspace finalization finish. Follow the user's explicitly requested final-response format, including an exact response when requested. Otherwise describe the completed work and any explicitly requested reviewer action. Do not claim an approval is needed unless one was requested." + documentGuidance; + return "Completion report accepted. Task status will be committed after this turn and workspace finalization finish. Follow the user's explicitly requested final-response format, including an exact response when requested. Otherwise describe the completed work and any explicitly requested reviewer action. Do not claim an approval is needed unless one was requested. When compatible with the requested response format, present any created or updated Paperclip resources you cite as usable Markdown links [name](href), using resourceLinks or resource hrefs actually returned by tools, not only backtick-wrapped paths. Do not guess routes or invent links when no resource href was returned." + documentGuidance; }