@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.232
Published
Dec 6, 2026
Downloads
33.5K/mo · 7,611/wk
Author
agiflow-ai
License
MIT
Types
extension
Size
92.7 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.

po_autostop.waiting_on_background_work is reported on the first hold and at most once a minute after that. It includes item and provider error details, counts, elapsed wait and deferral count. Separate events report po_autostop.stood_down and po_autostop.shutdown_requested. Telemetry delivery is not verified live.

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

License

MIT. See LICENSE.