You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f72b3da
Browse filesBrowse the repository at this point in the historyBrowse files
authored
docs(agents): E2B/Daytona sandboxes, fleshed-out examples, design patterns first (#115)
- The reviewer is keyed by repository, so every coder working on the same repository reaches the same reviewer, and its session remembers past reviews.
38
-
-`requestReview` schedules the reviewer's `prompt` and returns, so the coder's tool doesn't wait for the review. The schedule is saved with the reviewer, so the review runs even if the coder's request goes away.
39
-
-`streamingBehavior: "followUp"` queues the request when the reviewer is busy with another review. Use it with `prompt`, not the `followUp` action, which only queues on an idle agent and never starts a run.
39
+
- The `requestReview` action schedules the reviewer's `prompt` and returns, so the coder's tool doesn't wait for the review. The schedule is saved with the reviewer, so the review runs even if the coder's request goes away.
40
+
- Passing `streamingBehavior: "followUp"` queues the request when the reviewer is busy with another review. Use it with `prompt`, not the `followUp` action, which only queues on an idle agent and never starts a run.
41
+
- The reviewer runs on a different model family than the coder.
40
42
41
43
To wait for the other agent's answer instead, see [Subagents](/agents/docs/subagents). See [Schedules](/actors/docs/schedule) for more on `c.schedule`.
Copy file name to clipboardExpand all lines: agents/docs/content/docs/api-keys.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: "Give agents model access with your own provider keys, from the env
5
5
6
6
An agent calls the model from your worker, so its keys stay in your backend and never enter the sandbox. It looks for a key in this order:
7
7
8
-
1.`apiKeys` passed to `pi()`.
8
+
1.The `apiKeys` option passed to `pi()`.
9
9
2. The `credentials` Actor, when your users [bring their own subscriptions](/agents/docs/user-subscriptions).
10
10
3. The worker's environment.
11
11
@@ -62,16 +62,16 @@ Set the key for your model provider in the environment of the process that runs
62
62
ANTHROPIC_API_KEY=sk-ant-...
63
63
```
64
64
65
-
Pi reads the provider-named variable, such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, or `OPENROUTER_API_KEY`. See Pi's [provider list](https://github.com/earendil-works/pi) for the rest.
65
+
Pi reads the provider-named variable, such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `XAI_API_KEY`, `DEEPSEEK_API_KEY`, `GROQ_API_KEY`, or `OPENROUTER_API_KEY`. See Pi's [provider list](https://github.com/earendil-works/pi) for the rest.
66
66
67
67
## Keys in code
68
68
69
-
Pass `apiKeys` to set keys by provider id in code, for example when they come from a secret manager or differ per deployment. Here it's added to the [Quickstart](/agents/docs/quickstart) agent. The keys stay in the Actor's memory and win over every other source.
69
+
Pass `apiKeys` to set keys by provider id in code, for example when they come from a secret manager or differ per deployment. The keys stay in the Actor's memory and win over every other source.
Copy file name to clipboardExpand all lines: agents/docs/content/docs/architecture.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: "The states an agent moves through, and what survives sleep, crashe
5
5
6
6
## States
7
7
8
-
An agent is idle until a prompt starts a run, and goes back to idle when the run ends or is cancelled. When the context fills up during a run, the agent compacts it and keeps going. Tool calls run in the sandbox.
8
+
An agent is idle until a prompt starts a run, and goes back to idle when the run ends or is cancelled. When the context fills up during a run, the agent compacts it and keeps going.
9
9
10
10
<divstyle="overflow-x:auto">
11
11
<svgviewBox="0 0 640 300"role="img"aria-label="Agent states: a prompt moves Idle to Running, and the run ending or being cancelled moves it back. Running moves to Compacting when the context is full and back when compaction is done. Idle moves to Sleeping when idle, and the next action wakes it back to Idle. Running sends tool calls to the sandbox."style="width:100%;min-width:520px;max-width:640px;height:auto;display:block;margin:2.5rem auto;font-family:system-ui,sans-serif">
@@ -47,7 +47,7 @@ An agent is idle until a prompt starts a run, and goes back to idle when the run
47
47
48
48
## Sleep
49
49
50
-
An idle agent sleeps and frees its memory. The next action on its key wakes it: the agent reloads its session and reconnects to the same sandbox, so clients don't do anything different. While the agent sleeps, an E2B or Daytona sandbox is suspended, and an agentOS VM sleeps on its own.
50
+
An idle agent sleeps and frees its memory. The next action on its key wakes it: the agent reloads its session and reconnects to the same sandbox, so clients don't do anything different. While the agent sleeps, its sandbox is suspended.
51
51
52
52
<divstyle="overflow-x:auto">
53
53
<svgviewBox="0 0 640 280"role="img"aria-label="The agent loop runs in memory and saves each step to the Actor's SQLite database, which also holds the sandbox id. On wake, the loop is restored from SQLite and reconnects to the same sandbox. Sleep, a crash, or a deploy clears memory, and SQLite is kept."style="width:100%;min-width:520px;max-width:640px;height:auto;display:block;margin:2.5rem auto;font-family:system-ui,sans-serif">
@@ -86,6 +86,6 @@ An idle agent sleeps and frees its memory. The next action on its key wakes it:
86
86
| Sleep | Every message so far. | Reconnected on wake. |
87
87
| Crash | Every message written before the crash. | Reconnected on wake. |
88
88
| Deploy | Every message so far. Old Actors get up to 30 minutes to finish before the agent wakes on the new code. See [Versions](/docs/versions). | Reconnected on wake. |
89
-
| Destroy | Deleted. |E2B and Daytona sandboxes are deleted. An agentOS VM and its files are left in place. |
89
+
| Destroy | Deleted. |Deleted. |
90
90
91
91
A model chosen with `setModel` is restored too, if it's still allowed. If the sandbox no longer exists when the agent wakes, a new one is created and the old files are lost.
Copy file name to clipboardExpand all lines: agents/docs/content/docs/built-in-tools.mdx
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,18 @@
1
1
---
2
2
title: "Built-in Tools"
3
-
description: "The file and shell tools every agent gets, where they run, and how to limit them."
3
+
description: "Pi's file and shell tools for agents with a sandbox, where they run, and how to limit them."
4
4
---
5
5
6
-
With a sandbox, an agent gets seven built-in tools that run in the sandbox, not on your worker.
6
+
Built-in tools are Pi's own [coding tools](https://github.com/earendil-works/pi/tree/main/packages/coding-agent), with the same names, parameters, and output as in Pi. They run in the agent's sandbox instead of on your worker.
7
7
8
8
| Tool | What it does |
9
9
| --- | --- |
10
10
|`read`, `write`, `edit`| Read, create, and change files. |
11
11
|`grep`, `find`, `ls`| Search files and list directories. |
12
12
|`bash`| Run a shell command. |
13
13
14
+
A sandbox is optional. Without one, the agent has no built-in tools and only uses the [custom tools](/agents/docs/custom-tools) you pass. Pi's tools run with the permissions of the process they run in, which is your worker, so they're only turned on when a [sandbox](/agents/docs/sandboxes) gives them somewhere else to run.
15
+
14
16
<divstyle="overflow-x:auto">
15
17
<svgviewBox="0 0 640 200"role="img"aria-label="client.ts calls executeBash on the reviewer agent to check out the branch. The reviewer's read and search tools run in its sandbox. bash, edit, and write are excluded."style="width:100%;min-width:520px;max-width:640px;height:auto;display:block;margin:2.5rem auto;font-family:system-ui,sans-serif">
16
18
<defs>
@@ -37,9 +39,8 @@ With a sandbox, an agent gets seven built-in tools that run in the sandbox, not
-`excludeTools` turns tools off by name, so this reviewer can read and search files but can't run commands or change them. `tools` does the opposite and enables only the tools you list.
41
-
-`executeBash` runs a command in the agent's sandbox from your backend, without the model. It works even though the reviewer can't run `bash` itself. `excludeFromContext` keeps the output out of the conversation.
42
-
- File tools only reach paths inside the sandbox's working directory. `bash` accepts a timeout, and long output is truncated before it reaches the model.
43
-
- Without a sandbox, the agent has no built-in tools. See [Sandboxes](/agents/docs/sandboxes).
42
+
- The `excludeTools` option turns tools off by name, so this reviewer can read and search files but can't run commands or change them. The `tools` option does the opposite and enables only the tools you list.
43
+
- The `executeBash` action runs a command in the agent's sandbox from your backend, without the model. It works even though the reviewer can't run `bash` itself. Its `excludeFromContext` option keeps the output out of the conversation.
44
+
- File tools only reach paths inside the sandbox's working directory. The `bash` tool accepts a timeout, and long output is truncated before it reaches the model.
44
45
45
46
To give an agent your own tools, see [Custom Tools](/agents/docs/custom-tools).
Copy file name to clipboardExpand all lines: agents/docs/content/docs/client-sdk.mdx
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,19 +41,19 @@ Call an agent from your backend, a script, or any JavaScript runtime with `rivet
41
41
42
42
## Handles and connections
43
43
44
-
-`createClient()` reads `RIVET_ENDPOINT`, `RIVET_NAMESPACE`, and `RIVET_TOKEN` from the environment, and defaults to a local Rivet at `localhost:6420`.
45
-
-`getOrCreate` returns a handle to the agent with that key, and creates the agent on first use. Actions called on the handle, like `getMessages`, are single requests.
46
-
-`connect()` opens a live connection that receives the session's events. Actions called before it opens wait until it does.
47
-
- A dropped connection reconnects on its own. `onStatusChange` reports `connecting`, `connected`, and `disconnected`, and `idle` after `dispose()` closes the connection for good.
44
+
-With no options, `createClient()` reads `RIVET_ENDPOINT`, `RIVET_NAMESPACE`, and `RIVET_TOKEN` from the environment, and defaults to a local Rivet at `localhost:6420`.
45
+
-The `getOrCreate` method returns a handle to the agent with that key, and creates the agent on first use. Actions called on the handle, like `getMessages`, are single requests.
46
+
-Calling `connect()` opens a live connection that receives the session's events. Actions called before it opens wait until it does.
47
+
- A dropped connection reconnects on its own. The `onStatusChange` callback reports `connecting`, `connected`, and `disconnected`, and `idle` after `dispose()` closes the connection for good.
48
48
49
49
## Events
50
50
51
-
`on("event", ...)` receives every event of the session as the agent works. See [Session Lifecycle](/agents/docs/session-lifecycle#events) for the event types.
51
+
A listener added with `on("event", ...)` receives every event of the session as the agent works. See [Session Lifecycle](/agents/docs/session-lifecycle#events) for the event types.
52
52
53
53
## Results and errors
54
54
55
-
-`prompt` resolves when the run ends. Read the reply with `getLastAssistantText` or `getMessages`.
56
-
-`prompt` rejects with an `ActorError` when the action itself fails. For example, another prompt is already running (pass `streamingBehavior` to queue it instead), the model has no credential (`model_unavailable`), or the run passes the ten-minute action timeout (`action_timed_out`).
55
+
-The `prompt` action resolves when the run ends. Read the reply with `getLastAssistantText` or `getMessages`.
56
+
-The `prompt` action rejects with an `ActorError` when the action itself fails. For example, another prompt is already running (pass `streamingBehavior` to queue it instead), the model has no credential (`model_unavailable`), or the run passes the ten-minute action timeout (`action_timed_out`).
57
57
- A model error doesn't reject. The run ends with an assistant message whose `stopReason` is `"error"`, and `errorMessage` explains why.
58
58
59
59
## Browsers
@@ -65,8 +65,8 @@ A browser shouldn't hold your Rivet credentials. Your backend checks who the use
Copy file name to clipboardExpand all lines: agents/docs/content/docs/connectors/discord.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,7 @@ Under **General Information**, set the interactions endpoint URL to `https://<yo
88
88
89
89
- The route verifies Discord's Ed25519 signature against the raw body with the application's public key.
90
90
- Each Discord channel gets its own agent. Every `/ask` in the channel continues the same session.
91
-
- Discord expects a response within three seconds and an agent run takes longer, so the route hands the command to the agent's `receive` action and defers the reply. `receive` schedules `reply`, which prompts the agent and edits the deferred message. Interaction tokens stay valid for 15 minutes, and a message holds up to 2,000 characters. The schedule is saved with the agent, so the reply still runs if the request that delivered the message goes away.
91
+
- Discord expects a response within three seconds and an agent run takes longer, so the route hands the command to the agent's `receive` action and defers the reply. The `receive`action adds the message to the agent's queue and schedules `drain`, which prompts the agent with the oldest message and edits the deferred message. Interaction tokens stay valid for 15 minutes, and a message holds up to 2,000 characters. A message that arrives while the agent is answering waits in the queue. The queue is saved with the agent, so replies still run if the request that delivered a message goes away.
92
92
93
93
## Configure
94
94
@@ -97,7 +97,7 @@ Under **General Information**, set the interactions endpoint URL to `https://<yo
97
97
|`DISCORD_PUBLIC_KEY`|**Required.** Verifies that requests come from Discord. |
98
98
|`DISCORD_APPLICATION_ID`| Registers the command. Not needed by the server. |
99
99
|`DISCORD_BOT_TOKEN`| Registers the command. Not needed by the server. |
100
-
|`ANTHROPIC_API_KEY`|**Required.** The agent's model key. See [API Keys](/agents/docs/api-keys). |
100
+
|`ANTHROPIC_API_KEY`|**Required.** The agent's model key. For another provider, change `model` and set its key instead, such as `OPENAI_API_KEY` or `OPENROUTER_API_KEY`. See [LLM API Keys](/agents/docs/api-keys). |
Copy file name to clipboardExpand all lines: agents/docs/content/docs/connectors/github.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ In the repository's **Settings > Webhooks**, add a webhook with the payload URL
76
76
- The route verifies GitHub's `X-Hub-Signature-256` signature against the raw body.
77
77
- Each issue or pull request gets its own agent, keyed by owner, repository, and number. Every mention in the thread continues the same session.
78
78
- The route only answers new comments that mention the bot, and never the bot's own comments, so replies do not loop.
79
-
- GitHub times out a delivery after ten seconds, so the route only hands the comment to the agent's `receive` action and returns. `receive` schedules `reply`, which prompts the agent and posts the answer as a comment with Octokit. The schedule is saved with the agent, so the reply still runs if the request that delivered the message goes away.
79
+
- GitHub times out a delivery after ten seconds, so the route only hands the comment to the agent's `receive` action and returns. The `receive`action adds the message to the agent's queue and schedules `drain`, which prompts the agent with the oldest message and posts the answer as a comment with Octokit. A message that arrives while the agent is answering waits in the queue. The queue is saved with the agent, so replies still run if the request that delivered a message goes away.
80
80
81
81
## Configure
82
82
@@ -85,7 +85,7 @@ In the repository's **Settings > Webhooks**, add a webhook with the payload URL
85
85
|`GITHUB_WEBHOOK_SECRET`|**Required.** Verifies that deliveries come from GitHub. |
86
86
|`GITHUB_TOKEN`|**Required.** Posts replies as the bot account. |
87
87
|`GITHUB_BOT_LOGIN`|**Required.** The bot's username. Comments that mention it start a reply. |
88
-
|`ANTHROPIC_API_KEY`|**Required.** The agent's model key. See [API Keys](/agents/docs/api-keys). |
88
+
|`ANTHROPIC_API_KEY`|**Required.** The agent's model key. For another provider, change `model` and set its key instead, such as `OPENAI_API_KEY` or `OPENROUTER_API_KEY`. See [LLM API Keys](/agents/docs/api-keys). |
Copy file name to clipboardExpand all lines: agents/docs/content/docs/connectors/linear.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ In Linear's **Settings > Administration > API**, which needs admin rights, creat
76
76
- The route verifies the `Linear-Signature` HMAC against the raw body and rejects deliveries older than a minute.
77
77
- Each Linear issue gets its own agent. Every comment with the trigger continues the same session.
78
78
- The route never answers the agent's own comments, so replies do not loop.
79
-
- The route only hands the comment to the agent's `receive` action and returns. `receive` schedules `reply`, which prompts the agent and posts the answer as a comment with the Linear SDK. The schedule is saved with the agent, so the reply still runs if the request that delivered the message goes away.
79
+
- The route only hands the comment to the agent's `receive` action and returns. The `receive`action adds the message to the agent's queue and schedules `drain`, which prompts the agent with the oldest message and posts the answer as a comment with the Linear SDK. A message that arrives while the agent is answering waits in the queue. The queue is saved with the agent, so replies still run if the request that delivered a message goes away.
80
80
81
81
## Configure
82
82
@@ -85,7 +85,7 @@ In Linear's **Settings > Administration > API**, which needs admin rights, creat
85
85
|`LINEAR_WEBHOOK_SECRET`|**Required.** Verifies that deliveries come from Linear. |
86
86
|`LINEAR_API_KEY`|**Required.** Posts replies as the agent's Linear user. |
87
87
|`LINEAR_TRIGGER`| Text that makes a comment start a reply. Defaults to `@agent`. |
88
-
|`ANTHROPIC_API_KEY`|**Required.** The agent's model key. See [API Keys](/agents/docs/api-keys). |
88
+
|`ANTHROPIC_API_KEY`|**Required.** The agent's model key. For another provider, change `model` and set its key instead, such as `OPENAI_API_KEY` or `OPENROUTER_API_KEY`. See [LLM API Keys](/agents/docs/api-keys). |
0 commit comments