Compel agents to keep acting until they explicitly finish
Forcing only the opening turn let a weak model take one token action and stop, so a kickoff hired one agent (or none) and went quiet. Now every turn is forced (tool_choice required) and the agent ends only by calling the new `finish` tool — so it must keep hiring, delegating, and messaging until the work is actually done. Finishing with zero actions, or returning no tool call at all, fails the run loudly instead of faking success. Prompts tell each agent it must call a tool every turn and finish only when done. Tests drive weak-model stubs that act then finish, proving a full team forms rather than a single gesture. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ef9ee463c9
commit
f7543e506d
7 files changed
+72
-50
No files matched your search
@@ -37,7 +37,7 @@ function scriptedTeam(): (input: ProviderToolTurnInput) => Promise<AgentTurnResu
|
||||
call("create_task", { title: "Build the booking API", description: "Ship the booking API.", assignee_agent_name: "Dana Lee" }),
|
||||
call("send_message", { channel: "engineering", body: `@${handle} you own the booking API — kicking off here.` }),
|
||||
] },
|
||||
{ text: "Kickoff complete.", toolCalls: [] },
|
||||
{ text: "Kickoff complete.", toolCalls: [call("finish", {})] },
|
||||
];
|
||||
return async (input: ProviderToolTurnInput): Promise<AgentTurnResult> => {
|
||||
if ((input.instructions ?? "").includes("Dana Lee")) {
|
||||
@@ -46,11 +46,11 @@ function scriptedTeam(): (input: ProviderToolTurnInput) => Promise<AgentTurnResu
|
||||
const threadId = firstUser ? /thread_id="([^"]+)"/.exec(firstUser.text)?.[1] : undefined;
|
||||
const turn = dana === 0
|
||||
? { text: "On it.", toolCalls: [call("send_message", { channel: "engineering", body: "On it — booking API design starting now.", ...(threadId ? { thread_id: threadId } : {}) })] }
|
||||
: { text: "Replied.", toolCalls: [] };
|
||||
: { text: "Replied.", toolCalls: [call("finish", {})] };
|
||||
dana += 1;
|
||||
return { text: turn.text, toolCalls: turn.toolCalls, rawResponseJson: "{}" };
|
||||
}
|
||||
const turn = ceoScript[ceo] ?? { text: "done", toolCalls: [] };
|
||||
const turn = ceoScript[ceo] ?? { text: "done", toolCalls: [call("finish", {})] };
|
||||
ceo += 1;
|
||||
return { text: turn.text, toolCalls: turn.toolCalls, rawResponseJson: "{}" };
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ function scriptedCeo(): (input: ProviderToolTurnInput) => Promise<AgentTurnResul
|
||||
call("write_deliverable", { path: "plan/operating-plan.md", content: "# OrbitOps Operating Plan\n\n- Validate demand\n- Launch booking site\n" }),
|
||||
] },
|
||||
{ text: "Handing off the plan.", toolCalls: [] },
|
||||
{ text: "Team staffed, work delegated, plan written.", toolCalls: [] },
|
||||
{ text: "Team staffed, work delegated, plan written.", toolCalls: [call("finish", {})] },
|
||||
];
|
||||
let index = 0;
|
||||
return async (input) => {
|
||||
@@ -55,7 +55,7 @@ function scriptedCeo(): (input: ProviderToolTurnInput) => Promise<AgentTurnResul
|
||||
rawResponseJson: JSON.stringify({ id: `resp_${index}` }),
|
||||
};
|
||||
}
|
||||
const turn = script[index] ?? { text: "done", toolCalls: [] };
|
||||
const turn = script[index] ?? { text: "done", toolCalls: [call("finish", {})] };
|
||||
index += 1;
|
||||
return { text: turn.text, toolCalls: turn.toolCalls, rawResponseJson: JSON.stringify({ id: `resp_${index}` }) };
|
||||
};
|
||||
@@ -169,14 +169,13 @@ describe("autonomous bootstrap run", () => {
|
||||
// The forced opening turn means each run must take a concrete action; it
|
||||
// posts to the company channel, then stops on the next (free) turn.
|
||||
const providers = new ProviderService(connection.db, providerAdapters, testVault, undefined, async (input) => {
|
||||
if (input.toolChoice === "required") {
|
||||
return {
|
||||
text: "Reviewing the goal.",
|
||||
toolCalls: [call("send_message", { channel: "general", body: "Reviewed the goal and posting the operating plan." })],
|
||||
rawResponseJson: JSON.stringify({ id: "resp_goal_act" }),
|
||||
};
|
||||
}
|
||||
return { text: "Done.", toolCalls: [], rawResponseJson: JSON.stringify({ id: "resp_goal_done" }) };
|
||||
const acted = input.messages.some((message) => message.role === "tool");
|
||||
if (acted) return { text: "Done.", toolCalls: [call("finish", {})], rawResponseJson: JSON.stringify({ id: "resp_goal_done" }) };
|
||||
return {
|
||||
text: "Reviewing the goal.",
|
||||
toolCalls: [call("send_message", { channel: "general", body: "Reviewed the goal and posting the operating plan." })],
|
||||
rawResponseJson: JSON.stringify({ id: "resp_goal_act" }),
|
||||
};
|
||||
});
|
||||
const onboarding = new OnboardingService({ db: connection.db, saveProviderCredential: (input) => providers.saveCredential(input) });
|
||||
const organization = new OrganizationService(connection.db);
|
||||
|
||||
Reference in new issue
Block a user