Агенты: язык ответов - поле владельца (по умолчанию English), правило в промтах, смена только по просьбе владельца (deviations п.76)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -525,6 +525,39 @@ d("консольные агенты (временная БД, фейковый
|
||||
expect(p).toContain("what is overdue?");
|
||||
expect(liveCalls[0]!.env).toEqual({ KHB_SQL_URL: "postgres://ro-ceo" }); // чтение Supabase: роль руководителя
|
||||
});
|
||||
it("язык ответов: по умолчанию английский во входе; владелец просит сменить - меняется только его строка; по системному событию не меняется", async () => {
|
||||
const OTHER = "00000000-0000-0000-0000-0000000000a9";
|
||||
await db.pool.query("insert into person (id, display_name, jt_membership_id) values ($1,'llmtest-Other','m9')", [OTHER]);
|
||||
await db.pool.query("insert into construction_manager (person_id) values ($1)", [OTHER]);
|
||||
expect((await db.pool.query("select language from construction_manager where person_id = $1", [MGR])).rows[0].language).toBe("English");
|
||||
const slack = { postMessage: async () => true, fileInfo: async () => null, download: async () => 0 };
|
||||
const mgr = { personId: MGR, name: "llmtest-Manager", slackUserId: "ULLMTEST", slackChannelId: "CLLMTEST" };
|
||||
const msg = (text: string, ts: string) => [{ channel: "CLLMTEST", ts, text, fileIds: [] as string[] }];
|
||||
calls = [];
|
||||
script = [ok("## Ответ менеджеру\nOK\n## Память\nм1")];
|
||||
await handleManagerMessages({ ctx: ctx(), timezone: "America/New_York", slack, dryPublish: true }, mgr, msg("Привет, как дела? Ответь по-русски", "1791742000.000001"));
|
||||
expect(calls[0]!.prompt).toContain("# Язык ответов");
|
||||
expect(calls[0]!.prompt).toContain("Язык ответов владельцу агента (llmtest-Manager): English");
|
||||
// владелец сам просит сменить язык: запись только в его строку
|
||||
script = [ok("## Ответ менеджеру\nХорошо, отвечаю по-испански.\n## Память\nм2\n## Язык\n`spanish`.")];
|
||||
await handleManagerMessages({ ctx: ctx(), timezone: "America/New_York", slack, dryPublish: true }, mgr, msg("Please answer me in Spanish from now on", "1791742010.000001"));
|
||||
expect((await db.pool.query("select language from construction_manager where person_id = $1", [MGR])).rows[0].language).toBe("Spanish");
|
||||
expect((await db.pool.query("select language from construction_manager where person_id = $1", [OTHER])).rows[0].language).toBe("English");
|
||||
calls = [];
|
||||
script = [ok("## Ответ менеджеру\nOK\n## Память\nм3")];
|
||||
await handleManagerMessages({ ctx: ctx(), timezone: "America/New_York", slack, dryPublish: true }, mgr, msg("hola", "1791742020.000001"));
|
||||
expect(calls[0]!.prompt).toContain("Язык ответов владельцу агента (llmtest-Manager): Spanish");
|
||||
// системное событие язык не меняет, мусор в разделе игнорируется
|
||||
script = [ok("## Ответ менеджеру\nOK\n## Память\nм4\n## Язык\nFrench")];
|
||||
await handleManagerMessages({ ctx: ctx(), timezone: "America/New_York", slack, dryPublish: true }, mgr, [], { systemEvent: "12:00" });
|
||||
script = [ok("## Ответ менеджеру\nOK\n## Память\nм5\n## Язык\nпереключи на русский, пожалуйста, очень прошу тебя!!!")];
|
||||
await handleManagerMessages({ ctx: ctx(), timezone: "America/New_York", slack, dryPublish: true }, mgr, msg("x", "1791742030.000001"));
|
||||
expect((await db.pool.query("select language from construction_manager where person_id = $1", [MGR])).rows[0].language).toBe("Spanish");
|
||||
await db.pool.query("update construction_manager set language = 'English' where person_id = $1", [MGR]);
|
||||
await db.pool.query("delete from construction_manager where person_id = $1", [OTHER]);
|
||||
await db.pool.query("delete from person where id = $1", [OTHER]);
|
||||
});
|
||||
|
||||
it("API агентов: память читается и пишется с аудитом, сброс сессии, история", async () => {
|
||||
const app = buildApi({ pool: db.pool, token: "t", run: async () => { throw new Error("не нужен"); } });
|
||||
const h = { authorization: "Bearer t" };
|
||||
|
||||
Reference in New Issue
Block a user