Multiplayer agent harness for work.
Re-adopt a suggestions cron whose task was reverted to the standard instructions (#2564)
Regan Bell7fda25c64085
diff --git a/src/suggestions/activities.ts b/src/suggestions/activities.tsindex 4e3fce9d9..9620dbed8 100644--- a/src/suggestions/activities.ts+++ b/src/suggestions/activities.ts@@ -56,8 +56,9 @@ export function createSuggestedActivityService(deps: {const owned = (cron: Cron | null, principalId: string): cron is Cron =>!!cron && cron.owner === principalId && cron.ownerScopeId === scopeId("personal", principalId);+ const managedPrefix = `${SUGGESTED_ACTIVITIES_TASK}\n\nDeployment guidance:\n`;const actionFor = (seeds: SuggestedActivity[], dismissed: DismissedActivity[] = []) =>- `${SUGGESTED_ACTIVITIES_TASK}\n\nDeployment guidance:\n${deps.context ?? "No special deployment context."}\n\nFallback seed activities:\n${JSON.stringify(seeds)}${+ `${managedPrefix}${deps.context ?? "No special deployment context."}\n\nFallback seed activities:\n${JSON.stringify(seeds)}${dismissed.length? `\n\nThe owner dismissed these suggestions. Do not suggest them or close variants again:\n${JSON.stringify(dismissed.map((entry) => entry.title))}`: ""@@ -65,7 +66,8 @@ export function createSuggestedActivityService(deps: {const syncAction = async (cron: Cron, profile: SuggestedActivityProfile) => {const action = actionFor(profile.seeds ?? [], profile.dismissed);- if (cron.action !== profile.managedAction || action === cron.action) return;+ if (action === cron.action) return;+ if (cron.action !== profile.managedAction && !cron.action?.startsWith(managedPrefix)) return;await deps.crons.update(cron.id, { action });await deps.store.merge(cron.owner, { managedAction: action });};diff --git a/test/suggested-activities.test.ts b/test/suggested-activities.test.tsindex 103725d80..79a9317a8 100644--- a/test/suggested-activities.test.ts+++ b/test/suggested-activities.test.ts@@ -190,6 +190,25 @@ test("guidance updates managed task text while preserving user edits", async ()assert.equal((await f.crons.get(id))!.action, "My custom research task");});+test("a task edited and later reverted to the standard instructions is managed again", async () => {+ const f = fixture();+ await f.service.get("alice", []);+ await f.settle();+ const id = (await f.crons.list())[0]!.id;+ const standard = (await f.crons.get(id))!.action!;+ await f.crons.update(id, { action: "My custom research task" });+ const service = createSuggestedActivityService({ ...f.deps, context: "Changed guidance" });+ await service.get("alice", []);+ assert.equal((await f.crons.get(id))!.action, "My custom research task");+ await f.crons.update(id, { action: standard.replace("No special deployment context.", "Older guidance") });+ await service.get("alice", []);+ assert.match((await f.crons.get(id))!.action!, /Changed guidance/);+ await service.dismiss("alice", "brief");+ const action = (await f.crons.get(id))!.action!;+ assert.ok(action.includes(JSON.stringify(["Build my brief"])));+ assert.equal((await f.store.get("alice"))!.managedAction, action);+});+test("old valid results are returned while a newer refresh is running", async () => {const f = fixture();await f.service.get("alice", []);