Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Keep a default pick at the short quote; only real answers travel whole

AdityaUmale76c150e63b37
diff --git a/server/runtime/envelope.test.ts b/server/runtime/envelope.test.ts
index 7b0f90bada..8213450e3b 100644
--- a/server/runtime/envelope.test.ts
+++ b/server/runtime/envelope.test.ts
@@ -485,6 +485,14 @@ describe("composeEnvelope at Full access: nothing a bot can settle waits on the
expect(composeResume(long, chief, [])).toContain(line);
});
+ it("still bounds a long default pick to the short quote", () => {
+ const answer = `Pick A. ${"x".repeat(1_000)}TAIL`;
+ const envelope = composeEnvelope(assignment({ answer, answeredBy: { kind: "default" } }), names);
+ expect(envelope).toContain("go on with your default, \"Pick A. ");
+ expect(envelope).not.toContain("TAIL");
+ expect(envelope.length).toBeLessThan(envelope.indexOf("go on with your default") + 600);
+ });
+
it("keeps the end of an answer that redaction made more than twice as long", () => {
const answer = `${"--token=x ".repeat(1000)}END`;
const envelope = composeEnvelope(assignment({ question: "Done?", answer, answeredBy: { kind: "bot", botId: "chief" } }), { ...names, answerer: "Chief" });
diff --git a/server/runtime/envelope.ts b/server/runtime/envelope.ts
index 1a1f88d49d..78e892b15d 100644
--- a/server/runtime/envelope.ts
+++ b/server/runtime/envelope.ts
@@ -111,7 +111,8 @@ function replyLine(a: Assignment, requester: string, parent?: Assignment): strin
function 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, Number.POSITIVE_INFINITY);
+ // Only a bot's or the person's answer travels whole; a default pick keeps the short quote it always had.
+ const answer = quote(a.answer, a.answeredBy?.kind === "default" ? QUOTE_MAX : Number.POSITIVE_INFINITY);
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.`;
}