Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .changeset/a-worker-knows-who-it-is.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"@flow-state-dev/workforce": minor
---

The built-in `agent` worker flow now opens every roster worker's system prompt with who it is: its name (its `WORKER.md` `name:`, else its id's worker segment), its team, its role (its `description`), the teammates it can message by id, and any task-only workers to file a task with. One rule on using tools follows. The team's, the worker's own and its packages' instructions come after, unchanged. Off an installation the layer is absent. `RosterWorker` gains `name` and `teamName`; `workerRecipients`, `rosterDisplayName` and `rosterTeamName` are exported from the package root, and `sendMessage`'s recipient list reads the same `workerRecipients` (FIX-2334).
The built-in `agent` worker flow now opens every roster worker's system prompt with who it is: its name (its `WORKER.md` `name:`, else its id's worker segment), its team, its role (its `description`), the teammates it can message by id (a teammate that is also its delegate marked as one that takes its tasks, with a line that work for a delegate goes as a task), and any task-only workers to file a task with. One rule on using tools follows. The team's, the worker's own and its packages' instructions come after, unchanged. Off an installation the layer is absent. `RosterWorker` gains `name` and `teamName`; `workerRecipients`, `rosterDisplayName` and `rosterTeamName` are exported from the package root, and `sendMessage`'s recipient list reads the same `workerRecipients` (FIX-2334).
5 changes: 3 additions & 2 deletions docs/architecture/workforce-default-worker-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ Generator slots stay `prompt` / `context` / `history` / `user`. Instructions com
first, then the worker's team, then the worker's own, then the instructions of the packages it holds
(joined by a blank line, its own packages first), with absent layers dropped rather than joined as
blanks. The default layer is the worker's identity, read from the roster each request (its
name, team and `description`, the workers a message reaches and the task-only ones), then one
rule on using tools. It is present on an installation only; off one there is no roster, and the
name, team and `description`, the workers a message reaches and the task-only ones, with each
messageable delegate marked as one that takes the worker's tasks and a line that work for a
delegate goes as a task), then one rule on using tools. It is present on an installation only; off one there is no roster, and the
entry is absent (FIX-2334).

**What that order buys, and what it does not.** The position is fixed and checkable: a worker's own
Expand Down
4 changes: 4 additions & 0 deletions goals/claude-code-style-lab/session-mode-script/goal.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ task settles), through the AI Gateway. Claude Code needs `ANTHROPIC_API_KEY`.
| 2026-10-28 | d86b248 tree, pre-commit | openai/gpt-5.4 | FAIL (control `no-project`) | Signal 0 (header reads *no project*) and signal 6 (no run cloned anything); the composer stayed closed and asked once; lab checkout untouched |
| 2026-10-28 | d86b248 tree, pre-commit | — | FAIL (control `planted-glue`) | `inventory: other: src/glue.ts is not config, UI, a small flow, a check or a fixture` |
| 2026-10-28 | e2cdf9a | openai/gpt-5.4 | PASS | Rerun after the review fixes (phase `code`, harness read through `resolveWorker`, graded retries): attempt 1 of 3, 110 polls, 2 task rows, 6 harness entries, the change on the run's branch in the clone |
| 2026-10-30 | 863a0e13 | openai/gpt-5.4 | FAIL | Closure re-run (FIX-2156), 0 of 6 attempts over two runs gradable: the main session sent its two research pieces to `desk.researcher` with `sendMessage` (`workforceMessagesSent: 2`) and filed no task, so `listTasks` read 0 rows. Same run with FIX-2334's default layer patched out: PASS on attempt 1 |
| 2026-10-30 | 863a0e13 | openai/gpt-5.4 | FAIL (control `answer-again-off`) | Same 0-task retry as the green run; the control graded nothing on main |
| 2026-10-30 | 863a0e13 + layer fix | openai/gpt-5.4 | PASS | Attempt 1 of 3, twice. The default layer marks a messageable delegate as taking tasks and says work for one goes as a task; 2 tasks, the card inside the first `respond`, 6 harness entries |
| 2026-10-30 | 863a0e13 + layer fix | openai/gpt-5.4 | FAIL (control `answer-again-off`) | Signal 4 only: a task settled while the first turn ran and no card showed inside it |
4 changes: 4 additions & 0 deletions goals/teammates-lab/a-worker-knows-who-it-is/goal.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ Each leg passes in 3 runs of 3 (`GOAL_RUNS`, default 3).
|------|--------|-------|---------|-------|
| 2026-10-30 | (this PR) | openai/gpt-5.4-mini | PASS 3/3 | Every worker named itself in all runs; leg 2 named both teammates with no tool call. An earlier wording failed 1 of 3 on leg 2 (`listDelegates`); the teammates list now says to answer from it. |
| 2026-10-30 | (this PR) | openai/gpt-5.4-mini | control `no-identity`: FAIL as required | All three workers answered as "your team assistant" / "your AI assistant"; leg 2 called `listDelegates`. |
| 2026-10-30 | 863a0e13 | openai/gpt-6-luna | FAIL | Closure re-run (FIX-2156) on the lab's new default model: leg 1 passed 3/3; leg 2 called `listDelegates` 3/3. On `TEAMMATES_MODEL=openai/gpt-5.4-mini`, leg 2 failed 1/3 |
| 2026-10-30 | 863a0e13 | openai/gpt-6-luna | control `no-identity`: FAIL as required | Leg 1 unnamed / "ChatGPT" answers |
| 2026-10-30 | 863a0e13 + layer fix | openai/gpt-6-luna | PASS 5/5 | The teammates list says it is current, so no tool call is needed; every worker named itself; leg 2 named both with no tool call |
| 2026-10-30 | 863a0e13 + layer fix | openai/gpt-6-luna | control `no-identity`: FAIL as required | Leg 1 unnamed in every run, "ChatGPT" in run 2; leg 2 called `listDelegates` |
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ Steps 2 and 3 have no isolating red state for Chief of Staff's side: without Chi
| 2026-10-29 | dd5f323+ | openai/gpt-5.4-mini, Claude Code | PASS | lead asks researcher with `replyRequested` (FIX-2310); researcher answers in place and the answer comes back. Typo "mesage"; date 8 July; one worktree, README.md only |
| 2026-10-29 | dd5f323+ | openai/gpt-5.4-mini | FAIL (expected) | `no-reply-back`: only [3] "no reply From researcher within 240s" |
| 2026-10-29 | e045c07+ | openai/gpt-5.4-mini, Claude Code | PASS | Steps 1 to 5 after merging Chief of Staff (FIX-2336) and no projects (FIX-2335), with `replyRequested`. Step 4: "crimson heron 452" and 26 December above "Earlier turns summarized". Typo "mesage" |
| 2026-10-30 | 863a0e13 | openai/gpt-6-luna, Claude Code | FAIL | Closure re-run (FIX-2156). First run: steps 1 to 4 passed; [5] Claude Code had no key in the lab (setup). Run with the key: [5] only, the page "mentions a project": Chief of Staff's own message to researcher said "the current project" (wording, not a project shown) |
| 2026-10-30 | 863a0e13 | openai/gpt-6-luna | FAIL (expected) | `no-reply-back`: [3] no reply From researcher within 240s; [5] also red, on the missing key |
| 2026-10-30 | 863a0e13 + layer fix | openai/gpt-6-luna, Claude Code | PASS | Steps 1 to 5. Step 4: "violet falcon 452" and 12 February above "Earlier turns summarized"; typo "mesages" fixed in one worktree |
25 changes: 18 additions & 7 deletions packages/workforce/src/messages/worker-identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ const MAX_DESCRIPTION = 160;
export const TOOL_USE_RULE =
"Use your tools to do what you're asked before you answer. Don't offer to do something you can do now: do it.";

/** Marks a teammate that is also the worker's delegate. */
export const DELEGATE_MARK = "(your delegate: takes your tasks too)";
Comment thread
jhoffner marked this conversation as resolved.
Resolved

/** How a worker splits a delegate's work between a message and a task. */
export const DELEGATE_RULE =
"A message to a delegate is for a quick question. A piece of work for one, or anything to run in the background, goes as a task: createTask, its id as the assignee.";

const oneLine = (text: string | null): string => {
const flat = (text ?? "").replace(/\s+/g, " ").trim();
return flat.length > MAX_DESCRIPTION ? `${flat.slice(0, MAX_DESCRIPTION - 1)}…` : flat;
Expand All @@ -44,22 +51,26 @@ export async function workerIdentityPrompt(ctx: BlockContext, installation: Work
`When someone asks who you are, answer as ${name}, with this role. Your worker id, ${me.id}, is the address others reach you by, not your name.`
];

// Only a worker's delegates take its tasks (the board checks an assignee
// against them), so only they are named as ones to file a task with.
// `createTask` unsuffixed: Workforce's conversation board mounts the task
// tools with no `nameSuffix`, so a worker on this flow always sees that name.
const delegates = me.delegates;
const isDelegate = (worker: (typeof taskOnly)[number]) => delegates === "all" || delegates.includes(worker.id);
Comment thread
jhoffner marked this conversation as resolved.
Resolved
const entry = (worker: (typeof messageable)[number]) => {
const description = oneLine(worker.description);
return `- ${rosterDisplayName(worker)} (${worker.id})${description === "" ? "" : `: ${description}`}`;
};
// A messageable delegate takes tasks too. Listed only as one to message, it
// gets whole pieces of work as messages, which no board row tracks.
const teammate = (worker: (typeof messageable)[number]) => (isDelegate(worker) ? `${entry(worker)} ${DELEGATE_MARK}` : entry(worker));
Comment thread
jhoffner marked this conversation as resolved.
Resolved
Comment thread
jhoffner marked this conversation as resolved.
Resolved
lines.push(
"",
messageable.length === 0
? "No other worker on your roster can be messaged now."
: `Your teammates, read from your roster this turn (asked who they are, answer from this list), whom you can message with ${SEND_MESSAGE_TOOL} by id:\n${messageable.map(entry).join("\n")}`
: `Your teammates, read from your roster this turn (asked who your teammates or delegates are, answer from this list: it is current, so no tool call is needed), whom you can message with ${SEND_MESSAGE_TOOL} by id:\n${messageable.map(teammate).join("\n")}`
Comment thread
jhoffner marked this conversation as resolved.
Resolved
Comment thread
jhoffner marked this conversation as resolved.
Resolved
);
// Only a worker's delegates take its tasks (the board checks an assignee
// against them), so only they are named as ones to file a task with.
// `createTask` unsuffixed: Workforce's conversation board mounts the task
// tools with no `nameSuffix`, so a worker on this flow always sees that name.
const delegates = me.delegates;
const isDelegate = (worker: (typeof taskOnly)[number]) => delegates === "all" || delegates.includes(worker.id);
if (messageable.some(isDelegate)) lines.push("", DELEGATE_RULE);
Comment thread
jhoffner marked this conversation as resolved.
Resolved
const fileable = taskOnly.filter(isDelegate);
const others = taskOnly.filter((worker) => !isDelegate(worker));
if (fileable.length > 0) {
Expand Down
37 changes: 34 additions & 3 deletions packages/workforce/test/worker-identity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { mockGenerator, type MockGeneratorInstance } from "@flow-state-dev/testi
import type { WorkerManifest } from "../src";
import { rosterDisplayName, rosterTeamName, workerRecipients } from "../src/messages/recipients";
import type { RosterWorker, WorkerInstallation } from "../src/workers/installation";
import { TOOL_USE_RULE } from "../src/messages/worker-identity";
import { DELEGATE_MARK, DELEGATE_RULE, TOOL_USE_RULE } from "../src/messages/worker-identity";
import { bootBoardHost, type BoardHost } from "./conversation-board-harness";

const worker = (id: string, declared: Record<string, unknown>, body = "", teamName?: string): WorkerManifest => ({
Expand All @@ -25,9 +25,10 @@ const worker = (id: string, declared: Record<string, unknown>, body = "", teamNa
});

const roster = (): WorkerManifest[] => [
worker("eng.ana", { name: "Ana", description: "Runs the team's work with you.", delegates: ["eng.tasker"] }, "Ana's own instructions.", "Engineering"),
worker("eng.ana", { name: "Ana", description: "Runs the team's work with you.", delegates: ["eng.tasker", "eng.cy"] }, "Ana's own instructions.", "Engineering"),
worker("eng.bo", { description: "Knows colours." }, "You help.", "Engineering"),
worker("eng.tasker", { flow: "tasker", description: "Does tasks." }, "", "Engineering")
worker("eng.tasker", { flow: "tasker", description: "Does tasks." }, "", "Engineering"),
worker("eng.cy", { description: "Researches." }, "You research.", "Engineering")
];

/** The system message of each model call the agent turn made, in order. */
Expand Down Expand Up @@ -96,6 +97,36 @@ describe("what a worker is told first", () => {
}
});

// A delegate listed only as someone to message got whole pieces of work as
// messages: the Claude Code-style lab's main session filed no task, so no
// row showed and nothing could be stopped or reviewed.
it("marks a teammate that is also its delegate as one that takes its tasks, and says work goes as a task", async () => {
const agentAnswer = mockGenerator({ script: [{ when: () => true, then: { text: "Hi." } }] });
const h = bootBoardHost({ standard: roster(), agentAnswer, judgment: mockGenerator({ script: [{ when: () => true, then: { text: "" } }] }) });
try {
await turnOf(h, "eng.ana");
const [teammates] = systemsOf(agentAnswer)[0]!.split("Workers that take tasks only");
expect(teammates).toContain(`- cy (eng.cy): Researches. ${DELEGATE_MARK}`);
expect(teammates).toContain("- bo (eng.bo): Knows colours.\n");
Comment thread
jhoffner marked this conversation as resolved.
Resolved
expect(teammates).toContain(DELEGATE_RULE);
} finally {
await h.dispose();
}
});

it("gives a worker with no messageable delegate no delegate rule", async () => {
const agentAnswer = mockGenerator({ script: [{ when: () => true, then: { text: "Hi." } }] });
const h = bootBoardHost({ standard: roster(), agentAnswer, judgment: mockGenerator({ script: [{ when: () => true, then: { text: "" } }] }) });
try {
await turnOf(h, "eng.bo");
const system = systemsOf(agentAnswer)[0]!;
expect(system).not.toContain(DELEGATE_MARK);
expect(system).not.toContain(DELEGATE_RULE);
} finally {
await h.dispose();
}
});

it("names a worker with no name: by its id's worker segment", async () => {
const agentAnswer = mockGenerator({ script: [{ when: () => true, then: { text: "Hi." } }] });
const h = bootBoardHost({ standard: roster(), agentAnswer, judgment: mockGenerator({ script: [{ when: () => true, then: { text: "" } }] }) });
Expand Down
Loading