@agimon-ai/po-autostop

Shuts a Po session down once the agent settles and stays idle.

Packages

Package details

extension

Install @agimon-ai/po-autostop from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@agimon-ai/po-autostop
Package
@agimon-ai/po-autostop
Version
0.0.0-alpha.40
Published
Oct 21, 2026
Downloads
3,768/mo · 3,768/wk
Author
agiflow-ai
License
BUSL-1.1
Types
extension
Size
94.3 KB
Dependencies
2 dependencies · 1 peer

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@agimon-ai/po-autostop

Shuts a Po session down once the agent settles and stays idle.

A scripted run wants the session to exit on its own when the work is done. Waiting for agent_settled alone is not enough: the agent can settle and immediately pick up a queued message, and it can settle while the last response is still streaming. So this package settles, waits, looks again, and only then stops.

The policy

Moment Session state Outcome
agent_settled messages queued stand down
agent_settled queue empty look again in 5s
the scheduled look messages queued stand down
the scheduled look background runner or agent active look again in 5s
the scheduled look still streaming look again in 100ms
the scheduled look idle, queue and background empty context.shutdown()

An agent_start event disarms a pending stop. The cooldown is the grace period; the 100 ms recheck waits out a stream that has not finished draining. Supervised Runner processes (po-runner) hold while running or awaiting asynchronous completion admission (published without a status). Running commands stop holding after five minutes of settled background-work waiting. A new turn resets that clock. Shutdown uses Runner's existing cleanup to stop the commands. A runner listed as completed or failed no longer counts. Owned subagents (team-direct-runs, po-task), pending completion admission and holding-provider errors still hold after the deadline. The holding rule is shared with inline workflow step supervision through core's background-work predicates. Workflow runs (workflow-mcp) do not hold a session open.

Each wait is recorded as po_autostop.waiting_on_background_work telemetry naming the work holding the session, along with po_autostop.stood_down and po_autostop.shutdown_requested.

The idle shutdown watch adds the authoritative background-work gate before the policy may stop the session.

License

Business Source License 1.1: free for personal use, organisations under USD 1M revenue, non-profits and education. See LICENSE and https://agimon.ai/licensing.