Skip to content

Thread scheduled runs and refuse classes whose tool approvals cannot be raised - #87

Open
josephschorr wants to merge 9 commits into
mainfrom
bento-opening-and-rawzed-standing
Open

josephschorr wants to merge 9 commits into
mainfrom
bento-opening-and-rawzed-standing

Conversation

@josephschorr

@josephschorr josephschorr commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Two fixes for sessions that no person started, both found from one failing scheduled run.

Scheduled runs get their own thread

A session started by a schedule had no opening message, so its thread was rooted by whatever the agent posted first. A run that sent a single reply showed up as a bare message in the channel, with no thread and nowhere for progress updates to appear.

Scheduled sessions now open their thread with a line naming the schedule, the same way sessions started by a pull request already do, and the agent's output lands beneath it.

The tool that lets an agent update that opening message is now offered only to sessions that actually have one. Previously it was offered to every session of a kind that can post opening lines, including ones that never got a line.

An AgentClass is refused when a tool approval could never be raised

A tool's permission check can name a resource type that has no declared standing. Such a class looked healthy, but the first denied call failed outright because there was no way to decide who could approve it.

The AgentClass now reports Valid=False with reason ToolApprovalUnroutable, naming the tool and the resource type, whenever that failure is certain:

  • enforcing mode: any check on a type with no standing
  • permissive mode: only tools that always ask for approval, or checks marked to always enforce
  • disabled mode: never

Only tool calls the class can actually make are considered. A toolkit subcommand that the class's toolspecs do not allow is ignored, since it can never run: if an agent tries one anyway, the call is refused outright, before any permission is checked or approval requested.

Upgrade note

An existing class that has a tool check on a resource type with no standing, and runs in a mode where a denial asks for approval, will become Valid=False after upgrading. The condition message says which type needs a standing declared. Checks on tool calls the class cannot make do not count, so a class is never refused over a subcommand it does not allow.

Testing

Unit tests cover both changes, including a check that every toolkit shipped in this repository passes the new rule in enforcing mode.

@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
openagentprimitives Ignored Ignored Preview Dec 4, 2026 6:59pm UTC

Request Review

A cron tick carries no message from a person, so a scheduled session's
outbound thread was rooted by the agent's first output. A run that sent a
single reply landed as a bare message in the channel with no thread under it,
and its progress status had no thread to attach to.

The bento kind now describes its trigger, so the thread opens with the
schedule's name and interval and the agent's output lands beneath it.
A tool's permission check can name a resource type defined only in rawZed.
Such a type composes and answers checks but has no standing, so the first
denied call dead-ends in the approval flow with "declares no standing" while
the class reports Valid=True.

The AgentClass controller now sets Valid=False (ToolApprovalUnroutable) when a
check names a type with no resolved standing and a denial of that check would
ask a human: every check under enforcing mode, and under permissive mode only
external tools and checks marked enforceMode always. Disabled mode is never
refused.
@josephschorr
josephschorr force-pushed the bento-opening-and-rawzed-standing branch from 2f136e9 to f030fb6 Compare December 1, 2026 22:26

@samkim samkim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR makes a bento schedule open its outbound thread with a "Scheduled run of ()" line, and makes an AgentClass go Valid=False (ToolApprovalUnroutable) when a tool check names a resource type with no resolved standing and a denial would ask a human. Both changes work for the cases their tests cover, and the targeted unit tests pass; the admission check is broader than the runner in one case (first issue below).

Verdict: changes requested. The admission check needs to respect allowSubcommands before this merges; the rest are nits.

Issues, highest first:

  • The new admission check refuses a class over toolkit subcommands that the class's toolspec allowSubcommands excludes and that can never be called, so a healthy existing class can flip invalid on upgrade for a subcommand it cannot dispatch (see inline, tool_approval_standing.go:114).
  • Becoming a TriggerDescriber is kind-wide, so bento Channels without a generate block are also offered update_opening_summary although no opening line is ever posted (see inline, trigger_description.go:34, unconfirmed impact).
  • The denialAsks comment claims it mirrors the hook "exactly"; pin-drift and runtime EnforceOverride asks are not covered (see inline, comment only).
  • Nits: the reconcile test table has two divergent cases and its permissive case asserts only a negative (tool_approval_standing_reconcile_test.go:34); the error does not say when the offending check is a permission variant; the scheduled opening line has no bronzethread bundle, which the repo guidance asks for with new user-visible behavior.

Questions for the author:

  1. When a bento Channel has no generate block, should the runner still treat the session as having an opening (pinned message and update_opening_summary), or should that depend on the Channel rather than the kind?
  2. Accepted upgrade behavior: are you comfortable that existing classes flip to Valid=False with running sessions unchanged? (Pre-existing behavior for other reasons; confirming it is intended here.)

This review was drafted by an automated pipeline and checked before submission.

The admission check walked every subcommand of every toolkit a class
binds, so a class could be refused over a subcommand its toolspec
excludes and that is never dispatched. It now walks only what each
toolspec's allowSubcommands admits, taking the union across toolspecs
that share a toolkit, and counts the toolkit-wide default only when an
allowed subcommand inherits it.

The reading of allowSubcommands is one predicate in the toolspec spec
package, used by the validator that decides dispatch, the sandbox tool's
permission surface, and both AgentClass walks. The surface and the
fact-source walk previously read an empty list as "no narrowing" while
the validator denied everything; they now agree with the validator.

Whether a denied check asks a human, and whether permissive mode lets it
through, are methods on authz.Permission shared by the tool-call hook
and the admission check, so the check is the declared part of the hook
rather than a description of it. The refusal message now says which
toolspec allows the call and when the check is a permission variant.
update_opening_summary and the pinned-message projection were gated on
the input kind being able to describe its triggers. A kind does not
describe every one of them: a bento Channel with no schedule gets no
opening line, and neither does a pull-request kind handed a key that
names no pull request. Those sessions were offered a tool whose every
call reported that there was no pinned opening message to update.

Both now ask whether the session itself was given an opening line, which
is recorded on it at creation. The kind-name lookup they used has no
remaining callers and is removed.
@josephschorr

Copy link
Copy Markdown
Member Author

Pushed c561a29 and 3e41dc8; the three inline threads have replies. The body-only items:

  • Reconcile test table: reworked in c561a29. Every row now asserts one of two outcomes positively (Valid=True, or Valid=False/ToolApprovalUnroutable naming specific things), and it gained the excluded-subcommand and allowed-subcommand rows.
  • Error does not say when the check is a variant: it now does, e.g. MCPServer/crm tool/lookup permissionVariants[0] checks ..., and a toolkit refusal names the toolspec that allows the subcommand.
  • No bronzethread bundle for the scheduled opening line: not added. A bundle starts from typed turns or a signed webhook, and a schedule tick is neither, so there is no way to drive one today. The line is covered at the kind, at the pipeline's opening derivation, and at the tool offer.

Questions:

  1. It now depends on the session, not the kind: only a session that was actually given an opening line gets the pinned message and update_opening_summary. That also covers a pull-request trigger whose key names no pull request.
  2. Yes, that is the intended behaviour and is what the upgrade note describes. It is narrower after this push: a class is only refused for a call it can actually make.

Admission stopped holding an excluded toolkit subcommand against a
class on the grounds that it is never dispatched. That is true, but the
dispatch-time validator runs after the tool-call authorization hook,
and the hook resolved the excluded subcommand's permission regardless
of the toolspec. An agent that tried one anyway could still raise an
approval for a call that cannot run, or, where the checked type has no
standing, hit the unroutable approval the admission check exists to
prevent. In permissive mode the call was let through to dispatch.

A tool can now say that a call can never be dispatched, and the hook
asks before it resolves a permission. The sandbox tool refuses a
subcommand its toolspec does not allow and an argv that names no
subcommand, reading the allow list through the predicate the validator
uses. The hook denies such a call outright in enforcing and permissive
mode alike, with no check and no approval ask, and records the refusal
with the reason. The validator is unchanged and remains the backstop.
@josephschorr
josephschorr requested a review from samkim December 2, 2026 20:33
The previous change refused a call the toolspec excludes inside the
tool-call authorization hook. The plan gate runs one position earlier,
resolves a handle for every call from the tool's per-call permission
without consulting the toolspec, and the executor publishes a hook's
approval ask before the next hook runs. So an excluded subcommand was
still recorded against the plan, and where its handle sat inside the
phase ceiling, or the agent justified it, it raised a phase or
amendment card before the refusal was reached.

The refusal is now its own hook, ahead of the plan gate, trifecta and
tool-call authorization and behind content inspection, so no gate sees
a call that can never run. It is registered in every tool-call mode,
since the plan gate activates on its own setting, and it still records
one authz decision with the reason. Tool-call authorization no longer
consults the tool itself.

@samkim samkim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 2 (commits since the last review: c561a29, 3e41dc8, 8dbde21, d4c8605). All 3 earlier issues are verified fixed, and the round 1 body items are addressed (the bronzethread bundle for the scheduled opening line is reasonably deferred).

Verdict: ready after the inline nits. The blocking item is gone. Admission now follows allowSubcommands through one shared predicate, the opening tool is offered only to a session that was given an opening line, and the admission check and the hook share their ask predicates.

New behavior in this round is the undispatchable_call hook, which refuses a call the toolspec excludes or that names no subcommand, before the plan gate and ToolCallAuthz. I found only nits:

  • Unparseable args are skipped with no log, and the comment says something untrue for toolCalls.mode: disabled (see inline, undispatchable.go:76).
  • The refusal message prints the bare command as subcommand "" (see inline, subcommand_permission.go:172).
  • Builtin-parser toolkits skip the refusal that admission relies on. No builtin parser exists today, so no live impact (see inline, subcommand_permission.go:158; related tool_approval_standing.go:194).

Questions for the author:

  1. undispatchable_call runs after tool_guard (15) and content_guard (18, order.go:44), so a call that can never run can still consume a tool-guard rate slot or, with an Approve inspector policy, raise a content_inspection card. You kept content inspection first on purpose. Do you also want tool_guard ahead of this hook, or is the rate/breaker accounting of such calls acceptable?
  2. For the builtin-parser gap, do you prefer a parser-interface method that both the sandbox tool and admission consult, or documenting that builtin parsers are out of scope until one is registered?

This review was drafted by an automated pipeline and checked before submission.

Comment thread pkg/authz/hooks/undispatchable.go Resolved
// credential.
func (s *SandboxTool) RefuseCall(args map[string]any) (string, bool) {
tk := s.opts.Toolkit
if tk == nil || s.opts.Spec == nil || tk.Parser.Kind == "builtin" {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Builtin-parser toolkits skip the undispatchable refusal, which admission relies on

Problem: RefuseCall returns false when tk.Parser.Kind == "builtin", so for such a toolkit an excluded subcommand still reaches ToolCallAuthz. permissionSources (pkg/controllers/agentclass/tool_approval_standing.go:194) skips excluded subcommands on the assumption that the call is refused first, so a class can be Valid=True while a call to an excluded subcommand with an undeclared check type is denied with a dead-end ask. Also a string branch on the parser kind in a consumer, against the "registered, not branched on" rule. No builtin parser is registered today, so there is no live impact.
Verify: confirm still no parser.kind: builtin toolkit is registered or shipped (grep -rn 'builtin' pkg/tools/toolspec/parser). If none, this can be a comment; otherwise add a method on the parser abstraction (for example whether it can identify a subcommand from an argv) and call it here instead of comparing the string, and have admission treat toolkits where it is false as not narrowed. Which of the two is a design choice for the author.
Test: a sandbox test with a builtin-kind toolkit asserting the documented behavior; go test ./pkg/agent/tool/sandbox/ -run RefuseCall.
Constraints: CLAUDE.md pluggability rule "New variants of an aspect get registered, not branched on".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took the documentation route in c916591: nothing registers a builtin parser outside a validator test, so RefuseCall and permissionSources now both say a builtin-parser toolkit is not narrowed by the refusal, and that registering one means giving parser.Parser a way to say which subcommand an argv selects, consulted by both sites in place of the kind comparison. An interface method with no implementer to shape it seemed premature; TestSandboxTool_RefuseCall_BuiltinParserToolkitIsNotNarrowed pins today's behaviour so that change has to be made on purpose.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred, acceptable. The doc comments state the builtin-parser gap and what the first builtin parser must change, and TestSandboxTool_RefuseCall_BuiltinParserToolkitIsNotNarrowed pins today's behaviour. It can wait because no builtin parser is registered, so such a toolkit fails at dispatch anyway.

…ents

The hook passed on arguments that did not decode without a word, and its
comment said tool-call authorization denies them, which is untrue under
toolCalls.mode disabled where that hook is not registered. It now logs the
tool, the mode and the decode error, and the comment says what actually stops
such a call: the tool's own decoding at dispatch, and tool-call authorization
when it is registered.
… toolkits

A refusal for the bare binary read as subcommand ""; it now says
(bare command), the wording the AgentClass controller already uses.

A toolkit with a builtin parser is not narrowed by the refusal, while the
admission walk skips excluded subcommands whatever the parser. No builtin
parser is registered, so this is documented as out of scope at both sites,
with what registering one has to change, and pinned by a test. A second test
pins that the sandbox tool refuses arguments that do not decode on both
execute paths, which the hook relies on when it stands aside for them.
@josephschorr

Copy link
Copy Markdown
Member Author

Answers to the two questions from the round 2 review:

  1. Keeping the order. A refused call is never a breaker failure (failures are recorded only at PostToolCall, which it never reaches) and a half-open probe it claimed is handed back by the per-call probe ledger, so the only accounting is one rate slot, and only where an operator authored a rate limit. I think that is the right side to err on: the budget is what bounds a model retrying a call that can never run, and moving tool_guard behind the refusal would either run content inspectors on breaker-denied calls or stop inspecting undispatchable ones. The cost is that such attempts draw from the same per-tool budget as the allowed subcommands; if that bites in practice, refunding the slot on refusal is a smaller change than reordering.
  2. Documented as out of scope for now (c916591). No builtin parser is registered, so every call to such a toolkit already fails at dispatch; the gap is only that a call to an excluded subcommand can be asked about before it fails. When the first builtin parser lands, parser.Parser gains a "which subcommand does this argv select" method that RefuseCall, PermissionForCall and the admission walk all consult in place of the kind comparison; both sites now say so, and a test pins the current behaviour.

@josephschorr
josephschorr requested a review from samkim December 4, 2026 19:43

@samkim samkim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 3. Checked commits 82548fb and c916591 (plus a clean merge of main, 07b9acb) since the last review at d4c8605. The delta only touches the undispatchable-call hook, the sandbox tool's refusal message, and comments in tool_approval_standing.go.

Verdict: ready. All 6 earlier threads are verified or acceptably deferred (5 verified, 1 deferred). The targeted tests (pkg/agent/tool/sandbox, pkg/authz/hooks, pkg/controllers/agentclass) pass at the head.

What was checked:

  • The hook now logs at INFO when it cannot read tool args, and the comment correctly says the sandbox tool's own decode refuses them (sandbox_tool.go:325).
  • The refusal message names the bare command as (bare command).
  • The builtin-parser gap is documented at both sites (subcommand_permission.go:150-182, tool_approval_standing.go) and pinned by a test. No builtin parser is registered, so no live impact. The kind-string branch at subcommand_permission.go:192 has to go when the first builtin parser lands, as the doc comment says.

No new issues. Your answers to the two round-2 questions (tool_guard order, builtin-parser scope) are accepted.

One observation outside this round's delta, not a blocker: ActiveHooks (pkg/authz/hooks/activation.go:87), the table the runner and oap agent authz share, has no row for undispatchable_call, so the CLI's pipeline view omits the hook that refuses these calls. Worth a look in a follow-up.

This review was drafted by an automated pipeline and checked before submission.

Comment thread pkg/authz/hooks/undispatchable.go Resolved
// credential.
func (s *SandboxTool) RefuseCall(args map[string]any) (string, bool) {
tk := s.opts.Toolkit
if tk == nil || s.opts.Spec == nil || tk.Parser.Kind == "builtin" {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred, acceptable. The doc comments state the builtin-parser gap and what the first builtin parser must change, and TestSandboxTool_RefuseCall_BuiltinParserToolkitIsNotNarrowed pins today's behaviour. It can wait because no builtin parser is registered, so such a toolkit fails at dispatch anyway.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants