feat(server): collect runtimes after one idle hour with optional provider vetoes

Keep callers resident while local or remote finish notification intent remains outstanding. Daemon-owned work determines baseline eligibility; provider checks add optional vetoes. Own the idle clock and sweep lifecycle in one cleanup module while the manager retains guarded closure.
This commit is contained in:
Mohamed Boudra
2026-10-24 08:05:51 +02:00
parent 74d2c46f9b
commit 0e1e85e323
17 changed files with 626 additions and 268 deletions
+4 -3
View File
@@ -86,8 +86,8 @@ See [Providers](/docs/providers) for the mental model and [Supported providers](
## Idle runtimes
Paseo releases resumable idle agent processes after 30 minutes when the provider confirms that no
background work needs the runtime. Your next prompt resumes the same conversation. Disable this
Paseo releases resumable idle agent processes after one hour when its daemon baseline allows
cleanup and any implemented provider check agrees. Your next prompt resumes the same conversation. Disable this
for the entire host with:
```json
@@ -95,7 +95,8 @@ for the entire host with:
```
This setting defaults to `true` and requires a daemon restart to change. There is no per-agent
setting. Providers without a runtime safety check stay resident.
setting. Providers without a runtime safety check use the same daemon baseline and one-hour idle
period. Active work, descendants and pending finish notifications prevent cleanup.
## Worktrees
+2 -2
View File
@@ -84,13 +84,13 @@ Agent Provider,包括 Paseo 自带的一等 Provider 和你在 `agents.provide
## 空闲运行时 {#idle-runtimes}
当 Provider 确认没有后台工作需要运行时时,Paseo 会在可恢复的 Agent 空闲 30 分钟后释放其进程。你的下一条提示词会恢复同一个会话。要为整个主机禁用此功能,请设置:
当 daemon 的基础条件允许清理,且 Provider 已实现的安全检查也允许时,Paseo 会在可恢复的 Agent 空闲一小时后释放其进程。你的下一条提示词会恢复同一个会话。要为整个主机禁用此功能,请设置:
```json
{ "agents": { "idleRuntimeCleanup": false } }
```
此设置默认为 `true`,更改后需要重启 daemon。没有单个 Agent 的设置。不提供运行时安全检查的 Provider 会保持驻留。
此设置默认为 `true`,更改后需要重启 daemon。没有单个 Agent 的设置。不提供运行时安全检查的 Provider 使用相同的 daemon 基础条件和一小时空闲期。活动中的工作、后代 Agent 和待发送的完成通知都会阻止清理。
## worktree {#worktrees}
+10 -7
View File
@@ -308,9 +308,10 @@ can replace the active turn instead.
## Permit idle runtime cleanup
Paseo can release an idle resumable session after 30 minutes. Opt in by advertising
`session.can_stop_runtime` on the connection and the session's `session.opened` capabilities.
Without this capability your sessions stay resident. Older plugins receive no new request.
Paseo can release an idle resumable session after one hour when its daemon baseline allows cleanup.
Add a provider-owned veto by advertising `session.can_stop_runtime` on the connection and the
session's `session.opened` capabilities. Without this capability, the same baseline and one-hour
idle period apply, and the plugin receives no safety request.
Handle the safety query in your existing `send(input)` handler. It addresses the provider's own
session ID, including when one connection serves several sessions:
@@ -343,10 +344,12 @@ queued completion reports, or pending autonomous replies. This query must not st
session. Return `false` while work remains. A rejected query, invalid response, or timeout also
keeps the runtime alive. Never respond with `request.completed` for this query.
Paseo checks its own foreground turns, permissions, queued messages, and managed descendants,
then rechecks activity before calling the existing `session.close` operation. A positive safety
response permits collection; it does not request it. After protected work finishes, a fresh
30-minute idle period starts. The saved provider persistence must resume the same conversation.
Paseo always checks foreground work, permissions, queued deliveries, lifecycle operations,
working managed/native descendants, and outstanding local or remote finish subscriptions for the
caller. Subscription protection lasts through registration, recovery and notification dispatch
acknowledgment. A positive provider response never overrides these blockers. Paseo rechecks
activity before the existing `session.close` operation. After protected work finishes, a fresh
one-hour idle period starts. The saved provider persistence must resume the same conversation.
The host setting `agents.idleRuntimeCleanup: false` disables collection for every provider.
## Publish timeline items
+2 -2
View File
@@ -271,7 +271,7 @@ Paseo 刷新 Agent 的方式是关闭它当前的 Provider 会话,然后用当
## 允许清理空闲运行时 {#permit-idle-runtime-cleanup}
Paseo 可以在可恢复的会话空闲 30 分钟后释放其运行时。要启用此功能,请在连接和会话的 `session.opened` capabilities 中声明 `session.can_stop_runtime`。没有此能力的会话会保持驻留。旧版插件不会收到新请求。
当 daemon 的基础条件允许清理时,Paseo 可以在可恢复的会话空闲一小时后释放其运行时。在连接和会话的 `session.opened` capabilities 中声明 `session.can_stop_runtime`,即可添加 Provider 自己的否决检查。没有此能力时,会话仍使用相同的基础条件和一小时空闲期,插件不会收到安全查询。
在现有的 `send(input)` 处理函数中处理安全查询。请求使用 Provider 自己的会话 ID,包括同一连接服务多个会话的情况:
@@ -299,7 +299,7 @@ case "session.can_stop_runtime": {
`canStopRuntime(): Promise<boolean>` 由你的 Provider 会话实现。只有释放运行时不会丢失后台 shell、监控任务、原生子 Agent、排队的完成报告或待处理的自主回复时,才返回 `true`。此查询不得停止或修改会话。仍有工作时返回 `false`。查询拒绝、响应无效或超时也会保留运行时。不要用 `request.completed` 响应此查询。
Paseo 会检查自己管理的前台轮次、权限、排队消息和托管后代 Agent,然后在调用现有的 `session.close` 操作之前重新检查活动。肯定的安全响应允许清理,但不会请求清理。受保护的工作完成后,会重新开始 30 分钟的空闲期。保存的 Provider 持久化数据必须能恢复同一个会话。主机设置 `agents.idleRuntimeCleanup: false` 会禁用所有 Provider 的清理。
Paseo 始终检查前台工作、权限、排队投递、生命周期操作、工作中的托管或原生后代 Agent,以及调用方尚未完成的本地或远程完成通知订阅。订阅保护覆盖注册、恢复,直到通知投递获确认。Provider 返回 `true` 也不能绕过这些阻止条件。Paseo 会在调用现有的 `session.close` 操作之前重新检查活动。受保护的工作完成后,会重新开始一小时的空闲期。保存的 Provider 持久化数据必须能恢复同一个会话。主机设置 `agents.idleRuntimeCleanup: false` 会禁用所有 Provider 的清理。
## 发布时间线条目 {#publish-timeline-items}