The Open Framework for Building Agents
fix(eve): keep GitHub context out of option replies (#1966)
vercel-gh-bot-4[bot]22975d3243bd
diff --git a/.changeset/calm-ravens-resume.md b/.changeset/calm-ravens-resume.mdnew file mode 100644index 000000000..ba53686f7--- /dev/null+++ b/.changeset/calm-ravens-resume.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Keep GitHub comment text separate from channel metadata so option replies can resume pending input requests.diff --git a/packages/eve/src/public/channels/github/dispatch.ts b/packages/eve/src/public/channels/github/dispatch.tsindex cfddca4ac..fb24fb7fc 100644--- a/packages/eve/src/public/channels/github/dispatch.ts+++ b/packages/eve/src/public/channels/github/dispatch.ts@@ -6,7 +6,6 @@ import { buildGitHubBinding } from "#public/channels/github/binding.js";import {extractGitHubCommentTrigger,formatGitHubContextBlock,- prependGitHubContext,type GitHubCheckRunWebhookEvent,type GitHubCheckSuiteWebhookEvent,type GitHubCiPayload,@@ -313,12 +312,11 @@ async function sendGitHubTurn(input: {repository: input.event.repository,sender: input.event.sender,});- const turnMessage = prependGitHubContext(input.message, contextBlock);try {- await input.from(continuationTokenFromState(input.state)).send(turnMessage, {+ await input.from(continuationTokenFromState(input.state)).send(input.message, {auth: input.auth,- context: input.context,+ context: [contextBlock, ...(input.context ?? [])],state: input.state,});} catch (error) {diff --git a/packages/eve/src/public/channels/github/githubChannel.test.ts b/packages/eve/src/public/channels/github/githubChannel.test.tsindex 67ed8c4f6..2ad40c879 100644--- a/packages/eve/src/public/channels/github/githubChannel.test.ts+++ b/packages/eve/src/public/channels/github/githubChannel.test.ts@@ -231,8 +231,8 @@ describe("githubChannel", () => {expect(send).toHaveBeenCalledTimes(1);const [continuationToken, input] = send.mock.calls[0]!;- expect(input.message).toContain("<github_context>");- expect(input.message).toContain("help me");+ expect(input.message).toBe("help me");+ expect(input.context).toEqual([expect.stringContaining("<github_context>")]);expect(input.inputResponses).toBeUndefined();expect(continuationToken).toBe("repo:123:issue:5");expect(input).toMatchObject({@@ -257,6 +257,34 @@ describe("githubChannel", () => {});});+ it("keeps GitHub metadata separate from the comment text", async () => {+ const channel = githubChannel({+ botName: "testbot",+ credentials: { webhookSecret: SECRET },+ });+ const { send } = await firePost(+ channel,+ signedRequest(+ "issue_comment",+ basePayload({+ action: "created",+ comment: {+ body: "@testbot Yes",+ html_url: "https://github.test/vercel/eve/issues/5#issuecomment-10",+ id: 10,+ user: { id: 1, login: "octocat", type: "User" },+ },+ issue: { number: 5 },+ }),+ ),+ );++ expect(send).toHaveBeenCalledTimes(1);+ const [, input] = send.mock.calls[0]!;+ expect(input.message).toBe("Yes");+ expect(input.context).toEqual([expect.stringContaining("<github_context>")]);+ });+it("dispatches Connect-forwarded issue comments without GitHub event headers", async () => {const warn = vi.spyOn(console, "warn").mockImplementation(() => {});const channel = githubChannel({@@ -281,8 +309,10 @@ describe("githubChannel", () => {expect(send).toHaveBeenCalledTimes(1);const [continuationToken, input] = send.mock.calls[0]!;- expect(input.message).toContain("delivery_id: inferred:issue_comment:10:created");- expect(input.message).toContain("help me");+ expect(input.message).toBe("help me");+ expect(input.context).toEqual([+ expect.stringContaining("delivery_id: inferred:issue_comment:10:created"),+ ]);expect(continuationToken).toBe("repo:123:issue:5");expect(input).toMatchObject({auth: {@@ -404,8 +434,9 @@ describe("githubChannel", () => {expect(fetchMock.mock.calls[0]?.[0]).toBe("https://github.test/repos/vercel/eve/pulls/7");const [, input] = send.mock.calls[0]!;- expect(input.context?.[0]).toContain("title: Add GitHub context");- expect(input.context?.[0]).toContain("head_sha: head-sha");+ expect(input.context?.[0]).toContain("<github_context>");+ expect(input.context?.[1]).toContain("title: Add GitHub context");+ expect(input.context?.[1]).toContain("head_sha: head-sha");});it("dispatches inline review comments to the review-thread token", async () => {diff --git a/packages/eve/src/public/channels/github/inbound.ts b/packages/eve/src/public/channels/github/inbound.tsindex 435ad4d8b..534d0026d 100644--- a/packages/eve/src/public/channels/github/inbound.ts+++ b/packages/eve/src/public/channels/github/inbound.ts@@ -1,5 +1,3 @@-import type { TextPart, UserContent } from "ai";-import { isObject } from "#shared/guards.js";import { parseJsonObject, type JsonObject } from "#shared/json.js";import type {@@ -210,18 +208,6 @@ export function formatGitHubContextBlock(input: {return lines.join("\n");}-/** Prepends a `<github_context>` block to the inbound turn message. */-export function prependGitHubContext(- message: string | UserContent,- block: string,-): string | UserContent {- if (typeof message === "string") {- return message.length > 0 ? `${block}\n\n${message}` : block;- }- const contextPart: TextPart = { text: block, type: "text" };- return [contextPart, ...message];-}-function parseIssueCommentEvent(base: GitHubInboundEventBase): GitHubIssueCommentEvent | null {const issue = isObject(base.raw.issue) ? base.raw.issue : null;const rawComment = isObject(base.raw.comment) ? parseJsonObject(base.raw.comment) : null;