Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions apps/server/src/kin/lead/LeadPrompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,7 @@ it.effect(
WHERE chat_id = ${chatId}`;
yield* sql`UPDATE kin_leads SET domain = 'chief-of-staff' WHERE agent_id = ${agentId}`;
const prompt = yield* KinLeadPrompt;
const keys: PromptFingerprint[] = [];
const say = Effect.fn("test.say")(function* (id: string, clientMessageId: string) {
yield* repo.insertMessage({
audience: "chat",
Expand Down Expand Up @@ -1677,8 +1678,9 @@ it.effect(
provenance: { _tag: "human", personId, memberId },
});
yield* stored(`wake-${id}`, [said]);
return prompt.build({
return prompt.buildSession({
...input,
observePrompt: (fingerprint) => keys.push(fingerprint),
wakeupId: KinWakeupId.make(`wake-${id}`),
lane: { chatId, mode: "reply" },
events: [said],
Expand All @@ -1687,7 +1689,14 @@ it.effect(
const guidance = `${PROMPT_HEADINGS.setUp}\n\n${CHIEF_OF_STAFF_SET_UP}`;
// The owner's first word to the company's first agent gets it.
const hello = yield* say("hello", "c-1");
expect(yield* hello).toContain(guidance);
const first = yield* hello;
expect(first.full).toContain(guidance);
const firstKey = keys.at(-1)?.standing;
const later = yield* yield* say("later", "c-2");
expect(later.full).not.toContain(PROMPT_HEADINGS.setUp);
expect(later.full).not.toContain(CHIEF_OF_STAFF_SET_UP);
expect(keys.at(-1)?.standing).toBe(firstKey);

// Not where another agent came first: an older company's new Chief of staff.
yield* repo.insertAgent({
orgId,
Expand All @@ -1697,16 +1706,15 @@ it.effect(
ownerPersonId: personId,
createdAt: "1969-12-31T00:00:00.000Z",
});
expect(yield* hello).not.toContain(PROMPT_HEADINGS.setUp);
expect((yield* hello).full).not.toContain(PROMPT_HEADINGS.setUp);
yield* sql`UPDATE kin_agents SET created_at = '2999-01-01T00:00:00.000Z'
WHERE agent_id = 'older-lead'`;
// Nothing after the first word does, so a company that talks to it reads what it read.
const later = yield* yield* say("later", "c-2");
expect(later).not.toContain(PROMPT_HEADINGS.setUp);
expect(later).not.toContain(CHIEF_OF_STAFF_SET_UP);
// Set up… does, whenever it is sent; another seat never reads it.
const pressed = yield* say("pressed", `${KIN_SET_UP_MESSAGE_PREFIX}c-3`);
expect(yield* pressed).toContain(guidance);
const pressedTurn = yield* pressed;
expect(pressedTurn.full).toContain(guidance);
expect(pressedTurn.message).toContain(guidance);
expect(keys.at(-1)?.standing).toBe(firstKey);
yield* sql`UPDATE kin_leads SET domain = 'finance' WHERE agent_id = ${agentId}`;
expect(yield* pressed).not.toContain(PROMPT_HEADINGS.setUp);
}).pipe(Effect.provide(layer)),
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/kin/lead/LeadPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const promptSectionPlaces = {
playbooks: "standing",
thisCompany: "standing",
whatWeSell: "standing",
setUp: "standing",
setUp: "message",
checkIns: "checkIns",
work: "work",
started: "message",
Expand Down Expand Up @@ -2982,7 +2982,7 @@ export class KinLeadPrompt extends Context.Service<
: setUp
? [
ownerPart(promptSectionPlaces.setUp, PROMPT_HEADINGS.setUp),
ownerPart("standing", CHIEF_OF_STAFF_SET_UP),
ownerPart("message", CHIEF_OF_STAFF_SET_UP),
]
: []),
...(checkIns.length === 0
Expand Down
Loading