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
6 changes: 3 additions & 3 deletions apps/server/src/guide/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Some agents lack a level; they run at the next safer one they have, and the comp

You add and remove agents at the top of the model button's panel in the composer: one pill per agent, the picked one being who your next message goes to (typing @ and picking an agent does the same). The model and effort under the pills are that agent's.

Only one agent works at a time, in the same checkout. Agents in a room can ask each other a question on the side, ask for an independent review of the changes, or hand the next turn to another agent. Up to three agents can answer on the side at once, one answer each, so you can ask a second agent while the first is still answering, and an agent can ask two or three for a review of the same changes in one go.
Only one agent works at a time, in the same checkout. Agents in a room can ask each other a question on the side, ask for an independent review of the changes, or hand the next turn to another agent. Up to three agents can answer on the side at once, one answer each, so you can ask a second agent while the first is still answering, and an agent can ask two or three for a review of the same changes in one go. Agents can ask and hand off to each other as often as the work needs, without you writing in between; Stop ends the back and forth.

Whether the thread's agent may bring in another model on its own is {place:threads.agentInvites}: Off, Ask me first (a card asks you each time), or Without asking. Bringing in another provider's model spends that provider's quota.`,
},
Expand All @@ -113,7 +113,7 @@ Once a thread it started has finished, the agent can wrap it up itself (thread_w

A thread that keeps working after its answer went back (a check-back woke it, or a reviewer it asked replied) doesn't wake the parent. Its latest reply is passed to the parent's agent at that agent's next turn, and the thread then wraps up by itself. A thread the agent stops with thread_stop wraps up by itself too.

{place:threads.agentThreads} decides this: Off, Ask me first (a card in the chat lists the threads and you decide), or Automatic. The same setting covers agents creating or changing scheduled tasks. An agent may start at most 5 threads and send 10 messages to them per message you send.
{place:threads.agentThreads} decides this: Off, Ask me first (a card in the chat lists the threads and you decide), or Automatic. The same setting covers agents creating or changing scheduled tasks. There's no limit on how many threads an agent starts or how many messages it sends them, so an agent can keep a team of threads going for hours without you writing. Stop on the parent stops its agent and its threads' answers coming back, but the threads keep working; "Stop N working threads" in the parent's menu stops them too.

A started thread works in a worktree of its own; in a project without git it shares the project's folder. With {place:threads.agentThreadsShareWorktrees} on, an agent can instead put a thread in a checkout that already exists: its own, or that of a thread it started. The new thread sees the files as they are there, uncommitted changes included, which suits a reviewer for work another thread just finished. An agent can also move an idle thread into such a checkout with a message, and the thread keeps its conversation. The thread the checkout belongs to must not be working at that moment. No worktree or branch is made and the project's setup script does not run. The two threads then share one set of files, so only one should work at a time. The thread's row under the message box reads Shared worktree. This works on one computer only, and not for threads an outside agent starts.

Expand Down Expand Up @@ -151,7 +151,7 @@ The lead's row sits at the top of the sidebar with a crown, says Lead where the

The Threads tab in the right sidebar shows the project's threads on every computer you can see, grouped as Needs you, Ready for review, Working, Landing, Idle and Done. Open it from the sidebar's list of panels or its + menu, on any thread of the project. A thread you wrapped up goes under Done (for 7 days, closed until you open it) unless its pull request is still open, which keeps it under Ready for review or Landing. Ready for review says what the pull request waits on, as the Pull requests page does. Click a row to open the thread, or right-click it for the thread's menu. The top line counts what needs you and what's working, with a Lead chat link when you're on another thread.

The lead's agent is told its role at the start of every turn, and when you give it a goal. It may start 10 threads and send 20 messages to them per message you send, instead of 5 and 10. It needs {place:threads.agentThreads} to be on, and an agent that can't use the thread tools says so. General chats, a thread another thread still owns, and threads from another computer or an outside agent can't be the lead.`,
The lead's agent is told its role at the start of every turn, and when you give it a goal. It needs {place:threads.agentThreads} to be on, and an agent that can't use the thread tools says so. General chats, a thread another thread still owns, and threads from another computer or an outside agent can't be the lead.`,
},
{
id: "linking-computers",
Expand Down
8 changes: 0 additions & 8 deletions apps/server/src/mcp/roomToolHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,6 @@ describe("room_ask", () => {
}),
outcome: "busy",
},
// The agents used their requests.
{
thread: makeThread({
agentRequests: { ...EMPTY_AGENT_REQUEST_STATE, requestsSinceUser: 3 },
}),
outcome: "limit",
},
// The user pressed Stop.
{
thread: makeThread({ agentRequests: { ...EMPTY_AGENT_REQUEST_STATE, hold: true } }),
Expand Down Expand Up @@ -846,7 +839,6 @@ describe("room_hand_off", () => {
makeThread({
agentRequests: {
...EMPTY_AGENT_REQUEST_STATE,
requestsSinceUser: 1,
open: [
{
requestId: submit!.requestId,
Expand Down
5 changes: 2 additions & 3 deletions apps/server/src/mcp/roomTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const RequestOutcome = Schema.Literals([
"stopped",
"timeout",
"busy",
"limit",
"refused",
]);

Expand Down Expand Up @@ -80,7 +79,7 @@ export const RoomAnswerResult = Schema.Struct({
export type RoomAnswerResult = typeof RoomAnswerResult.Type;

export const RoomHandOffResult = Schema.Struct({
outcome: Schema.Literals(["queued", "failed", "busy", "limit", "refused"]),
outcome: Schema.Literals(["queued", "failed", "busy", "refused"]),
detail: Schema.optional(Schema.String),
agent: Schema.optional(AgentLabel),
requestId: Schema.optional(Schema.String),
Expand Down Expand Up @@ -190,7 +189,7 @@ export const RoomInviteResult = Schema.Struct({
* (invites need no approval here). Either way its review comes back to you
* as a message (into your turn if you are still working), if it runs.
*/
outcome: Schema.Literals(["asked_user", "started", "failed", "busy", "limit", "refused"]),
outcome: Schema.Literals(["asked_user", "started", "failed", "busy", "refused"]),
detail: Schema.optional(Schema.String),
agent: Schema.optional(AgentLabel),
/** The reasoning level it reviews at, when the invite named one. */
Expand Down
20 changes: 0 additions & 20 deletions apps/server/src/mcp/threadToolHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ const makeTools = (options: {
childRequests: {
...caller.childRequests,
open: [...caller.childRequests.open, ...open],
startsSinceUser: caller.childRequests.startsSinceUser + open.length,
},
};
}
Expand Down Expand Up @@ -475,25 +474,6 @@ describe("thread_start", () => {
}),
);

it.effect("refuses past the per-message limit, counting what was already asked", () =>
Effect.gen(function* () {
const tools = yield* makeTools({
caller: makeThread({
childRequests: { ...EMPTY_CHILD_REQUEST_STATE, startsSinceUser: 4 },
}),
});
const result = yield* tools.handlers.thread_start(mainCaller(), {
threads: [
{ title: "One", prompt: "First." },
{ title: "Two", prompt: "Second." },
],
});

expect(result.outcome).toBe("limit");
expect(tools.dispatched).toHaveLength(0);
}),
);

it.effect("refuses agents billed per use or unable to plan when the caller plans", () =>
Effect.gen(function* () {
const tools = yield* makeTools({ caller: makeThread({ interactionMode: "plan" }) });
Expand Down
15 changes: 2 additions & 13 deletions apps/server/src/mcp/threadToolHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,6 @@ export function makeThreadToolHandlers(deps: ThreadToolDeps) {
from: from(scope),
callerTurnId,
count: specs.length,
isLead: yield* isLeadThread(current),
});
if (refusal !== null) {
return ruleOutcome(refusal) satisfies ThreadStartResult;
Expand Down Expand Up @@ -1340,7 +1339,6 @@ export function makeThreadToolHandlers(deps: ThreadToolDeps) {
from: from(scope),
callerTurnId,
count: specs.length,
isLead: yield* isLeadThread(current),
});
if (refusal !== null) {
return ruleOutcome(refusal) satisfies ThreadStartResult;
Expand Down Expand Up @@ -1856,16 +1854,11 @@ export function makeThreadToolHandlers(deps: ThreadToolDeps) {
const refusal = childSendRefusal(caller, child ?? null, {
from: from(scope),
callerTurnId,
isLead: yield* isLeadThread(caller),
});
if (refusal !== null) {
return {
outcome:
refusal.outcome === "not_allowed"
? ("not_yours" as const)
: refusal.outcome === "limit"
? ("limit" as const)
: ("refused" as const),
refusal.outcome === "not_allowed" ? ("not_yours" as const) : ("refused" as const),
detail: refusal.detail,
} satisfies ThreadSendResult;
}
Expand Down Expand Up @@ -1996,11 +1989,7 @@ export function makeThreadToolHandlers(deps: ThreadToolDeps) {
if (refusal !== null || target === undefined) {
return {
outcome:
refusal?.outcome === "limit"
? ("limit" as const)
: refusal?.outcome === "not_allowed"
? ("not_yours" as const)
: ("refused" as const),
refusal?.outcome === "not_allowed" ? ("not_yours" as const) : ("refused" as const),
detail: refusal?.detail ?? NOT_FOUND,
threadId: targetId,
} satisfies ThreadSendResult;
Expand Down
8 changes: 1 addition & 7 deletions apps/server/src/mcp/threadTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ import {
AgentThreadReadResult,
AgentThreadStatusWord,
AgentThreadSummary,
CHILD_THREAD_SEND_LIMIT,
CHILD_THREAD_START_LIMIT,
CHILD_THREADS_PER_CALL,
RuntimeMode,
} from "@threadlines/contracts";
import { LEAD_THREAD_SEND_LIMIT, LEAD_THREAD_START_LIMIT } from "@threadlines/shared/childThreads";
import * as Schema from "effect/Schema";
import { Tool, Toolkit } from "effect/ai";
import { loadedOnDemand } from "./toolLoading.ts";
Expand Down Expand Up @@ -86,7 +83,6 @@ export const ThreadStartResult = Schema.Struct({
"started",
"asked_user",
"off",
"limit",
"not_allowed",
"unavailable_agent",
"refused",
Expand Down Expand Up @@ -136,7 +132,6 @@ export const ThreadSendResult = Schema.Struct({
"sent",
"queued",
"not_yours",
"limit",
"off",
"not_allowed",
"refused",
Expand Down Expand Up @@ -268,7 +263,7 @@ export const ThreadStartTool = loadedOnDemand(
Tool.make("thread_start", {
description:
"Start new threads in this project to work in parallel. Each gets its own agent session and its own git worktree off your current commit (in a project without git they share the project folder). Give each a short `title` and a self-contained `prompt`: the new thread sees none of this conversation, only its prompt. `agent` picks a model from thread_agents; leave it out to use your own model and reasoning. Unless the user asked for a model or reasoning, prefer your own model or one already in this room (thread_agents' `room`), here or on another computer: a thread on a room agent's model runs at the reasoning the user set for that agent. `agent.reasoning` sets a level instead. Threads get your current access and interaction modes, never more; `access` asks for less. `runSetup: false` skips the project's setup script, for quick research. `checkout` puts a thread in a checkout that already exists instead of a new worktree, so it sees the files as they are there, uncommitted changes included (a reviewer for work another thread just finished): no worktree or branch is made and the setup script is not run. It shares that folder with the thread it belongs to, so have only one of them work at a time. `computer` starts them on another linked computer (a name or id from thread_agents' `computers`) in its copy of this project: from your branch when you pushed it, otherwise from that computer's default branch, without your unpushed changes. With `reportBack` (default true) each thread's final reply comes back to you as a message when it finishes; with false they run on their own and nothing comes back. Returns as soon as they are recorded and does not wait for them, so don't poll: carry on, or end your turn if you have nothing else to do. " +
`At most ${CHILD_THREADS_PER_CALL} threads per call and ${CHILD_THREAD_START_LIMIT} per user message (${LEAD_THREAD_START_LIMIT} in the project's lead chat).`,
`At most ${CHILD_THREADS_PER_CALL} threads per call; make more calls for more.`,
parameters: Schema.Struct({
threads: Schema.Array(
Schema.Struct({
Expand Down Expand Up @@ -351,7 +346,6 @@ export const ThreadSendTool = loadedOnDemand(
Tool.make("thread_send", {
description:
"Send one of your threads a message: more work, a correction or a question. If it is idle it starts on it now; if it is busy it takes it after its current turn. Its reply comes back to you as a message, like a start. Only threads you started whose replies still come back to you. `checkout` first moves an idle thread into another thread's checkout, keeping its conversation, so it reads your message there (a thread that planned the work looks at what another thread built). The project's lead chat may also pass a message to an open thread in this project that it did not start (not a room, not one another thread owns, not one the user stopped): it works on it there, and nothing comes back. " +
`At most ${CHILD_THREAD_SEND_LIMIT} messages per user message (${LEAD_THREAD_SEND_LIMIT} in the project's lead chat). ` +
"Don't poll; end your turn if you have nothing else to do.",
parameters: Schema.Struct({
threadId: ThreadIdParameter,
Expand Down
9 changes: 2 additions & 7 deletions apps/server/src/orchestration/agentRequestDecisions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,19 +1051,14 @@ export function decideAgentChainStop(
];
}

/** The user wrote: the hold comes off, invites resume and the agents' count starts over. */
/** The user wrote: the hold comes off and invites resume. */
export function resetAgentRequestsForUser(
thread: OrchestrationThread,
base: EventBase,
createdAt: string,
): ReadonlyArray<PlannedEvent> {
const state = thread.agentRequests;
if (
!state.hold &&
state.requestsSinceUser === 0 &&
!state.invitesPaused &&
state.batchesSinceUser.length === 0
) {
if (!state.hold && !state.invitesPaused) {
return [];
}
return [
Expand Down
13 changes: 2 additions & 11 deletions apps/server/src/orchestration/childThreadDecisions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ export function decideChildStart(
from: command.from,
callerTurnId: command.callerTurnId,
count: command.children.length,
isLead: isProjectLeadThread(readModel, parent),
});
if (refusal !== null) {
return refuse(refusal.detail);
Expand Down Expand Up @@ -570,13 +569,7 @@ export function decideChildSend(
): ChildThreadDecision {
const remoteChild = remoteChildOf(parent.childRequests, command.childThreadId);
if (remoteChild !== undefined) {
return decideRemoteChildSend(
parent,
command,
baseFor,
remoteChild,
isProjectLeadThread(readModel, parent),
);
return decideRemoteChildSend(parent, command, baseFor, remoteChild);
}
if (pendingChildRequest(parent, command.childThreadId) !== undefined) {
return refuse("That thread is still being set up. Send it a message once it has started.");
Expand All @@ -585,7 +578,6 @@ export function decideChildSend(
const refusal = childSendRefusal(parent, child, {
from: command.from,
callerTurnId: command.callerTurnId,
isLead: isProjectLeadThread(readModel, parent),
});
if (refusal !== null || child === null) {
return refuse(refusal?.detail ?? "That thread is gone.");
Expand Down Expand Up @@ -815,7 +807,6 @@ function decideRemoteChildSend(
command: CommandOf<"thread.child.send">,
baseFor: ChildEventBase,
remoteChild: NonNullable<ReturnType<typeof remoteChildOf>>,
isLead: boolean,
): ChildThreadDecision {
const refusal = childSendRefusal(
parent,
Expand All @@ -825,7 +816,7 @@ function decideRemoteChildSend(
attachedToParent: true,
archivedAt: null,
},
{ from: command.from, callerTurnId: command.callerTurnId, isLead },
{ from: command.from, callerTurnId: command.callerTurnId },
);
if (refusal !== null) {
return refuse(refusal.detail);
Expand Down
1 change: 0 additions & 1 deletion apps/server/src/orchestration/decider.projectLead.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ describe("lead chat passes", () => {
const lead = threadIn(passed.model, LEAD);
const target = threadIn(passed.model, OTHER);
expect(lead.childRequests.open).toEqual([]);
expect(lead.childRequests.sendsSinceUser).toBe(1);
const message = target.messages.find((entry) => entry.id === PASS_MESSAGE);
expect(message?.fromThread).toMatchObject({
threadId: LEAD,
Expand Down
Loading
Loading