pi-agent-integration
Skill365 starsChanged 8 months agoApache-2.0View on GitHub
Guides implementation and review of the latest `@earendil-works/pi-agent-core` API. Use when a task mentions Pi `Agent`, agent loops, streaming, tools, queues, continuation, proxying, aborts, sessions, skills, compaction, or the current `AgentHarness` scaffold.
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- packages/docs/public/llms.txtllms.txt
- nitroSkill
- public-docsSkill
- slack-developmentSkill
- vercel-queuesSkill
- vercel-sandboxSkill
- example-bundle-helpSkill
- example-localSkill
- agent-browserSkill
- demo-videoSkill
- visual-web-qaSkill
- amplitudeSkill
- cloudflareSkill
- datadogSkill
- coding-workspace-fixtureSkill
- github-headless-pr-fixtureSkill
- eval-guardian-actionsSkill
- eval-authSkill
- eval-directorySkill
- eval-mcpSkill
- eval-oauthSkill
- eval-operationSkill
- incident-briefSkill
- resilient-working-directorySkill
- source-handbookSkill
- weather-lookupSkill
- github-codeSkill
- github-issuesSkill
- hexSkill
- linearSkill
- self-updateSkill
- notionSkill
- octolensSkill
- sentrySkill
- jr-rpcSkill
- eval-authSkill
- eval-mcp-openSkill
- ttsSkill
- vercelSkill
- junior-qaSkill
- juniorSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 6 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Check npm latest for @earendil-works/pi-agent-core before relying on a contract.
- Very specific: line 23
Use Agent when event handling must finish before run settlement.
- Very specific: line 26
Do not call prompt(), continue(), or reset() while an agent is active.
- Very specific: line 28
Keep streamFn, convertToLlm, transformContext, getApiKey, queue providers, and loop hooks no-throw for expected failures.
- Distinctive: line 29
Keep tool calls, progress, results, thinking deltas, and provider payloads internal unless the product exposes them on purpose.
- Very specific: line 34
Prefer Pi options over wrapper state machines: streamFn, getApiKey, sessionId, thinkingBudgets, transport, maxRetryDelayMs, onPayload, …
- Very specific: line 36
Use transformContext for message-level pruning or injection.
- Very specific: line 38
Use streamFn with streamProxy-style behavior for server-proxied model access.
- Very specific: line 39
Use toolExecution, per-tool executionMode, beforeToolCall, afterToolCall, thrown tool errors, and terminate before adding a custom tool …
- Distinctive: line 40
Keep timeout and abort paths observable.
- Distinctive: line 44
Verify the event bridge emits only text deltas, preserves intended boundaries, and closes on success, error, and abort.
- Very specific: line 45
Verify active-run handling for prompt(), continue(), and reset().
- Very specific: line 46
Verify continue() with empty history and with user, toolResult, and assistant tails.
- Very specific: line 47
Verify custom messages remain in agent state while convertToLlm emits only provider-compatible messages.
- Very specific: line 48
Verify streamFn encodes expected provider failures instead of throwing or rejecting.
- Distinctive: line 49
Verify parallel and sequential tool ordering, hook blocking and patches, progress updates, usage, added tools, and termination.
- Very specific: line 50
Verify Agent.subscribe() listener settlement and waitForIdle() with async listeners.
- Very specific: line 51
When reviewing the AgentHarness scaffold, verify implemented status in the published source before recommending any method.
- Distinctive: line 57
Do not present unreleased main behavior as published behavior.
- Distinctive: line 58
Do not add compatibility shims or old package guidance unless the user asks for a migration.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Implement Pi consumers against the latest published API. Keep streaming stable, queue behavior explicit, and wrapper code small.
Step 1: Classify the request
| Request type | Read first |
Wire or update Agent, loop, provider, stream, or tool APIs | references/api-surface.md |
| Add Pi behavior in an app, library, runtime, or adapter | references/common-use-cases.md |
Use AgentHarness, sessions, skills, resources, compaction, or execution helpers | references/harness.md |
| Debug streaming, tools, queues, continuation, proxy, abort, or harness failures | references/troubleshooting-workarounds.md |
Load each reference that the task needs. Keep guidance Pi-specific unless the user asks about a consuming product.
Step 2: Apply integration guardrails
- Check npm
latestfor@earendil-works/pi-agent-corebefore relying on a contract. Treat the published package as authoritative. Treat upstreammainas unreleased evidence. - Pass a
streamFnwhen constructingAgent. Also pass it as the last argument to low-level loop functions. - Use
Agentwhen event handling must finish before run settlement. UseagentLooponly when an observational event stream is enough. - Stream user-visible text only from
message_updatewhenassistantMessageEvent.type === "text_delta". - Preserve assistant message boundaries when forwarding multi-message output.
- Do not call
prompt(),continue(), orreset()while an agent is active. Queue mid-run input withsteer()orfollowUp(). - Continue a normal run only from a non-empty
userortoolResulttail. Anassistanttail can only drain queued steering or follow-up messages. - Keep
streamFn,convertToLlm,transformContext,getApiKey, queue providers, and loop hooks no-throw for expected failures. Return safe values or encode the failure in stream events. - Keep tool calls, progress, results, thinking deltas, and provider payloads internal unless the product exposes them on purpose.
- In
0.84.1, do not recommendAgentHarnessrun, queue, hook, or navigation paths for production use. They are scaffold APIs and most reject withHarnessNotImplemented. Use bareAgent, session APIs, and standalone helpers until the published implementation is complete.
Step 3: Implement with minimal surface
- Prefer Pi options over wrapper state machines:
streamFn,getApiKey,sessionId,thinkingBudgets,transport,maxRetryDelayMs,onPayload,onResponse,beforeToolCall,afterToolCall,shouldStopAfterTurn,prepareNextTurnWithContext,toolExecution,steeringMode, andfollowUpMode. - Mutate
Agentthroughagent.stateand public runtime options. Callreset()only when idle. - Use
transformContextfor message-level pruning or injection. UseconvertToLlmfor provider-compatible role conversion and filtering. - Set queue modes to
"one-at-a-time"or"all"when ordering or batching matters. - Use
streamFnwithstreamProxy-style behavior for server-proxied model access. - Use
toolExecution, per-toolexecutionMode,beforeToolCall,afterToolCall, thrown tool errors, andterminatebefore adding a custom tool runner. - Keep timeout and abort paths observable. Make sure streams and iterables settle.
Step 4: Verify behavior
- Verify the event bridge emits only text deltas, preserves intended boundaries, and closes on success, error, and abort.
- Verify active-run handling for
prompt(),continue(), andreset(). Verify queuedsteer()andfollowUp()behavior. - Verify
continue()with empty history and withuser,toolResult, andassistanttails. - Verify custom messages remain in agent state while
convertToLlmemits only provider-compatible messages. - Verify
streamFnencodes expected provider failures instead of throwing or rejecting. - Verify parallel and sequential tool ordering, hook blocking and patches, progress updates, usage, added tools, and termination.
- Verify
Agent.subscribe()listener settlement andwaitForIdle()with async listeners. - When reviewing the
AgentHarnessscaffold, verify implemented status in the published source before recommending any method.
Step 5: Keep version discipline
- Target npm
latestonly. - Re-check package metadata, declarations, implementation, README, and changelog before a material API update.
- Do not present unreleased
mainbehavior as published behavior. - Do not add compatibility shims or old package guidance unless the user asks for a migration.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

