Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(coordination): keep amounts and operators in request identity
Afloatfb486dfae4b8
diff --git a/server/runtime-coordinator.test.ts b/server/runtime-coordinator.test.tsindex 15fc89184e..290fb71026 100644--- a/server/runtime-coordinator.test.ts+++ b/server/runtime-coordinator.test.ts@@ -704,6 +704,14 @@ describe("RuntimeCoordinator: one answer to the same request from two teammates"send(w, chief, "gen-1", undefined, builder, ASK);send(w, lead, "gen-2", undefined, builderForLead, "How many days would the database migration to the new hosting provider cost, roughly?");}],+ ["a request in another currency", (w) => {+ send(w, chief, "gen-1", undefined, builder, "Please calculate the forecast for the next financial year using a budget of $100.");+ send(w, lead, "gen-2", undefined, builderForLead, "Please calculate the forecast for the next financial year using a budget of €100.");+ }],+ ["a request with the opposite comparison", (w) => {+ send(w, chief, "gen-1", undefined, builder, "Please find all the invoices from the previous financial year with an amount >= 100.");+ send(w, lead, "gen-2", undefined, builderForLead, "Please find all the invoices from the previous financial year with an amount <= 100.");+ }],["a requester who may not read the first answer", (w) => {w.host.shareAnswer = () => false;send(w, chief, "gen-1", undefined, builder, ASK);diff --git a/server/same-request.test.ts b/server/same-request.test.tsindex c1050e657e..60e061a09a 100644--- a/server/same-request.test.ts+++ b/server/same-request.test.ts@@ -30,4 +30,18 @@ describe("whether two requests to one bot ask the same thing", () => {expect(sameRequest("Any update on this one?", "Any update on this one?")).toBe(false);expect(sameRequest("", "")).toBe(false);});++ it.each([+ ["currency", "$100", "€100"],+ ["sign", "+100", "-100"],+ ["signed currency", "$100", "-$100"],+ ["comparison", ">= 100", "<= 100"],+ ["percentage", "5%", "5"],+ ["decimal separator", "1.5", "1,5"],+ ["fraction and range", "1/2", "1-2"],+ ])("keeps a different %s from reusing another request's answer", (_name, first, second) => {+ const request = (value: string) => `Please calculate the forecast for the next financial year using a value of ${value} in the report.`;+ expect(sameRequest(request(first), request(second))).toBe(false);+ expect(sameRequest(request(first), request(first).toUpperCase())).toBe(true);+ });});diff --git a/server/same-request.ts b/server/same-request.tsindex 52439aa7d4..30289cc3d9 100644--- a/server/same-request.ts+++ b/server/same-request.ts@@ -1,14 +1,16 @@// Whether two requests to the same bot ask the same thing: the same words in the same order, whatever their case,-// punctuation or spacing, as when two teammates pass on one question in the person's words. Requests that differ by-// any word (an amount, a date, "not", "cost" for "take") are two requests, however alike they read: answering one+// ordinary sentence punctuation or spacing, as when two teammates pass on one question in the person's words. Requests that differ by+// a symbol or any word (an amount, a date, "not", "cost" for "take") are two requests, however alike they read: answering one// with the other's answer would be wrong, while answering both only costs a second turn. Only a long enough request// counts: a short "any update?" from two conversations means two things./** At least this many characters of words, once case, punctuation and spacing are set aside. */export const SAME_REQUEST_MIN_CHARS = 40;-/** Punctuation becomes a space, so "5-6 days" never reads as "56 days". */-const words = (text: string) => text.toLowerCase().replace(/[^\p{L}\p{N}\s]+/gu, " ").replace(/\s+/g, " ").trim();+/** Symbols and punctuation next to numbers can change the requested amount or comparison. */+const words = (text: string) => text.toLowerCase()+ .replace(/(?<![\p{N}\p{Sc}])[^\p{L}\p{N}\p{S}\s%](?![\p{N}\p{Sc}])/gu, " ")+ .replace(/\s+/g, " ").trim();export function sameRequest(a: string, b: string): boolean {const left = words(a);