diff --git a/packages/agent/src/server/agent-server.ts b/packages/agent/src/server/agent-server.ts index f53594a274..990fd388db 100644 --- a/packages/agent/src/server/agent-server.ts +++ b/packages/agent/src/server/agent-server.ts @@ -3625,6 +3625,10 @@ Optimize for the fewest shell round trips. - Read multiple files at once. - Never rerun a command solely to reproduce output you already have.`; + const artifactInstructions = ` +## Delivering non-code files (artifacts) +When you create a non-code file the user should be able to download (such as a report, chart, image, archive, or data file), call the \`upload_artifact\` tool with its path before your final reply. In your final reply, link to the download URL returned by the tool—never link to the file's local workspace path. Files left in the workspace don't reach the user. Don't upload source code or repository changes—those belong in a commit or PR.`; + const whyContextInstruction = ` - Add a brief **Why** to the body — one or two sentences capturing the reason the user asked for this change (the motivation, not a restatement of the diff). Keep it short.`; const publicRepoSafetyInstruction = ` - **Public-repo safety.** Treat the target repository as public-readable unless you have verified otherwise. The PR title, description, and commit messages must not contain private operational scale (exact event counts, internal row volumes, customer-usage percentages), customer names / emails / companies, references to internal tickets or incidents, the contents of Slack threads (do not quote or paraphrase what was said), or unreleased roadmap details. Linking to the originating Slack thread is fine and encouraged — Slack links are auth-gated and useful as context — as are channel references like "raised in #team-foo". Describe findings qualitatively ("present on nearly all X events, absent from Y") rather than with quantitative figures pulled from analytics queries — the reasoning that uses those numbers can stay in the thread; the PR copy cannot.`; const prMentionSafetyInstruction = ` - **Never guess a GitHub identity.** Do NOT \`@\`-mention, tag, assign, request review from, or attribute the PR to a person (in the title, description, commit message, or reviewers) using a name or handle taken from Slack or this thread. A Slack display name or handle is NOT a GitHub username. Finding a similar-looking handle in the repo's git history, CODEOWNERS, or existing PRs/issues does NOT confirm it belongs to this person: repository presence proves the handle exists, not that it is the person you mean, so treating it as a match still \`@\`-tags an unrelated account (e.g. Slack "Ross" is not necessarily GitHub \`@ross\`, even if some \`@ross\` has committed to the repo). Only \`@\`-mention a GitHub \`@handle\` the user gave you explicitly in this thread. Otherwise refer to people by plain-text name, or omit the mention entirely.`; @@ -3652,7 +3656,7 @@ Do the requested work, but stop with local changes ready for review. Important: - Do NOT create new commits, push to the branch, or update the pull request unless the user explicitly asks. - Do NOT create a new branch or a new pull request unless the user explicitly asks. -${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions} +${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions}${artifactInstructions} `; } @@ -3673,7 +3677,7 @@ After completing the requested changes: Important: - Do NOT create a new branch or a new pull request unless the user explicitly asks. - Do NOT push fixes for review comments without replying to and resolving each related thread. -${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions} +${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions}${artifactInstructions} `; } @@ -3725,7 +3729,7 @@ ${publishInstructions} Important: - Prefer using MCP tools to answer questions with real data over giving generic advice. -${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions} +${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions}${artifactInstructions} `; } @@ -3743,7 +3747,7 @@ ${publicRepoSafetyInstruction.trimStart()} ${prMentionSafetyInstruction.trimStart()} - End the PR description with a horizontal rule followed by this footer line: ${prFooter} - Always create the PR as a draft. -${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions} +${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions}${artifactInstructions} `; } @@ -3771,7 +3775,7 @@ ${prFooter} Important: - Always create the PR as a draft. Do not ask for confirmation. -${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions} +${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions}${artifactInstructions} `; }