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
2 changes: 1 addition & 1 deletion examples/docs/agent-to-agent/coder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const requestReview = defineTool({
parameters: Type.Object({ repo: Type.String(), branch: Type.String(), summary: Type.String() }),
execute: async ({ repo, branch, summary }) => {
await client.reviewer.getOrCreate([repo]).requestReview(`Review the ${branch} branch of https://github.com/${repo}: ${summary}`);
return { content: [{ type: "text", text: `Sent ${branch} for review.` }] };
return { output: [{ type: "text", text: `Sent ${branch} for review.` }] };
},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/docs/custom-tools/get-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const getOrder = defineTool({
execute: async ({ orderId }, _api, context) => {
const order = await fetchOrder(orderId, context.abortSignal);
const text = `Status: ${order.status}. Total: $${order.total}.`;
return { content: [{ type: "text", text }], details: order };
return { output: [{ type: "text", text }], details: order };
},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/docs/design-patterns/background-job/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const openPullRequest = defineTool({
});
if (!response.ok) throw new Error(`GitHub returned ${response.status}.`);
const pull = (await response.json()) as { html_url: string };
return { content: [{ type: "text", text: pull.html_url }] };
return { output: [{ type: "text", text: pull.html_url }] };
},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/docs/durable-ai-agents/chat-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const updatePlan = defineTool({
await api.commit(async (tx) => {
(await tx.doc(Plan, api.conversationId)).steps = steps;
}, context);
return { content: [{ type: "text", text: "Plan saved." }] };
return { output: [{ type: "text", text: "Plan saved." }] };
},
});

Expand Down
4 changes: 2 additions & 2 deletions examples/docs/durable-ai-agents/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const searchFlights = defineTool({
execute: async ({ from, to, date }) => {
const flights = await findFlights(from, to, date);
const text = flights.map((f) => `${f.id}: departs ${f.departs}, $${f.price}`).join("\n");
return { content: [{ type: "text", text }], details: flights };
return { output: [{ type: "text", text }], details: flights };
},
});
// docs:end search
Expand All @@ -32,7 +32,7 @@ export const bookFlight = defineTool({
const idempotencyKey = await api.memo("idempotency-key", crypto.randomUUID(), context);
const booking = await createBooking(flightId, passenger, idempotencyKey);
const text = `Booked ${passenger} on ${flightId}. Confirmation ${booking.confirmation}.`;
return { content: [{ type: "text", text }], details: booking };
return { output: [{ type: "text", text }], details: booking };
},
});
// docs:end book
Expand Down
4 changes: 2 additions & 2 deletions examples/docs/human-in-the-loop/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export const deploy = defineTool({
await client.approval.getOrCreate([id]).request(version);
const text = `Waiting for a person to approve deploying ${version}. After approval, call deploy again with approvalId ${id}.`;
// Ends the run, so the agent waits for the person instead of trying again.
return { content: [{ type: "text", text }], details: { version, approvalId: id }, control: { terminate: true } };
return { output: [{ type: "text", text }], details: { version, approvalId: id }, control: { terminate: true } };
}
if (!(await client.approval.get([approvalId]).consume(version))) {
throw new Error(`Deploying ${version} is not approved.`);
}
await fetch(`https://deploy.example.com/releases/${version}`, { method: "POST", signal: context.abortSignal });
return { content: [{ type: "text", text: `Deployed ${version}.` }] };
return { output: [{ type: "text", text: `Deployed ${version}.` }] };
},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/docs/multi-agent-system/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const askSpecialist = defineTool({
);

const text = subtasks.map((subtask, i) => `## ${subtask}\n\n${answers[i]}`).join("\n\n");
return { content: [{ type: "text", text }] };
return { output: [{ type: "text", text }] };
},
});
// docs:end fan-out
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/multi-agent-system/researcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const fetchPage = defineTool({
const response = await fetch(url, { signal: context.abortSignal });
if (!response.ok) throw new Error(`${url} returned ${response.status}.`);
const text = (await response.text()).slice(0, 20_000);
return { content: [{ type: "text", text }] };
return { output: [{ type: "text", text }] };
},
});

Expand Down
8 changes: 4 additions & 4 deletions examples/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
},
"dependencies": {
"@daytonaio/sdk": "^0.216.0",
"@earendil-works/chord": "^1.0.4",
"@earendil-works/pi-ai": "^1.0.4",
"@earendil-works/pi-coding-agent": "^1.0.4",
"@earendil-works/pi-durable": "^1.0.4",
"@earendil-works/chord": "1.3.0",
"@earendil-works/pi-ai": "1.3.0",
"@earendil-works/pi-coding-agent": "1.3.0",
"@earendil-works/pi-durable": "1.3.0",
"@hono/node-server": "^2.1.5",
"@linear/sdk": "^97.0.0",
"@octokit/rest": "^22.0.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/personal-agent/weather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export const getWeather = defineTool({
// A mock. Call a real weather API here.
const weather = { city, temperatureC: 18, conditions: "sunny" };
const text = `${city}: ${weather.temperatureC}°C and ${weather.conditions}.`;
return { content: [{ type: "text", text }], details: weather };
return { output: [{ type: "text", text }], details: weather };
},
});
2 changes: 1 addition & 1 deletion examples/docs/pi/pokedex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const findPokemon = defineTool({
.map((encounter) => encounter.location_area.name);
const text =
areas.length > 0 ? `${pokemon} in ${version}: ${areas.join(", ")}.` : `No wild ${pokemon} in ${version}.`;
return { content: [{ type: "text", text }] };
return { output: [{ type: "text", text }] };
},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/docs/pi/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const deployPreview = defineTool({
const id = await api.createTask(DeployPreview, args, { ownership: { kind: "task", taskId: api.taskId } }, context);
const { outcome } = (await api.waitForTask(id, context)).state;
const text = outcome.status === "completed" ? `Preview at ${outcome.result}.` : `Preview ${outcome.status}.`;
return { content: [{ type: "text", text }] };
return { output: [{ type: "text", text }] };
},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/docs/scoped-access/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const shareReport = defineTool({
const handle = await admin.report.create([crypto.randomUUID()], { input: { title, body } });
const { token } = await handle.issueToken({ subject: "shared-report", expiresIn: 3600 });
const url = `https://app.example.com/reports/${await handle.resolve()}#${token}`;
return { content: [{ type: "text", text: `Shared at ${url}` }], details: { url } };
return { output: [{ type: "text", text: `Shared at ${url}` }], details: { url } };
},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/docs/skills/skills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const loadSkill = defineTool({
execute: async ({ name }) => {
const skill = skills.get(name);
if (!skill) throw new Error(`No skill named ${name}. Skills: ${[...skills.keys()].join(", ")}.`);
return { content: [{ type: "text", text: skill.body }] };
return { output: [{ type: "text", text: skill.body }] };
},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/docs/subagents/get-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const getOrder = defineTool({
execute: async ({ orderId }, _api, context) => {
const order = await fetchOrder(orderId, context.abortSignal);
const text = `Status: ${order.status}. Total: $${order.total}.`;
return { content: [{ type: "text", text }], details: order };
return { output: [{ type: "text", text }], details: order };
},
});

Expand Down
4 changes: 2 additions & 2 deletions examples/docs/subagents/specialists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export const askSpecialist = defineTool({

const result = await agent.prompt(question, { requestId: id });
if (result.status === "unanswered") {
return { content: [{ type: "text", text: `The specialist did not answer: ${result.reason}` }], isError: true };
return { output: [{ type: "text", text: `The specialist did not answer: ${result.reason}` }], isError: true };
}
const answer = result.text || "The specialist finished without an answer.";
return { content: [{ type: "text", text: answer }], details: { specialist } };
return { output: [{ type: "text", text: answer }], details: { specialist } };
},
});

Expand Down
6 changes: 3 additions & 3 deletions packages/pi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
"rivetkit": ">=2.3.26 <2.4.0"
},
"devDependencies": {
"@earendil-works/chord": "^1.1.0",
"@earendil-works/pi-ai": "^1.1.0",
"@earendil-works/pi-durable": "^1.1.0",
"@earendil-works/chord": "1.3.0",
"@earendil-works/pi-ai": "1.3.0",
"@earendil-works/pi-durable": "1.3.0",
"@opentelemetry/sdk-trace-node": "2.11.0",
"@types/node": "^24.0.0",
"rivetkit": "2.3.26",
Expand Down
4 changes: 2 additions & 2 deletions packages/pi/tests/actor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function buildRegistry(mock: MockModel, root: string) {
toolRuns[name] += 1;
if (toolRuns[name] === 1) await aborted(context.abortSignal);
context.abortSignal?.throwIfAborted();
return { content: [{ type: "text", text: `${name} done` }] };
return { output: [{ type: "text", text: `${name} done` }] };
},
});
const tools = createRegistry();
Expand Down Expand Up @@ -300,7 +300,7 @@ function buildRegistry(mock: MockModel, root: string) {
description: "Look up a value",
parameters: Type.Object({}),
replay: "safe",
execute: async () => ({ content: [{ type: "text", text: "42" }] }),
execute: async () => ({ output: [{ type: "text", text: "42" }] }),
}),
],
}),
Expand Down
3 changes: 2 additions & 1 deletion packages/pi/tests/helpers/mock-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export function createMockModel(): MockModel {
reasoning: false,
input: ["text" as const],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 128_000,
// Large enough that the 20,000-line log never triggers compaction, which the mock does not script.
contextWindow: 1_000_000,
maxTokens: 4_096,
}));
const replies = new Map<string, MockReply[]>();
Expand Down
2 changes: 1 addition & 1 deletion packages/pi/tests/on-answer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const lookup = defineTool({
description: "Looks something up.",
parameters: Type.Object({}),
replay: "safe",
execute: async () => ({ content: [{ type: "text", text: "found it" }] }),
execute: async () => ({ output: [{ type: "text", text: "found it" }] }),
});

function buildRegistry(mock: MockModel) {
Expand Down
6 changes: 3 additions & 3 deletions packages/pi/tests/upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const deployTool = defineTool({
execute: async () => {
deployRuns += 1;
await release.promise;
return { content: [{ type: "text", text: "deployed" }] };
return { output: [{ type: "text", text: "deployed" }] };
},
});

Expand All @@ -80,7 +80,7 @@ const shipTool = defineTool({
execute: async () => {
shipRuns += 1;
await shipRelease.promise;
return { content: [{ type: "text", text: "shipped" }] };
return { output: [{ type: "text", text: "shipped" }] };
},
});

Expand All @@ -96,7 +96,7 @@ const blockingTool = defineTool({
await aborted(context.abortSignal);
blocking.stopped += 1;
context.abortSignal?.throwIfAborted();
return { content: [{ type: "text", text: "stopped" }] };
return { output: [{ type: "text", text: "stopped" }] };
},
});

Expand Down
2 changes: 1 addition & 1 deletion packages/pi/tests/watch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const addTodo = defineTool({
await api.commit(async (tx) => {
(await tx.doc(Todos, api.conversationId)).items.push(item);
}, context);
return { content: [{ type: "text", text: "added" }] };
return { output: [{ type: "text", text: "added" }] };
},
});

Expand Down
Loading
Loading