[Question] What is the best practice for obtaining permission suggestedRules in the ReActAgent HITL flow?
When the permission system decides ASK, PermissionEngine.checkPermission auto-generates suggested rules and attaches them to the decision (PermissionDecision.getSuggestedRules()). The docs tell users to accept those rules via toolCall.getSuggestedRules() on the ToolUseBlock carried by RequireUserConfirmEvent — but ToolUseBlock has no such method, and the event carries no suggestions at all. Is there an intended way to obtain them when driving HITL through ReActAgent.streamEvents()?
Current Version is 2.0.3
Issue Evaluation
Category: bug (documentation/API mismatch) | Status: Confirmed — ToolUseBlock.getSuggestedRules() does not exist; the docs describe an API that was never implemented (verified against main @ c0d03ccea; latest published tag is v2.0.2, working tree revision 2.0.4-SNAPSHOT)
What is true in the code
- Suggested rules are produced in exactly one place and are attached to the decision, not the message:
PermissionEngine.checkPermission(...)returnsaskDecision.withSuggestedRules(tool.generateSuggestions(input))—agentscope-core/.../permission/PermissionEngine.java:152,:172,:201; getter isPermissionDecision.getSuggestedRules()—PermissionDecision.java:93. - The tool-call block has no such accessor.
ToolUseBlockis afinal class extends ContentBlockwith fieldsid,name,input,content,metadata,stateonly —agentscope-core/.../message/ToolUseBlock.java:39-44, getters at:126-174.grep -rn "getSuggestedRules"across all*.javain the repo hits onlyPermissionDecision.java:93plus tests (PermissionEngineTest,PermissionDecisionTest) — zero production callers. - The event carries nothing else.
RequireUserConfirmEventhas onlyreplyIdandtoolCalls—agentscope-core/.../event/RequireUserConfirmEvent.java:28-29,:52,:56— and it is constructed asnew RequireUserConfirmEvent(replyId, pending)atReActAgent.java:3050. - The point where the data is dropped:
ReActAgent.evaluateOnecollapses the decision to a bare enum —private record PermissionVerdict(ToolUseBlock use, PermissionBehavior behavior) {}(ReActAgent.java:3372), built fromdecision.getBehavior()(:3344-3351). Everything after that is aList<ToolUseBlock>, sosuggestedRulescannot be recovered from the stream.
The docs are wrong in four places, all of which are compile errors as written:
docs/v2/en/docs/building-blocks/agent.md:367(ToolUseBlock"exposing ...getSuggestedRules()"),:377,:397docs/v2/zh/docs/building-blocks/agent.md:367,:377,:397docs/v2/en/docs/building-blocks/permission-system.md:212anddocs/v2/zh/.../permission-system.md:212(toolCall.getSuggestedRules())
The runnable examples already know this: PermissionHITLExample.java:180-182 builds new ConfirmResult(approved, t) — the 2-arg overload (ConfirmResult.java:60) — and never passes rules, so the shipped path silently opts out of suggestion acceptance.
Resume contract that the suggestions must reach (this part does exist): ConfirmResult(boolean confirmed, ToolUseBlock toolCall, List<PermissionRule> rules) (ConfirmResult.java:55), and applyConfirmResults calls permissionEngine.addRule(rule) for each rule when confirmed is true (ReActAgent.java:2069-2085). So the plumbing on the way in is complete; only the way out is missing.
What you can do today
- Recompute from the tool instance — the same source the engine used, so results are identical:
ToolBase tool = (ToolBase) agent.getToolkit().getTool(tc.getName()); // name from ToolUseBlock List<PermissionRule> rules = tool.generateSuggestions(tc.getInput()); confirmResults.add(new ConfirmResult(true, tc, rules));generateSuggestionsis public and overridable (ToolBase.java:253; the default returns one tool-name-levelALLOWrule withsource = "suggested"). This is the fix direction PR #3238 took forpermission-system.md, but that PR touches only that file —agent.md:367/377/397(en + zh) still showstc.getSuggestedRules(). - Re-run the engine while paused:
agent.getPermissionEngine()is public (ReActAgent.java:4719), sogetPermissionEngine().checkPermission(tool, tc.getInput()).block().getSuggestedRules()returns the exact list the ASK was built from. Deterministic for the default implementation, but it re-evaluates policy, so treat it as a stopgap, not a documented pattern. - Build the rules explicitly yourself (
new PermissionRule(name, pattern, PermissionBehavior.ALLOW, "approved-by-user")). Note that today every auto-suggestion is indistinguishable from a user-authored one —sourceis hardcoded to"suggested"inToolBase.java:254— so there is no audit trail distinguishing an accepted suggestion from a hand-written rule.
Assessment / recommendation
There are two competing open fixes for this and the issue should be resolved by choosing one contract, not by merging both:
- PR #2916 (
fix(core): add ToolUseBlock.getSuggestedRules() implementation, +305/-28, currentlyCONFLICTING) makes the docs true by putting the rules on the block. - PR #3238 (
fix(doc): replace getSuggestedRules with generationSuggestions in ToolBase, mergeable) makes the code true by fixing one doc page.
A design caveat worth a maintainer's eye before either lands: ToolUseBlock is a serialized ContentBlock (metadata is documented as provider-specific), so a mutable rules field on it is both wire-format and semantic churn, and it is already being abused as a carrier for confirmation state (withState(ToolCallState.ALLOWED) at ReActAgent.java:2077). The smaller, better-scoped change is to carry the decision alongside the tool call on RequireUserConfirmEvent — e.g. List<PermissionDecision> or Map<String, List<PermissionRule>> keyed by toolCallId — which matches the documented "the event carries them" intent and leaves ContentBlock untouched. That is an agentscope-core API decision, so no bot-generated PR this tick; a maintainer can reply /approve (doc-only fix) or /revise <direction> to have one generated.
Automated evaluation by github-manager-bot
Issue Evaluation — follow-up (state change: PR #3238 closed)
Category: bug (docs describe a non-existent API) | Module: agentscope-core permission system + docs/v2 | Status: Still confirmed, and now with no open PR covering it (re-verified against main @ ed77530a4)
- PR #3238 was closed without merging (
state=CLOSED, updated2026-09-22T02:19:06Z), and PR #2916 (fix(core): add ToolUseBlock.getSuggestedRules() implementation) is stillCONFLICTING. The gap therefore remains onmain:ToolUseBlockstill has nogetSuggestedRules()— fields areid,name,input,content,metadata,state(agentscope-core/src/main/java/io/agentscope/core/message/ToolUseBlock.java:39-44, getters:126-174); the only implementation of that getter in the tree is on the decision object (PermissionDecision.getSuggestedRules(),.../permission/PermissionDecision.java:93, set inPermissionEngine.java:152,:172,:201).docs/v2/en/docs/building-blocks/agent.md:367,:377,:397and thezhtwins, plusdocs/v2/{en,zh}/docs/building-blocks/permission-system.md:212, still showtoolCall.getSuggestedRules()— all of which are compile errors as written.
- Concrete compatibility data point for choosing between the two competing contracts:
RequireUserConfirmEventis a Jackson-serialized event (@JsonCreator+@JsonProperty("id")/("createdAt")/("replyId")/("toolCalls")—agentscope-core/src/main/java/io/agentscope/core/event/RequireUserConfirmEvent.java:26-36). Adding asuggestedRules(orMap<String, List<PermissionRule>>keyed by tool-call id) field there is wire-visible but additive and nullable, so old consumers keep deserializing; putting the rules onToolUseBlockinstead changes a persisted polymorphicContentBlock, which is the larger blast radius (ToolUseBlockis already used as a state carrier viawithState(ToolCallState.ALLOWED)atReActAgent.java:2077).
What the bot can do now, on request:
- Doc-only fix (lowest risk, unblocks users today): correct the four stale spots in
agent.mdandpermission-system.md(en + zh) to the API that exists —ToolBase.generateSuggestions(input)(agentscope-core/src/main/java/io/agentscope/core/tool/ToolBase.java:253) on the tool instance, orPermissionDecision.getSuggestedRules()on the decision — and noteConfirmResult(confirmed, toolCall, rules)(ConfirmResult.java:55) as the resume contract. Purely additive doc edits, no API change. - Event-carrier fix (makes the documented intent true): carry the per-tool-call suggestions on
RequireUserConfirmEventas a nullable additive field, populate it whereReActAgent.evaluateOnecurrently collapses the decision to a bare enum (ReActAgent.java:3344-3351,:3372), and update the two doc pages to match.
Only the doc-only fix is uncontroversial enough to be generated without further decisions, and it is the same scope #3238 had — if its author or a maintainer wants it reopened in this shape, reply /approve (doc-only) or /revise event-carrier and the bot will prepare the PR against main.
Automated evaluation by github-manager-bot
Status: 72 h feedback window expired — no automated PR will be generated, the proposal window here is closed
The evaluation CTA above (5777151730, posted 2026-09-22T13:12:41Z) reached its 72-hour feedback limit at 2026-09-25T13:12:41Z with no own-line /approve, /revise, or /reject command in the thread, so per our workflow we skip PR generation and no competing PR will be filed from this proposal window. No action is needed from anyone.
This is a timing stand-down, not a verdict on the report. Measured on the thread at 2026-09-25T13:19Z: 0 replies of any kind after the CTA, 0 directive tokens, and 0 reactions on it — so there was nothing to act on, and no community member has claimed the work.
What is still true on main (re-verified this check at ea78c3172):
- The documented call
toolCall.getSuggestedRules()still does not exist onToolUseBlock. As ofea78c3172the only declaration in the tree isPermissionDecision.getSuggestedRules()(agentscope-core/src/main/java/io/agentscope/core/permission/PermissionDecision.java:93), whiledocs/v2/{en,zh}/docs/building-blocks/agent.md(:387,:397,:417) anddocs/v2/{en,zh}/docs/permission-system.md(:213) still call it on aToolUseBlock. The doc pages therefore remain uncompilable as written (the line numbers differ from the ones quoted in the CTA above becausemainmoved since 2026-09-22). - The two paths the CTA offered — a doc-only correction to
ToolBase.generateSuggestions(input)/PermissionDecision.getSuggestedRules(), or an additive nullablesuggestedRulescarrier onRequireUserConfirmEvent— were both left open for the community to choose between. Nobody chose.
One item worth flagging for a maintainer, because it is the reason this gap is not simply ours to close: PR #2916 (fix(core): add ToolUseBlock.getSuggestedRules() implementation) is still OPEN and unmerged at head 0d569211f487, and it currently reads CONFLICTING against main (last updated 2026-09-22T01:02:04Z). It targets the API-shape half of this question — the contract the docs describe — so whichever way the maintainers decide that contract, #2916 or its successor will carry the code change, and the doc correction should follow that decision rather than pre-empt it. The closed PR #3238 (doc-only scope) is not a carrier.
If an independent, bot-generated PR for either scope is still wanted despite #2916, open a fresh issue or leave a one-line approve doc-only / approve event-carrier request on this thread and the evaluation will be regenerated from the current main.
Automated by github-manager-bot
Update — this looks fixed on main and closable.
The confirmed defect here was "the docs describe an API that was never implemented". That text is gone:
-
PR #3293 — docs: fix verified doc-vs-code mismatches (MCP examples, HITL, defaults, tool names) (en+zh), merged 2026-09-26 (squash
00eb6868). It rewrites exactly the HITL passages, in both languages:docs/v2/{en,zh}/docs/building-blocks/agent.md— theRequireUserConfirmEventsection no longer listsgetSuggestedRules()among theToolUseBlockaccessors (nowgetId()/getName()/getInput()only), thetc.getSuggestedRules()sample is gone, and the "Build confirm results" step now states that suggested rules surface on the permission engine'sPermissionDecision, not on the tool call.docs/v2/{en,zh}/docs/building-blocks/permission-system.md— theConfirmResultsample now reads "ASK decisions carry suggested rules on thePermissionDecision(visible to permission hooks), not on theToolUseBlock."
-
Verified against current
main:getSuggestedRulesnow appears only inPermissionDecisionand its tests — no documentation file references it any more.
The direction taken is the docs-side one rather than adding the accessor: PR #2916 (fix(core): add ToolUseBlock.getSuggestedRules() implementation) was closed 2026-09-29 by @jujn with "fixed in: #3293". So the intended way to obtain the rules when driving HITL through ReActAgent.streamEvents() is the permission-hook / PermissionDecision path that the docs now describe.
The last evaluation comment on this thread (2026-09-25T13:24Z) predates the #3293 merge (2026-09-26T03:15Z), which is why it still reports the old state.