Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(runtime): keep a teammate's answer whole in the next turn
AdityaUmaled4bc430ff055
diff --git a/server/runtime/envelope.test.ts b/server/runtime/envelope.test.tsindex 9393cf48f0..7c9b24eb7c 100644--- a/server/runtime/envelope.test.ts+++ b/server/runtime/envelope.test.ts@@ -1,7 +1,7 @@import { describe, expect, it } from "vitest";import { CONSENT_RULE } from "../peer-provenance.ts";-import { composeAddition, composeEnvelope, composeQuestion, composeReport, composeResume, composeRootTurn, ENVELOPE_MARK, escapeEnvelope } from "./envelope.ts";+import { composeAddition, composeEnvelope, composeQuestion, composeReport, composeResume, composeRootTurn, ENVELOPE_MARK, envelopeNote, escapeEnvelope } from "./envelope.ts";import type { Assignment, EnvelopeNames } from "./types.ts";const base: Assignment = {@@ -471,6 +471,18 @@ describe("composeEnvelope at Full access: nothing a bot can settle waits on theexpect(composeEnvelope(assignment({ answer: "", answeredBy: { kind: "default" } }), names).endsWith("\n\nNobody was asked, at this level: pick the sensible default yourself, and say in one plain line what you chose.")).toBe(true);});++ it("carries a long answer whole, also in the note the thread shows and on resume", () => {+ const answer = `Use the fork. ${"You work best with a clear brief. ".repeat(120)}End of answer.`;+ const long = assignment({ question: "Which repo?", answer, answeredBy: { kind: "bot", botId: "chief" } });+ const chief = { ...names, answerer: "Chief" };+ const line = `@Chief answered: "${answer.trim()}".`;+ expect(answer.length).toBeGreaterThan(3_900);+ const envelope = composeEnvelope(long, chief);+ expect(envelope.endsWith(`\n\nYour question was: "Which repo?". ${line}`)).toBe(true);+ expect(envelopeNote(envelope)).toContain(line);+ expect(composeResume(long, chief, [])).toContain(line);+ });});describe("composeResume", () => {diff --git a/server/runtime/envelope.ts b/server/runtime/envelope.tsindex f743f72df5..914b761799 100644--- a/server/runtime/envelope.ts+++ b/server/runtime/envelope.ts@@ -9,6 +9,8 @@ import type { Assignment, EnvelopeNames, Level, OriginSource, TurnEvidence } froexport const ENVELOPE_MARK = "[From";const QUOTE_MAX = 400;+/** An answer is quoted whole: it is what the next turn works from, and the runtime already keeps it to 12 000 characters. */+const ANSWER_QUOTE_MAX = 12_000;const NAME_MAX = 80;const DETAIL_MAX = 200;const FILES_SHOWN = 8;@@ -111,7 +113,7 @@ function replyLine(a: Assignment, requester: string, parent?: Assignment): strinfunction answerLine(a: Assignment, names: EnvelopeNames): string {const question = quote(a.question, QUOTE_MAX);const asked = question ? `Your question was: "${question}". ` : "";- const answer = quote(a.answer, QUOTE_MAX);+ const answer = quote(a.answer, ANSWER_QUOTE_MAX);if (a.answeredBy?.kind === "default") {return `${asked}Nobody was asked, at this level: ${answer ? `go on with your default, "${answer}"` : "pick the sensible default yourself"}, and say in one plain line what you chose.`;}