Skip to content

feat(pi): define tools and hooks like actions, with the actor's context - #398

Merged
eersnington merged 4 commits into
mainfrom
stack/feat-pi-define-tools-and-hooks-like-actions-with-the-actor-s-context-lsnzrvrm
Nov 17, 2026
Merged

eersnington merged 4 commits into
mainfrom
stack/feat-pi-define-tools-and-hooks-like-actions-with-the-actor-s-context-lsnzrvrm

Conversation

@NathanFlurry

@NathanFlurry NathanFlurry commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

pi() takes tools and hooks keyed by name. A tool's
execute(c, args, api, context) and every Pi Durable hook, such as
beforeTool(c, call, api, context), get the actor's context first, typed
from the actor's state and vars, so a tool can read c.key, use c.db
and c.pi, and call other actors through c.client().

The harness opens with the actor's context as a context value. Pi derives
every task's context from the one it opens with, so the wrappers find the
actor after a wake and in conversations a tool creates. They are installed
as the rivet-pi-actor extension. registry is now optional and still
works alongside tools.

The docs example keeps its data in c.db, because RivetKit 3 deprecates c.state.


This is part 4 of 6 in a stack:

NathanFlurry commented Nov 16, 2026 •

Copy link
Copy Markdown
Member Author

Stack for rivet-dev/agents

Get stack: forklift get 398
Push local edits: forklift submit
Merge when ready: forklift merge 398

change lsnzrvrm

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

📟 Pip-Boy · ef3efb1

📦 Packages · fresh npm install resolve, no lockfile · this PR vs base

package (linux-x64-gnu) @latest base this PR Δ vs base packages
@rivet-dev/pi 392.6 MB 392.6 MB 392.6 MB +15.4 KB (+0.0%) 220 (0)
`@rivet-dev/pi` details
platform base this PR Δ
linux-x64-gnu 392.6 MB 392.6 MB +15.4 KB (+0.0%)
linux-arm64-gnu 371.7 MB 371.8 MB +15.4 KB (+0.0%)
darwin-arm64 269.5 MB 269.5 MB +15.4 KB (+0.0%)
darwin-x64 280.4 MB 280.5 MB +15.4 KB (+0.0%)
win32-x64 188.5 MB 188.6 MB +15.4 KB (+0.0%)

Entrypoints (own code, minified; third-party imports excluded)

entrypoint base this PR Δ imports exports
. 37.2 KB 38.6 KB +1.4 KB (+3.7%) — +PiHooks +PiTool +PiToolContext
./durable 37.2 KB 38.6 KB +1.4 KB (+3.7%) — +PiHooks +PiTool +PiToolContext
All 10 packages · linux-x64-gnu
package (linux-x64-gnu) @latest base this PR Δ vs base packages
@rivet-dev/pi 392.6 MB 392.6 MB 392.6 MB +15.4 KB (+0.0%) 220 (0)
@rivet-dev/sandbox-adapter 114.5 KB 114.5 KB 114.5 KB 0 1 (0)
@sandbox-agent/cli-shared 27.2 KB 27.2 KB 27.2 KB 0 1 (0)
@sandbox-agent/persist-indexeddb 12.4 KB 12.4 KB 12.4 KB 0 1 (0)
@sandbox-agent/persist-postgres 12.3 KB 12.3 KB 12.3 KB 0 1 (0)
@sandbox-agent/persist-rivet 12.2 KB 12.2 KB 12.2 KB 0 1 (0)
@sandbox-agent/persist-sqlite 12.3 KB 12.3 KB 12.3 KB 0 1 (0)
@sandbox-agent/react 41.6 MB 41.9 MB 41.9 MB 0 15 (0)
acp-http-client 6.7 MB 6.7 MB 6.7 MB 0 3 (0)
sandbox-agent 31.0 MB 31.0 MB 31.0 MB 0 8 (0)

🧹 Rust dependencies

Skipped: this PR doesn't change any Rust code or dependencies.

🦀 Binaries

Skipped: this PR doesn't change any Rust code.

⏱ Timing

job wall time slowest step
zizmor 19s checkout · 10s
changes 16s checkout · 13s
footprint 2m30s Run pnpm --dir sandbox-agent install --frozen-lockfile · 56s
⏭ self-test — skipped
⏭ native · ${{ matrix.platform }} — skipped
⏭ hygiene — skipped
report 22s checkout · 10s
🔭 Full CI trace for this commit

One OpenTelemetry trace of CI and Pip-Boy for ef3efb1: every job and step, with the sizes above attached. Run after CI finishes.

pnpm install --frozen-lockfile --filter 'pipboy...'
pnpm --filter pipboy pipboy trace --sha ef3efb114a2eafa66a04eb2d8c69d4f3f9fcc328

Add --otlp <url> to send it to any OTLP/HTTP collector.

Agent instruction: From a rivet-dev/agents checkout, run the commands above, then read the trace file the last command prints. List the slowest jobs and steps and explain where CI time went.

@eersnington
eersnington force-pushed the stack/feat-pi-define-tools-and-hooks-like-actions-with-the-actor-s-context-lsnzrvrm branch from 1a1207d to 3c425ed Compare November 16, 2026 12:30
@eersnington
eersnington changed the base branch from main to chore/pi-tests-drop-duplicates November 16, 2026 12:31
Base automatically changed from chore/pi-tests-drop-duplicates to main November 17, 2026 14:08
eersnington and others added 3 commits November 17, 2026 18:11
The squash merge of #403 added the test "a commit that fails during a run
reopens the harness at once" a second time. The second copy shares the
poisonRuns counter with the first, so it waits for a count that is already
past, and fails.
pi() takes `tools` and `hooks` keyed by name. A tool's
`execute(c, args, api, context)` and every Pi Durable hook, such as
`beforeTool(c, call, api, context)`, get the actor's context first, typed
from the actor's state and vars, so a tool can read `c.key`, read and
write `c.state`, use `c.pi`, and call other actors through `c.client()`.

The harness opens with the actor's context as a context value. Pi derives
every task's context from the one it opens with, so the wrappers find the
actor after a wake and in conversations a tool creates. They are installed
as the `rivet-pi-actor` extension. `registry` is now optional and still
works alongside `tools`.
…esults

- The docs example stores its data with c.db, since RivetKit 3 deprecates
  c.state.
- The interrupted-tool test calls nothing before the tool reruns, so a call
  cannot resume the run for it.
- The registry-tool test checks the tool's own result, not the scripted reply.
- The tests keep per-generation data in c.vars.
@eersnington
eersnington force-pushed the stack/feat-pi-define-tools-and-hooks-like-actions-with-the-actor-s-context-lsnzrvrm branch from 3c425ed to 63fcdd4 Compare November 17, 2026 14:12
@eersnington
eersnington changed the base branch from main to fix/pi-duplicate-poison-test November 17, 2026 14:12
Base automatically changed from fix/pi-duplicate-poison-test to main November 17, 2026 14:17
- Two actors prompted at the same time each refund into their own vars
  and ledger.
- Drops the hasPi field, which was always true or never recorded. The
  refund tool still reads c.pi, so a missing harness fails it.
- The docs example creates its table once in onWake.
@eersnington
eersnington merged commit 4cd7e2e into main Nov 17, 2026
10 checks passed
@eersnington
eersnington deleted the stack/feat-pi-define-tools-and-hooks-like-actions-with-the-actor-s-context-lsnzrvrm branch November 17, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants