Skip to content

Commit 6566a4d

Browse files
Document how a factory's arguments reach the agent
There is no declared schema for `ctx.args`: `FactoryMeta` carries only name, description, phases and limits, and the `run_factory` tool's `args` parameter is untyped, forwarded verbatim. The description is therefore the only channel telling an agent what to supply, which the guide did not say and its example did not demonstrate — nothing in "Review changed files and verify the findings" hints that `ctx.args.files` is a string array. State the constraint explicitly and show the expected shape in the example's description.
1 parent 3d1963f commit 6566a4d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

nodejs/docs/factories.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import { defineFactory, joinSession } from "@github/copilot-sdk/extension";
1212
const reviewChanged = defineFactory({
1313
meta: {
1414
name: "review-changed",
15-
description: "Review changed files and verify the findings",
15+
description:
16+
"Review changed files and verify the findings. " +
17+
"args: { files: string[] } — the paths to review.",
1618
phases: [{ title: "Review" }, { title: "Verify" }],
1719
limits: {
1820
maxConcurrentSubagents: 3,
@@ -41,6 +43,8 @@ const session = await joinSession({ factories: [reviewChanged] });
4143

4244
Factory metadata contains a stable `name`, a human-readable `description`, declared `phases`, and optional `limits`. Phase entries contain a `title` and optional `detail`.
4345

46+
There is no declared schema for `ctx.args`. The `run_factory` tool forwards `args` verbatim and its parameter is untyped, so **the `description` is the only thing telling an agent what arguments to supply** — state the expected shape there whenever a factory reads `ctx.args`, as the example above does. Arguments supplied by an extension calling `session.factory.run(...)` directly are typed through `defineFactory<TArgs>`, but that typing does not reach the model. A factory that reads `ctx.args` should validate it rather than assume a shape.
47+
4448
`defineFactory<TArgs, TResult>` accepts a `run(context)` function returning `Promise<TResult>`, where `TResult` is `JsonValue | void`. Objects, arrays, strings, numbers, booleans, and `null` are valid results. Returning `undefined` completes the factory with no result. Other non-JSON values are rejected.
4549

4650
## Factory context

0 commit comments

Comments
 (0)