feat(adk): record permission resume decisions#1070
Merged
Conversation
Change-Id: I38cc39c3a0a7d5f35ddf61937de860971b1b0031
ac55d5b to
e1b8951
Compare
Change-Id: Ide870e5a104ff595300bf2bba7b1ca4a1da2e65c
Change-Id: I128434ec8500151f480082149f63f37fb838ee15
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## alpha/10 #1070 +/- ##
===========================================
Coverage ? 83.09%
===========================================
Files ? 172
Lines ? 28230
Branches ? 0
===========================================
Hits ? 23457
Misses ? 3213
Partials ? 1560 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Permission resume decisions need to be durable timeline facts, not only transient tool-wrapper control flow. Without a recorded decision event, a session can show the ask interrupt but lose the user's approve/reject/respond choice, which makes audit and reconstruction incomplete.
Extension events also need a clear typed payload contract. Middleware-owned durable payloads should round-trip as registered concrete types.
Solution
Record valid permission resume choices as
x.permission.decisionsession extension events before the resumed tool behavior is applied. The event carries the action, tool identity, optional decision text, and explicitUpdatedInputintent.Use typed extension payloads for durable extension events. Custom payload types that need durable round-trip behavior must be registered with
schema.RegisterNamebefore session events are encoded and decoded.Invalid
respondresumes are rejected before a decision event is emitted, so the session timeline only records decisions that can actually drive execution.Key Insight
The permission gate has two distinct boundaries: resume validation and tool execution. Decision emission belongs after validation but before tool execution, because that is the first point where the user decision is known to be semantically valid and can still be persisted through the Runner-owned session timeline.
Summary
SessionEventPermissionDecisionfor valid resume decisionsUpdatedInputcould be confused with absent inputHasUpdatedInputSessionExtensionEvent.DataTypedSendEventa no-op when no generator is available问题
permission resume decision 需要成为持久化的 timeline fact,而不只是 tool wrapper 内部的临时控制流。否则 session 里可以看到 ask interrupt,却丢失用户最终选择了 approve/reject/respond,审计和重放语义都不完整。
extension event 也需要明确的 typed payload contract。middleware 自己产生的 durable payload 应该以注册过的具体类型完成 round-trip。
解决方案
在 resumed tool 行为生效前,把合法的 permission resume choice 记录为
x.permission.decisionsession extension event。事件包含 action、tool identity、可选 decision text,以及显式的UpdatedInput意图。durable extension event 使用 typed extension payload。需要 durable round-trip 的自定义 payload 类型,必须在 session event 编解码前通过
schema.RegisterName注册。非法的
respondresume 会在事件写入前被拒绝,因此 session timeline 只记录真正能驱动执行的有效 decision。关键洞察
permission gate 有两个边界:resume validation 和 tool execution。decision event 应该在 validation 之后、tool execution 之前写入,因为这是用户 decision 首次具备明确语义的位置,同时仍处在 Runner 拥有的 session timeline 持久化通道中。
总结
SessionEventPermissionDecisionUpdatedInput容易和未更新混淆HasUpdatedInput保留用户意图SessionExtensionEvent.Data中保存注册过的具体 payload 类型TypedSendEventno-op