clanka 0.22.5 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "clanka",
3
3
  "type": "module",
4
- "version": "0.22.5",
4
+ "version": "0.23.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
package/src/Acp.test.ts CHANGED
@@ -646,7 +646,7 @@ describe("Acp", () => {
646
646
  ),
647
647
  )
648
648
 
649
- it.effect("reports subagents with a delegate prompt preview", () =>
649
+ it.effect("reports subagents with a subagent prompt preview", () =>
650
650
  withStore(
651
651
  Effect.scoped(
652
652
  Effect.gen(function* () {
@@ -661,14 +661,14 @@ describe("Acp", () => {
661
661
  type: "tool-call",
662
662
  id: "call-1",
663
663
  name: "execute",
664
- params: { script: "await delegate()" },
664
+ params: { script: "await subagent()" },
665
665
  })
666
666
  : assistantSays(summary),
667
667
  {
668
668
  ...executor,
669
669
  execute: ({ agentTasks, environment }) =>
670
670
  Stream.fromEffect(
671
- agentTasks.delegate({
671
+ agentTasks.subagent({
672
672
  id: "1",
673
673
  prompt,
674
674
  background: false,
@@ -706,13 +706,13 @@ describe("Acp", () => {
706
706
  assert.strictEqual(tools[1].sessionUpdate, "tool_call_update")
707
707
  assert.strictEqual(tools[1].toolCallId, tools[0].toolCallId)
708
708
  assert.strictEqual(tools[1].status, "completed")
709
- assert.match(tools[0].title, /^delegate: Inspect the repository/)
709
+ assert.match(tools[0].title, /^subagent: Inspect the repository/)
710
710
  assert.notMatch(tools[0].title, /[\r\n]/)
711
711
  assert.strictEqual(
712
712
  tools[0].title,
713
- "delegate: " + prompt.replace(/\s+/g, " ").slice(0, 120),
713
+ "subagent: " + prompt.replace(/\s+/g, " ").slice(0, 120),
714
714
  )
715
- assert.strictEqual(tools[0].title.length, "delegate: ".length + 120)
715
+ assert.strictEqual(tools[0].title.length, "subagent: ".length + 120)
716
716
  assert.deepStrictEqual(tools[1].content, [
717
717
  { type: "content", content: { type: "text", text: summary } },
718
718
  ])
@@ -763,7 +763,7 @@ describe("Acp", () => {
763
763
  Stream.fromEffect(
764
764
  executions++ === 0
765
765
  ? agentTasks
766
- .delegate({
766
+ .subagent({
767
767
  id: "1",
768
768
  prompt: "TASK-CHILD",
769
769
  background: true,
package/src/Acp.ts CHANGED
@@ -934,7 +934,7 @@ export const make = Effect.fnUntraced(function* <RAgent, RModel>(
934
934
  return update(session.id, {
935
935
  sessionUpdate: announced ? "tool_call_update" : "tool_call",
936
936
  toolCallId: `subagent-${part.id}`,
937
- title: `delegate: ${part.prompt.replace(/\s+/g, " ").trim().slice(0, 120)}`,
937
+ title: `subagent: ${part.prompt.replace(/\s+/g, " ").trim().slice(0, 120)}`,
938
938
  kind: "think",
939
939
  status: "in_progress",
940
940
  rawInput: { prompt: part.prompt },
package/src/Agent.test.ts CHANGED
@@ -180,7 +180,7 @@ describe("Agent", () => {
180
180
  Stream.fromEffect(
181
181
  (script === "done"
182
182
  ? onTaskComplete("done")
183
- : agentTasks.delegate({
183
+ : agentTasks.subagent({
184
184
  id: "1",
185
185
  prompt: "TASK-CHILD",
186
186
  background: false,
package/src/Agent.ts CHANGED
@@ -620,7 +620,7 @@ export const makeWith = Effect.fnUntraced(function* <
620
620
  })
621
621
 
622
622
  const agentTasks: AgentExecutor.ExecuteAgentTasks = {
623
- delegate: Effect.fnUntraced(function* ({
623
+ subagent: Effect.fnUntraced(function* ({
624
624
  id,
625
625
  prompt,
626
626
  background,
@@ -640,7 +640,7 @@ export const makeWith = Effect.fnUntraced(function* <
640
640
  yield* startTurn({
641
641
  child,
642
642
  label: prompt,
643
- prompt: `You have been asked using the "delegate" function to complete the following task. Try to avoid using the "delegate" function yourself unless strictly necessary:
643
+ prompt: `You have been asked using the "subagent" function to complete the following task. Try to avoid using the "subagent" function yourself unless strictly necessary:
644
644
 
645
645
  ${prompt}`,
646
646
  // The update goes into the child's first prompt.
@@ -686,7 +686,7 @@ ${prompt}`,
686
686
  if (child.turn.status === "running") {
687
687
  child.mailbox.messages.add({ message, resume: () => {} })
688
688
  child.mailbox.notify()
689
- return childTask(child)
689
+ return
690
690
  }
691
691
  child.turn = makeTurn(true)
692
692
  yield* startTurn({
@@ -695,7 +695,6 @@ ${prompt}`,
695
695
  label: message,
696
696
  background: true,
697
697
  })
698
- return childTask(child)
699
698
  }),
700
699
  stopTask: Effect.fnUntraced(function* (id) {
701
700
  const child = yield* lookupChild(id)
@@ -704,7 +703,6 @@ ${prompt}`,
704
703
  if (turn.status === "running") {
705
704
  yield* Fiber.interrupt(turn.fiber!)
706
705
  }
707
- return childTask(child)
708
706
  }),
709
707
  listTasks: Effect.sync(() =>
710
708
  Array.Array.from(children.values(), childTask),
@@ -1747,8 +1745,8 @@ const when = (condition: boolean, text: string) => (condition ? text : "")
1747
1745
  // model. Only offered functions are named.
1748
1746
  const taskInstructions = (tools: PromptTools): string => {
1749
1747
  const bash = tools.offers("bash")
1750
- const delegate = tools.offers("delegate")
1751
- if (!bash && !delegate) return ""
1748
+ const subagent = tools.offers("subagent")
1749
+ if (!bash && !subagent) return ""
1752
1750
  const functions = (
1753
1751
  [
1754
1752
  ["taskOutput", `"taskOutput" reads one`],
@@ -1763,7 +1761,7 @@ const taskInstructions = (tools: PromptTools): string => {
1763
1761
  .filter(([name]) => tools.offers(name))
1764
1762
  .map(([, text]) => text)
1765
1763
  const kinds =
1766
- bash && delegate
1764
+ bash && subagent
1767
1765
  ? "Background commands and sub-agents are"
1768
1766
  : bash
1769
1767
  ? "Background commands are"
@@ -1795,33 +1793,19 @@ const generateSystemTools = (
1795
1793
  tools.offers("search") && tools.offers("rg"),
1796
1794
  `
1797
1795
  - Prefer using the "search" function over "rg", unless you are targeting specific files or patterns.`,
1798
- )}${when(
1799
- tools.offers("applyPatch"),
1800
- `
1801
- - You can add / update / remove multiple files in one go with "applyPatch".${when(
1802
- tools.offers("writeFile"),
1803
- ` Prefer it over "writeFile" to update existing files.`,
1804
- )}`,
1805
1796
  )}${when(
1806
1797
  tools.offers("bash"),
1807
1798
  `
1808
1799
  - Avoid passing scripts into the "bash" function, and instead write javascript.`,
1809
1800
  )}
1810
1801
  - Variables are not shared between executions.
1811
- - Do not use \`require\`, \`import\`, \`process\`, or any other Node.js apis.${when(
1812
- tools.offers("delegate"),
1813
- `
1814
- - "delegate" runs a sub-agent and waits for it. Pass \`background: true\` to keep working while it runs: it returns an agent task straight away, and the agent's result is sent to you when it ends.${when(
1815
- tools.offers("messageAgent"),
1816
- ` Use "messageAgent" to send a message to a sub-agent.`,
1817
- )}`,
1818
- )}${taskInstructions(tools)}${when(
1802
+ - Do not use \`require\`, \`import\`, \`process\`, or any other Node.js apis.${taskInstructions(tools)}${when(
1819
1803
  !conversationMode,
1820
1804
  `
1821
1805
 
1822
1806
  When you have fully completed your task, call the "taskComplete" function with the final output.
1823
1807
  Make sure every detail of the task is done before calling "taskComplete".${when(
1824
- tools.offers("delegate"),
1808
+ tools.offers("subagent"),
1825
1809
  `
1826
1810
  Any sub-agents you started must finish first: "taskComplete" fails while they are running.`,
1827
1811
  )}`,
@@ -1850,12 +1834,7 @@ Here is how you would read a file and list a directory:
1850
1834
  \`\`\`
1851
1835
  const [files, content] = await Promise.all([
1852
1836
  ls("."),
1853
- readFile({
1854
- path: "package.json",
1855
- startLine: 1,
1856
- endLine: 10,
1857
- lineNumbers: false,
1858
- })
1837
+ readFile({ path: "package.json", startLine: 1, endLine: 10 })
1859
1838
  ])
1860
1839
  console.log("files:", files)
1861
1840
  console.log("package.json:", JSON.parse(content))
@@ -260,9 +260,9 @@ await taskComplete(result)`,
260
260
  const { system, summary } = yield* runAgent({
261
261
  mode,
262
262
  executor: {
263
- excludeTools: ["gh", "webSearch", "fetchMarkdown", "delegate"],
263
+ excludeTools: ["gh", "webSearch", "fetchMarkdown", "subagent"],
264
264
  },
265
- script: `const missing = [typeof gh, typeof webSearch, typeof fetchMarkdown, typeof delegate, typeof messageAgent].join(",")
265
+ script: `const missing = [typeof gh, typeof webSearch, typeof fetchMarkdown, typeof subagent, typeof messageAgent].join(",")
266
266
  let call
267
267
  try {
268
268
  await gh(["pr", "view"])
@@ -278,7 +278,7 @@ await taskComplete(missing + " " + call)`,
278
278
  )
279
279
  assert.notMatch(
280
280
  system,
281
- /\b(gh|webSearch|fetchMarkdown|delegate|messageAgent)\b/,
281
+ /\b(gh|webSearch|fetchMarkdown|subagent|messageAgent)\b/,
282
282
  )
283
283
  assert.include(system, "declare function readFile(")
284
284
  }),
@@ -286,13 +286,13 @@ await taskComplete(missing + " " + call)`,
286
286
 
287
287
  // The shared task functions address bash and agent tasks, so they stay
288
288
  // while either kind can still be started.
289
- it.live("the task functions go only when bash and delegate both go", () =>
289
+ it.live("the task functions go only when bash and subagent both go", () =>
290
290
  Effect.gen(function* () {
291
291
  const tasks =
292
292
  "[typeof taskOutput, typeof waitTasks, typeof stopTask, typeof listTasks].join()"
293
293
  const withBash = yield* runAgent({
294
294
  mode,
295
- executor: { excludeTools: ["delegate"] },
295
+ executor: { excludeTools: ["subagent"] },
296
296
  script: `await taskComplete(${tasks})`,
297
297
  })
298
298
  assert.strictEqual(
@@ -301,7 +301,7 @@ await taskComplete(missing + " " + call)`,
301
301
  )
302
302
  const withNeither = yield* runAgent({
303
303
  mode,
304
- executor: { excludeTools: ["bash", "delegate"] },
304
+ executor: { excludeTools: ["bash", "subagent"] },
305
305
  script: `await taskComplete(${tasks})`,
306
306
  })
307
307
  assert.strictEqual(
@@ -458,17 +458,21 @@ describe("rpc executor", () => {
458
458
  describe("agent", () => {
459
459
  it.live("a left-out tool is not mentioned anywhere in the prompt", () =>
460
460
  Effect.gen(function* () {
461
- // Each is named outside its own declaration: the delegate bullet, the
461
+ // Each is named outside its own declaration: the subagent bullet, the
462
462
  // applyPatch hint and the executor's skills catalog.
463
463
  const { system, summary } = yield* runAgent({
464
464
  mode: "local",
465
465
  executor: { excludeTools: ["waitTasks", "applyPatch", "readFile"] },
466
466
  script:
467
- "await taskComplete([typeof waitTasks, typeof applyPatch, typeof readFile].join())",
467
+ "await taskComplete([typeof waitTasks, typeof applyPatch, typeof readFile, typeof subagent, typeof delegate].join())",
468
468
  })
469
- assert.strictEqual(summary, "undefined,undefined,undefined")
469
+ assert.strictEqual(
470
+ summary,
471
+ "undefined,undefined,undefined,function,undefined",
472
+ )
470
473
  assert.notMatch(system, /\b(waitTasks|applyPatch|readFile)\b/)
471
- assert.include(system, "declare function delegate(")
474
+ assert.include(system, "declare function subagent(")
475
+ assert.notInclude(system, "declare function delegate(")
472
476
  }),
473
477
  )
474
478
 
@@ -277,7 +277,7 @@ for (const [mode, executorLayer] of Object.entries(executors)) {
277
277
  return Stream.make(toolCall(`await changeDirectory("pkg")`))
278
278
  case 3:
279
279
  return Stream.make(
280
- toolCall(`await delegate({ prompt: "TASK-CHILD" })`),
280
+ toolCall(`await subagent({ prompt: "TASK-CHILD" })`),
281
281
  )
282
282
  default:
283
283
  return Stream.fromIterable(text("done"))
@@ -326,7 +326,7 @@ for (const [mode, executorLayer] of Object.entries(executors)) {
326
326
  assert.include(
327
327
  JSON.stringify(encodePrompt(child!.prompt)),
328
328
  "PKG-RULES",
329
- "a delegate started after the cd sees pkg's instructions",
329
+ "a subagent started after the cd sees pkg's instructions",
330
330
  )
331
331
  const childUpdates = outputs.flatMap((output) =>
332
332
  output._tag === "SubagentPart" &&
@@ -23,7 +23,7 @@ import * as NodePath from "node:path"
23
23
  import * as AgentExecutor from "./AgentExecutor.ts"
24
24
  import { agentTasksUnavailable, type Task } from "./AgentTools.ts"
25
25
 
26
- // The task a stub `delegate` resolves with once its agent has finished.
26
+ // The task a stub `subagent` resolves with once its agent has finished.
27
27
  const completedAgent = (id: string, prompt: string, output: string): Task => ({
28
28
  id,
29
29
  kind: "agent",
@@ -74,7 +74,7 @@ const withRpc = <A, E, R>(
74
74
  )
75
75
 
76
76
  describe("RPC subagent executor", () => {
77
- it.live("routes concurrent delegates to their originating scripts", () =>
77
+ it.live("routes concurrent subagents to their originating scripts", () =>
78
78
  withRpc((executor) =>
79
79
  Effect.gen(function* () {
80
80
  const { environment } = yield* executor.capabilities
@@ -87,12 +87,12 @@ describe("RPC subagent executor", () => {
87
87
  environment,
88
88
  onEnvironment: () => Effect.void,
89
89
  script:
90
- 'console.log("first:" + (await delegate({ prompt: "first" })).output)',
90
+ 'console.log("first:" + (await subagent({ prompt: "first" })).output)',
91
91
  onTaskComplete: () => Effect.void,
92
92
  onImage: () => Effect.void,
93
93
  agentTasks: {
94
94
  ...agentTasksUnavailable,
95
- delegate: ({ id, prompt }) =>
95
+ subagent: ({ id, prompt }) =>
96
96
  Effect.gen(function* () {
97
97
  assert.strictEqual(prompt, "first")
98
98
  yield* Deferred.succeed(firstStarted, undefined)
@@ -107,12 +107,12 @@ describe("RPC subagent executor", () => {
107
107
  environment,
108
108
  onEnvironment: () => Effect.void,
109
109
  script:
110
- 'console.log("second:" + (await delegate({ prompt: "second" })).output)',
110
+ 'console.log("second:" + (await subagent({ prompt: "second" })).output)',
111
111
  onTaskComplete: () => Effect.void,
112
112
  onImage: () => Effect.void,
113
113
  agentTasks: {
114
114
  ...agentTasksUnavailable,
115
- delegate: ({ id, prompt }) =>
115
+ subagent: ({ id, prompt }) =>
116
116
  Effect.gen(function* () {
117
117
  assert.strictEqual(prompt, "second")
118
118
  yield* Deferred.succeed(secondStarted, undefined)
@@ -142,12 +142,12 @@ describe("RPC subagent executor", () => {
142
142
  environment,
143
143
  onEnvironment: () => Effect.void,
144
144
  script:
145
- 'console.log("parent:" + (await delegate({ prompt: "outer" })).output)',
145
+ 'console.log("parent:" + (await subagent({ prompt: "outer" })).output)',
146
146
  onTaskComplete: () => Effect.void,
147
147
  onImage: () => Effect.void,
148
148
  agentTasks: {
149
149
  ...agentTasksUnavailable,
150
- delegate: ({ id, prompt }) =>
150
+ subagent: ({ id, prompt }) =>
151
151
  Effect.gen(function* () {
152
152
  assert.strictEqual(prompt, "outer")
153
153
  const childOutput = yield* executor
@@ -155,12 +155,12 @@ describe("RPC subagent executor", () => {
155
155
  environment,
156
156
  onEnvironment: () => Effect.void,
157
157
  script:
158
- 'console.log("child:" + (await delegate({ prompt: "inner" })).output)',
158
+ 'console.log("child:" + (await subagent({ prompt: "inner" })).output)',
159
159
  onTaskComplete: () => Effect.void,
160
160
  onImage: () => Effect.void,
161
161
  agentTasks: {
162
162
  ...agentTasksUnavailable,
163
- delegate: ({ id: innerId, prompt: innerPrompt }) =>
163
+ subagent: ({ id: innerId, prompt: innerPrompt }) =>
164
164
  Effect.sync(() => {
165
165
  assert.strictEqual(innerPrompt, "inner")
166
166
  return completedAgent(
@@ -801,7 +801,8 @@ try {
801
801
  } catch (error) {
802
802
  console.log("MESSAGE-REJECTED:", String(error))
803
803
  }
804
- console.log("STOPPED:", show(await stopTask("1")))
804
+ console.log("STOP-VOID:", (await stopTask("1")) === undefined)
805
+ console.log("STOPPED:", show(await taskOutput("1")))
805
806
  try {
806
807
  await stopTask("99")
807
808
  } catch (error) {
@@ -816,6 +817,7 @@ try {
816
817
  output,
817
818
  'STOPPED: {"id":"1","kind":"bash","status":"stopped"}',
818
819
  )
820
+ assert.include(output, "STOP-VOID: true")
819
821
  assert.match(output, /REJECTED:.*No task with id "99".*listTasks\(\)/)
820
822
  openGate(environment.cwd)
821
823
  yield* Effect.sleep("500 millis")
@@ -992,15 +994,15 @@ console.log("MAIN" + "_DONE")`)
992
994
  .execute({
993
995
  environment,
994
996
  onEnvironment: () => Effect.void,
995
- // `delegate` never finishes. The worker then exits through
997
+ // `subagent` never finishes. The worker then exits through
996
998
  // the host's `process`, the way a crashed worker would.
997
999
  script: `
998
- delegate({ prompt: "never finishes" })
1000
+ subagent({ prompt: "never finishes" })
999
1001
  sleep(100).then(() => console.constructor.constructor("return process")().exit(7))`,
1000
1002
  onTaskComplete: () => Effect.void,
1001
1003
  agentTasks: {
1002
1004
  ...agentTasksUnavailable,
1003
- delegate: () => Effect.never,
1005
+ subagent: () => Effect.never,
1004
1006
  },
1005
1007
  onImage: () => Effect.void,
1006
1008
  })
@@ -158,16 +158,16 @@ export interface ExecuteOptions {
158
158
  }
159
159
 
160
160
  /**
161
- * The sub-agents of the agent running a script. `delegate` also receives the
161
+ * The sub-agents of the agent running a script. `subagent` also receives the
162
162
  * environment the new agent starts in: the script's directory at the moment
163
- * `delegate` was called, with an update holding everything that applies to
163
+ * `subagent` was called, with an update holding everything that applies to
164
164
  * it beyond the system prompt.
165
165
  *
166
166
  * @since 1.0.0
167
167
  * @category Models
168
168
  */
169
- export interface ExecuteAgentTasks extends Omit<AgentTasks, "delegate"> {
170
- readonly delegate: (options: {
169
+ export interface ExecuteAgentTasks extends Omit<AgentTasks, "subagent"> {
170
+ readonly subagent: (options: {
171
171
  readonly id: string
172
172
  readonly prompt: string
173
173
  readonly background: boolean
@@ -313,8 +313,8 @@ export interface LocalOptions<Toolkit extends Toolkit.Any = never> {
313
313
  readonly limits?: Limits | undefined
314
314
  /**
315
315
  * Built-in tools to leave out of the sandbox and the type declarations.
316
- * Leaving out `delegate` also leaves out `messageAgent`, and leaving out
317
- * both `delegate` and `bash` leaves out the task functions.
316
+ * Leaving out `subagent` also leaves out `messageAgent`, and leaving out
317
+ * both `subagent` and `bash` leaves out the task functions.
318
318
  * Leaving out `fetch` removes the global Fetch API.
319
319
  */
320
320
  readonly excludeTools?: ReadonlyArray<ExcludableTool> | undefined
@@ -526,10 +526,10 @@ const makeLocalWith = Effect.fnUntraced(function* <
526
526
  ...opts.agentTasks,
527
527
  // A new agent has only the system prompt, so it gets everything that
528
528
  // applies to the directory.
529
- delegate: (options) =>
529
+ subagent: (options) =>
530
530
  renderEnvironment(currentEnvironment(), { reset: true }).pipe(
531
531
  Effect.flatMap((environment) =>
532
- opts.agentTasks.delegate({ ...options, environment }),
532
+ opts.agentTasks.subagent({ ...options, environment }),
533
533
  ),
534
534
  ),
535
535
  }),
@@ -992,10 +992,10 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(
992
992
  request<void>({ _tag: "TaskComplete", summary }),
993
993
  agentId,
994
994
  agentTasks: {
995
- delegate: (options) =>
995
+ subagent: (options) =>
996
996
  Effect.orDie(
997
997
  request<Task>({
998
- _tag: "Delegate",
998
+ _tag: "Subagent",
999
999
  ...options,
1000
1000
  }),
1001
1001
  ),
@@ -1008,11 +1008,14 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(
1008
1008
  timeoutMs,
1009
1009
  }),
1010
1010
  messageAgent: (options) =>
1011
- request<void>({
1012
- _tag: "MessageAgent",
1013
- ...options,
1014
- }),
1015
- stopTask: (id) => request<Task>({ _tag: "StopTask", id }),
1011
+ Effect.asVoid(
1012
+ request<void>({
1013
+ _tag: "MessageAgent",
1014
+ ...options,
1015
+ }),
1016
+ ),
1017
+ stopTask: (id) =>
1018
+ Effect.asVoid(request<void>({ _tag: "StopTask", id })),
1016
1019
  listTasks: Effect.orDie(
1017
1020
  request<ReadonlyArray<Task>>({
1018
1021
  _tag: "ListTasks",
@@ -1105,7 +1108,7 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(
1105
1108
  */
1106
1109
  export const AgentRequest = Schema.TaggedUnion({
1107
1110
  TaskComplete: { summary: Schema.String },
1108
- Delegate: {
1111
+ Subagent: {
1109
1112
  id: Schema.String,
1110
1113
  prompt: Schema.String,
1111
1114
  background: Schema.Boolean,
@@ -1126,7 +1129,7 @@ export const AgentRequest = Schema.TaggedUnion({
1126
1129
 
1127
1130
  /**
1128
1131
  * The client's answer to a `Request`. `Failure` carries a message for the
1129
- * script; a failed foreground `delegate` is raised there as a defect.
1132
+ * script; a failed foreground `subagent` is raised there as a defect.
1130
1133
  *
1131
1134
  * @since 1.0.0
1132
1135
  * @category Rpcs
@@ -1302,8 +1305,8 @@ const handleRequest = (
1302
1305
  switch (request._tag) {
1303
1306
  case "TaskComplete":
1304
1307
  return opts.onTaskComplete(request.summary)
1305
- case "Delegate":
1306
- return opts.agentTasks.delegate(request)
1308
+ case "Subagent":
1309
+ return opts.agentTasks.subagent(request)
1307
1310
  case "TaskOutput":
1308
1311
  return opts.agentTasks.taskOutput(request.id)
1309
1312
  case "WaitTasks":
@@ -1377,13 +1380,13 @@ const errorMessage = (error: unknown): string =>
1377
1380
  ? error.message
1378
1381
  : String(error)
1379
1382
 
1380
- // Leaving out `delegate` leaves out `messageAgent`. The task functions
1383
+ // Leaving out `subagent` leaves out `messageAgent`. The task functions
1381
1384
  // address both kinds, so they go once neither can be started.
1382
1385
  const excludedToolNames = (
1383
1386
  excludeTools: ReadonlyArray<ExcludableTool> | undefined,
1384
1387
  ): ReadonlySet<string> => {
1385
1388
  const names = new Set<string>(excludeTools)
1386
- if (names.has("delegate")) {
1389
+ if (names.has("subagent")) {
1387
1390
  names.add("messageAgent")
1388
1391
  if (names.has("bash")) {
1389
1392
  for (const name of ["taskOutput", "waitTasks", "stopTask", "listTasks"]) {
@@ -268,11 +268,11 @@ describe("Agent images", () => {
268
268
  }),
269
269
  )
270
270
 
271
- it.effect("does not copy image bytes into a delegate prompt", () =>
271
+ it.effect("does not copy image bytes into a subagent prompt", () =>
272
272
  Effect.gen(function* () {
273
273
  const executor = makeExecutor(({ agentTasks, environment }) =>
274
274
  Stream.fromEffect(
275
- agentTasks.delegate({
275
+ agentTasks.subagent({
276
276
  id: "1",
277
277
  prompt: "child task: describe the layout",
278
278
  background: false,
@@ -292,7 +292,7 @@ describe("Agent images", () => {
292
292
  respond: (call, index) => {
293
293
  if (index === 0) {
294
294
  return Stream.make(
295
- toolCall("call-1", 'await delegate("describe the layout")'),
295
+ toolCall("call-1", 'await subagent("describe the layout")'),
296
296
  )
297
297
  }
298
298
  const isChild = userText(call.prompt).includes("child task")
@@ -305,7 +305,7 @@ describe("Agent images", () => {
305
305
  const child = calls.find((call) =>
306
306
  userText(call.prompt).includes("child task"),
307
307
  )
308
- assert.isDefined(child, "the delegate call reached the model")
308
+ assert.isDefined(child, "the subagent call reached the model")
309
309
  assert.strictEqual(fileParts(child!.prompt).length, 0)
310
310
  // The parent still has its image.
311
311
  assert.strictEqual(fileParts(calls[0]!.prompt).length, 1)