Repository navigation
feat(agent): 补齐轮次补充、排队、停止和结构化问答 - #239
Conversation
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
5 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| while state.events.len() > MAX_QUEUED_EVENTS || state.replay_bytes > MAX_REPLAY_BYTES { | ||
| if let Some(dropped) = state.events.pop_front() { | ||
| state.replay_bytes -= dropped.bytes(); | ||
| state.dropped_through = dropped.sequence; | ||
| } |
There was a problem hiding this comment.
🔴 Replay eviction strands permission requests
When output fills the replay budget, EventQueue::push can evict an unread permission request while the CLI waits. Live::list exposes the request ID but none of the choices. Refreshing cannot recover the prompt or let the user answer it.
Learn more
When a plugin reports a permission request, TurnState::apply_one saves the allowed choices and Live::report puts the full request in replay for the desktop host. The global byte cap can remove that request while the agent is still waiting, even when the event count is far below the count cap. On reopening the agent view, Live::list only returns pending permission IDs; neither the options nor their labels are in the interaction snapshot. respond_permission requires an option ID, and TurnState::decide rejects any ID the plugin did not offer. Replaying from an older cursor cannot recover the choices after eviction.
Example: One agent asks for permission with plugin-defined option IDs while the desktop host is not reading the feed. Another live agent reports 18 tool outputs of about 950 KiB each. When the host catches up, the first agent still waits for the decision, but the full request has been evicted. The host only has its ID and cannot display the choices.
Recommended fix: Retain each full pending permission request as bounded live-session state and expose it in agents.sessions or the current snapshot. Remove it on decision, turn end, or session exit. Test that a host can reconstruct and answer the request after unrelated output evicts its original replay event.
Was this helpful? React with 👍 or 👎 to provide feedback.
关联 Issue
Refs 1lck/Lithe-IDEA#2560
类型
feat
问题与改动
Agent 原生会话缺少运行中补充、下一轮排队和结构化问答,停止与完成竞争时也需要保证剩余任务不会自动启动。本 PR 在 API-45 内补齐通用交互状态机,桌面端只消费投影,工具专属协议由插件翻译。
agents.prompt区分默认send、queue和steer;补充绑定expectedTurn并等待工具确认。Review 修复
提交
f8fe577e316caff5c72063083ffede8fe859f413处理两项 review:acknowledge:[seq];推进游标、读取或退出不消费。容量不足时发送前返回agents.interactionBusy,用户文字仍在草稿。恢复副本不保留任意后端诊断正文,完整诊断仍在普通 replay。JSON 保留量基线(不是 native RSS):20×1 MiB replay 从 20,972,952 bytes 降至 15,729,717 bytes;3×128 KiB 排队与 64 次交互从 70 份快照/25,977,855 bytes 降至 1 份/393,591 bytes。16 MiB replay 和 16 MiB recovery 是各自预算,live state/每会话快照另计,不声称整个 runtime 固定 32 MiB。
本轮
agents.waitEvents是宿主 C ABI 命令扩展,四语 SDK 没有此 wrapper;SDK 源码无需为此变化,现有四语 e2e 16 项已复验通过。契约、API 索引和协议变更记录已在同一提交更新,版本不变。公共接口
agents/reportagents/didPromptagents/didCancelagents/didAnswerQuestionagents.promptagents.updateQueueagents.respondQuestionagents.waitEvents兼容、权限与日志
不提升
pluginAPIVersion、schemaVersion、agents或litheFunctions版本;不写 mode 继续使用原 send 行为,未声明能力的插件不开放 steering/questions。旧 Core 保持严格拒绝新字段和事件,新插件需等待包含扩展的宿主发布后才能稳定交付。本 PR 不发版。操作沿用用户发起、可信本地工作区和已有 Agent 运行权限约束。Core 新增
agent.interaction.failed目录事件,只记录插件、session、method、稳定 code;不记录提示、回答、CLI 消息正文。补充失败由 Core 记录唯一终态,问答 handler 失败由 SDK 记录,主动取消不记录错误。稳定 Core 码包括 steeringUnavailable、turnChanged、queueFull、turnStopping、questionNotPending、invalidQuestionAnswer、inputNotQueued、interactionBusy;未分配新的 JSON-RPC 数字码,既有 host 错误复用原分类。契约逐项说明拒绝、重试与生命周期。
验证
cargo test --manifest-path rust/Cargo.toml -p lithe-agent-runtime --all-targets:39 项通过;包括主动取消恢复输入的失败前/修复后回归。lithe-agent-runtime、lithe-plugin-rpcclippy:全部 feature、全部 target,通过。node shared/plugins/scripts/verify-docs.mjs通过。node shared/plugins/scripts/sdk-e2e.mjs:四语 SDK 16 项通过。.artifacts/test-stability/agent-turn-review.{html,xml}。组件与 SDK e2e 不等于真实 CLI 或目标平台原生整机验收;后者仍 pending。仅验证本次受影响范围,其他检查交 CI。
范围与依赖
/命令、ACP 和完整 transcript 归约迁移不在本次范围;既有归约债务为 [Feature] 将 Agent 会话事件归约、操作可用性和变更文件投影从 Go 桌面层迁入 Rust Core 1lck/Lithe-IDEA#2552。f8fe577e316caff5c72063083ffede8fe859f413;本 PR 只保留通用契约、SDK 与合成测试,不依赖真实插件。先完成 Core 依赖,再合入宿主;插件稳定交付等待包含扩展的宿主发布。