feat: session-level "always allow" for tool approvals - #7
Open
Feelings0220 wants to merge 1 commit into
Open
Feelings0220 wants to merge 1 commit into
Feelings0220 wants to merge 1 commit into
Conversation
Adds an 'Always allow (session)' option to the tool approval card. When chosen, the approval decision carries always_allow=true through the HITL payload; the Go runtime records the tool name in session state (kagent_approved_tools) and skips the confirmation round-trip for that tool for the rest of the session. - go/adk hitl: plumb always_allow through HitlConfirmationPayload - go/adk approval callback: consult/record session allow list - UI: new secondary button on the approval card wired through ToolCallDisplay/ChatMessage/ChatInterface Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016d9SxeefoRSLZmQ1oKo17j
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.
概述
工具审批卡片新增 Always allow (session) 按钮:本次批准后,同一会话内该工具后续调用不再弹出审批,直接执行。会话结束后失效(作用域严格为单个会话)。
实现
Go 运行时(go/adk)
pkg/a2a/hitl.go:HitlConfirmationPayload新增always_allow字段,随 HITL 决策消息透传(ToMap/ParseHitlConfirmationPayload/ProcessHitlDecision全链路)。pkg/agent/approval.go:kagent_approved_tools(无 app:/user: 前缀 ⇒ 会话级作用域)。MakeApprovalCallback:调用前先查会话允许列表,命中则跳过确认;批准时若 payload 带always_allow=true则把工具名记入允许列表。pkg/agent/approval_test.go:表驱动测试 7 个用例(未纳管工具直通 / 首次请求确认 / 普通批准 / always_allow 记忆 / 已记忆跳过 / JSON 回环形状 / 拒绝返回原因)。UI
ToolDisplay.tsx:审批卡片新增次级按钮 "Always allow (session)"。ToolCallDisplay.tsx/ChatMessage.tsx/ChatInterface.tsx:onApproveAlways回调逐层下传,最终发送{ decision_type: "approve", always_allow: true }。验证
go build ./adk/...、go test ./adk/pkg/agent/ ./adk/pkg/a2a/✅(7/7 新用例通过)npx tsc --noEmit(源代码无新增错误)、npx jest(282 通过)、npx eslint(改动文件 0 问题)、npm run build✅设计文档
见
reports/session-approvals-plan.md。🤖 Generated with Claude Code
https://claude.ai/code/session_016d9SxeefoRSLZmQ1oKo17j
Generated by Claude Code