Repository navigation
fix(channel): wait the configured approval window on channel cards - #18953
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Keeping the 3600 s default costs a second config reader in Not justified as shipped
What this change shipsInventory (6 items) — 5 justifiedIntent: let an operator's approval-timeout setting decide how long an unanswered channel approval card blocks the agent. FIX.
[FIRST-PRINCIPLES-REVIEWED] 1724cff Description read[DESCRIPTION-READ] 159ed8413a125a4215cdc07a3c299a68cb91b758a77e972123b639f73a0f51c5 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS
Watch
Suggestions
[DESIGN-REVIEWED] 1724cff Description read[DESCRIPTION-READ] 32cb05b7d705fad5147161ada57eef82209e20af7975fa0e01a811905811f039 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
43470ae to
2bd19b3
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
This PR makes a channel approval card wait agent.tool_approval_timeout_secs (capped at 3600 s) instead of a fixed 3600 s, and makes the expired notice quote the window it used. The goal is right, but the way it tells "unset" from "set" does not work. _channel_approval_window_secs (channel.py:1272) treats the key's presence in raw config.json as an operator choice. I confirmed that the gateway's first boot writes a default config with cfg.save (cli_server.py:2941), and save() publishes asdict(self.agent), so every install carries tool_approval_timeout_secs: 600 that nobody chose. loader.py:1470 already warns that "Presence cannot carry the meaning safely" for this reason. On an ordinary install, every channel card therefore drops from 3600 s to 600 s. That breaks the body's "Compatible: exactly as before" and its Not-a-goal of keeping the default. The tests miss it because they patch _raw_config with a hand-built dict instead of a save()-written file. The configured <= 0 branch is also dead, since the loader clamps to at least 30 s. Fix: decide from the value, not the key. Either resolve a channel default in the loader, or take the loaded value and list the default change as Breaking. Then add a test that a config written by KiroCrewConfig().save() still waits the intended default. — crew-pr-reviewer (deep re-check)
2bd19b3 to
3b158d9
Compare
|
Rebased onto main (0a47021, no conflict) and fixed in a new commit on top of the PR's. Presence is not a choice. Tests. They now write Dead branch. Confirmed with a run: a configured 0, -5 or 10 loads as 30 ( A second miss in the same check. The old test read An operator's window now reaching channel cards with no warning. No code change: that is the PR's intended effect for an operator who set a value, and the dashboard turn already waits that value. The body's Backwards compatibility section now says so. A config that was never edited, or holds only the saved default, keeps 3600 s. The review's own example, an operator who set 600 s, also keeps 3600 s, because 600 reads as the default. The turn-ceiling clamp. Kept, and stated in the docstring ( |
|
The new commit replaces the short fixed wait that the repo's wait-discipline ratchet (test/test_wait_discipline_ratchet.py) rejects in test/test_channel_approval_meta.py; it changes that file only. |
11e9d72 to
e0252f1
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
This PR makes an unanswered channel approval card wait agent.tool_approval_timeout_secs (capped at 3600 s) instead of a fixed 3600 s, and makes the expiry notice quote the window it used. The new head e0252f1 fixes our earlier request: it decides from the loaded value instead of key presence, so a config written by save() keeps the 3600 s wait, the dead <=0 branch is gone, config.local.json is honoured, and the tests now go through a real save() and the real loader. But comparing the post-clamp loaded value with a recomputed default (channel.py:1285-1296) still mixes up the operator's choice with the loader's clamp, in both directions. I traced the two cases the Opus and GPT lanes raised on this head through loader.py:3179-3186 and both are real. (1) With chat_turn_timeout_secs=300 and tool_approval_timeout_secs=500, the loader clamps 500 to 240, which equals unset, so the card waits 3600 s; an operator who asked for a shorter window gets a 15x longer one, while 200 would be honoured. (2) With chat_turn_timeout_secs=300 and the key omitted, the clamp never runs (it only fires when the key is present), the loaded 600 does not equal unset (240), and the card expires at 600 s instead of keeping the 3600 s default. Neither has a posted disposition. Fix: decide "unset" from the merged raw value before the turn-ceiling clamp (key absent, or equal to the field default 600, means the 3600 s cap; otherwise use the loaded, clamped value, capped at 3600), drop the duplicated clamp formula, and add tests for the 300/500 and 300/absent cases. — crew-pr-reviewer (deep re-check)
A channel approval card waited a fixed _APPROVAL_TIMEOUT_SECS (3600 s) before the host declined it, and never read agent.tool_approval_timeout_secs, the documented window for how long a turn waits for a human to answer a tool-approval prompt. The dashboard turn honours that setting; on channels an operator who set 30 s still had the agent parked for an hour, and the expired-card notice always said "unanswered for 3600s". _stream_task now reads the window once per card, off the loop and inside the card's ownership scope, through the new _channel_approval_window_secs: the configured value when the operator set it, capped at 3600 s; 3600 s when the setting is absent, not positive, or config cannot be read. The wait and the notice both use that value. An expired card is still declined.
KiroCrewConfig.save writes every agent field, so a config.json nobody edited already holds tool_approval_timeout_secs at its default, and the key's presence says nothing about a choice. The loaded number says no more. The loader pulls the window under the turn ceiling, so with chat_turn_timeout_secs at 300 a saved 600 and a written 500 both load as 240, and an omitted key loads as 600 because the pull only runs on a present key. The channel card now reads whether a number was chosen from config.json and config.local.json merged the way the load merges them, with the number read the way the load reads an integer, before any clamp. Absent, or equal to the default of 600, is unset and the card waits the 3600 s cap as before. Any other number is the operator's, and the card waits the loaded value, capped at 3600 s. The recomputed default and its margin arithmetic leave channel.py. Exactly the default cannot be pinned on a channel; any other number can. The config.json read through _raw_config is gone, along with the "not positive" branch: the loader raises a window under 30 s to 30 s, so that branch never ran. The tests write config.json with KiroCrewConfig().save() or by hand and read it through the real loader. They cover the saved default, a window the loader pulls under a short turn ceiling, an omitted key under one, numeric spellings, a malformed value, windows split across config.json and config.local.json, an overlay the loader cannot use and a zero.
e0252f1 to
1724cff
Compare
|
Both cases are real, and the cause is wider than the two examples: comparing the loaded number with a recomputed default mixes the operator's choice with the loader's pull under the turn ceiling ( The amended second commit decides "unset" from the merged documents before the clamp, as the review asks:
(1) A written 500 under a 300 s ceiling now waits the loaded 240 s: Both go through |
iamwhatever
left a comment
There was a problem hiding this comment.
This PR makes an unanswered channel approval card wait the operator's agent.tool_approval_timeout_secs (capped at 3600 s) instead of a fixed 3600 s, and the expiry notice now quotes the window it actually used. The new head 1724cff does what our last change request asked: _written_approval_window (channel.py:1268) decides "unset" from the merged config.json + config.local.json value BEFORE the loader's turn-ceiling clamp, and _channel_approval_window_secs then waits the loaded, clamped value capped at 3600 s. I traced both cases from our review through loader.py:3179-3186: a written 500 under a 300 s turn ceiling now waits the loaded 240 s, and an omitted key under that ceiling keeps the 3600 s cap. The read runs off the loop inside the post/wait ownership scope, and any config error falls back to the cap. I ran test/test_channel_approval_meta.py: 51 pass on the head, and 18 fail with main's channel.py swapped back in, so the tests prove the fix. The Design and First Principles CONCERNS (a second config reader built from loader helpers, and a typed 600 reading as unset) are real but advisory. The 600 trade-off is the one our review proposed and the docstring states it, so I accept it. The author should still post a disposition for each lane, and a loader-owned "was this written" flag would be a good follow-up. Checks are green and our earlier change request is fully met. — crew-pr-reviewer (deep re-check)
Problem / Motivation
Goal: a channel approval card waits the operator's configured approval window (
agent.tool_approval_timeout_secs), capped at 3600 s, and the expired-card notice quotes the window it actually used._APPROVAL_TIMEOUT_SECS = 3600before the host declined it (asyncio.wait_for(approval_future, timeout=_APPROVAL_TIMEOUT_SECS)in_stream_task,src/kiro_crew/channel.py).agent.tool_approval_timeout_secs, whose documented meaning is "How long a chat turn waits for a human to answer a tool-approval prompt before declining it" (src/kiro_crew/config/sections.py). The dashboard turn honours that setting (chat_runner.pywaitsmin(state.approval_timeout_for(slot), tool_approval_timeout_secs())).Why it matters
The setting is the operator's one control for how long an unanswered approval blocks work, and the channel surface ignored it. A channel agent waiting on nobody stays blocked for up to an hour, and the notice the model reads names a window the operator never chose.
Not a goal
_stream_taskis awaited without one, so a channel approval cannot outlive a turn ceiling; that is unchanged.turn_dispatch.tool_approval_timeout_secs. The channel module reads the config directly rather than importing that dashboard helper, which would reverse a layer.docs/system-specs/modules/persistent-agent-channels.mdsays "asyncio.wait_forsupplies the timeout" and does not state its length, so no spec text changes.What changed (motivation → approach → change)
agent.tool_approval_timeout_secsand always waits 3600 s._stream_taskwaited on the constant_APPROVAL_TIMEOUT_SECS, and the expired-card notice quoted the same constant.src/kiro_crew/channel.py:_channel_approval_window_secs()(src/kiro_crew/channel.py:1291). It returns the loadedagent.tool_approval_timeout_secs, capped at_APPROVAL_TIMEOUT_SECS, once the operator has written a number other than the default. While the setting is absent or holds the default it returns the cap, and it returns the cap when config cannot be read. The decision issrc/kiro_crew/channel.py:1311-1317.KiroCrewConfig.save()writes every agent field throughto_dict()(src/kiro_crew/config/loader.py:4306), and the gateway's first boot callssave(src/kiro_crew/cli_server.py:2999), so a config nobody edited already holds the default. The loader rules presence out as evidence (src/kiro_crew/config/loader.py:1616). A number equal to the default reads as unset, asembedding_threadsdoes (src/kiro_crew/embeddings.py:1081).src/kiro_crew/config/loader.py:3184-3186) and never touches an omitted one. Withagent.chat_turn_timeout_secsat 300, a saved 600 and a written 500 both load as 240, and an omitted key loads as 600. So the choice is read before that pull._written_approval_window()(src/kiro_crew/channel.py:1268) mergesconfig.jsonandconfig.local.jsonwith the loader's own_deep_merge, the overlay winning key by key (src/kiro_crew/channel.py:1279-1285), and reads the number with the loader's own_safe_int(src/kiro_crew/channel.py:1288): a numeric string or an integral float counts as the loader counts it, and anything else reads as the default. A document that cannot be read, or is not a JSON object, adds nothing, as in the load.config.local.jsonoverconfig.jsonand its clamps: into 30..7200 s, then to at most 60 s belowagent.chat_turn_timeout_secs. A configured zero arrives as 30 s, so no "not positive" branch is left, and the turn-ceiling arithmetic stays in the loader. Channels and the dashboard read the same validated number, and the loader logs a clamp when it applies._stream_taskreads the window once per card withawait asyncio.to_thread(_channel_approval_window_secs)(src/kiro_crew/channel.py:1692), off the event loop because it reads the config files. The read sits inside the card's existing ownership scope, so a cancel during it still clears the pending future.src/kiro_crew/channel.py:1701), and the "went unanswered" notice quotes it (src/kiro_crew/channel.py:1762). An expired card is still declined._APPROVAL_TIMEOUT_SECSstays 3600 (src/kiro_crew/channel.py:69); its comment names it the cap and the default.dashboard.turn_dispatch.tool_approval_timeout_secs. It is a dashboard module, and its turn-budget bound is about the dashboard turn's ceiling, which a channel turn does not have.Backwards compatibility
Compatible for an install that never chose a window. With
agent.tool_approval_timeout_secsabsent fromconfig.json, or at its default asKiroCrewConfig.save()writes it, a channel card waits 3600 s and the notice reads "3600s", exactly as before. That holds under a shortagent.chat_turn_timeout_secs, where the loader loads a saved default lower (240 s under a 300 s ceiling) and an omitted key at 600 s.Only an operator who set another value sees a different wait: their value as the loader leaves it, capped at 3600 s. The dashboard turn already waits that value. A window typed as exactly the default cannot be told from the saved one, so it keeps the 3600 s wait; 599 s and 601 s are honoured.
Removes nothing: the change adds two helpers and replaces the constant in one wait and one notice.
Tests
Red on this PR's previous head (rebased onto origin/main 315affc,
pytest test/test_channel_approval_meta.py -n 0, 3 of 3 serial runs): 19 failed, 32 passed each. The review's two cases are among them: a written 500 under a 300 s turn ceiling waited 3600 s instead of 240 s, and an omitted key under it waited 600 s instead of 3600 s.Red on origin/main 315affc (the test file copied onto it, same command, 3 of 3 serial runs): 18 failed, 33 passed each. The failures are the eighteen tests that expect a written window to be waited; the controls pass on main by design, they pin today's 3600 s.
After the fix: same command, 3 of 3 serial runs, 51 passed each. With the 27 neighbour files below, 28 files run serially: 859 passed.
Changed in
test/test_channel_approval_meta.py. The tests writeconfig.jsonwithKiroCrewConfig().save(), or by hand for a typed value, and read it through the real loader. Only the unreadable-config case stubs the loader._expire_one_cardreplaces the module's ownasynciobinding with a namespace that delegates every other name to the real module, sowait_forreports the window it was given and expires at once, with no wall clock.The eighteen failures on main are the tests that expect 30, 60, 90 set in
config.local.json, 1000, 599, 601, a zero raised to 30, a window pulled under a short turn ceiling, the numeric spellings of 500 and the overlay splits.Neighbours: the other 21 test files that import
kiro_crew.channeland six that pin the config loader's bounds and the import boundaries (test/test_transport_permission_floor.pyleft out: it builds paths under the real home directory). mypy, flake8, isort and black are clean on the changed files.scripts/check_black_formatting.py,scripts/check_subprocess_encoding.py,scripts/docs-lint.shandscripts/check_comment_history.pywithCOMMENT_HISTORY_BASE_REF=origin/mainpass. Eight one-line mutations ofsrc/kiro_crew/channel.pyare each caught: deciding from the loaded number (7 tests fail), readingconfig.jsononly (4), skipping the loader's integer reading (2), dropping the 3600 s cap (1), replacing the merge with the last document (1), deciding from the key's presence (16), and letting an unreadable (2) or non-object (1) overlay abort the read.What each test pins:
test_an_unanswered_card_waits_the_configured_approval_window: a saved window of 30 s is waited, the card is declined, and the notice reads "went unanswered for 30s".test_an_unanswered_card_waits_the_full_cap_when_no_window_is_set: control, an emptyconfig.jsonwaits 3600 s and the notice reads "3600s".test_a_config_saved_with_defaults_keeps_the_full_cap:KiroCrewConfig().save()puts the default window in the file (asserted), and the card waits 3600 s.test_the_default_window_under_a_short_turn_ceiling_keeps_the_full_cap: at ceilings of 300, 659, 660 and 14400 s the loader leaves 240, 599, 600 and 600 s of the saved default (asserted), and the card waits 3600 s each time.test_a_window_set_under_a_short_turn_ceiling_is_waited: a set 60 s under a 300 s ceiling is waited.test_a_window_the_loader_pulls_under_the_turn_ceiling_is_waited_as_pulled: a written 500, 240 or 7200 under a 300 s ceiling and a written 700 under 660 s load as 240, 240, 240 and 600 (asserted), the figures a saved default can load as, and the card waits that figure.test_an_omitted_window_under_a_short_turn_ceiling_keeps_the_full_cap: with the key omitted, at ceilings of 300, 659, 660 and 14400 s the loader leaves the field default (asserted), and the card waits 3600 s.test_a_numeric_string_or_integral_float_window_is_read_as_the_loader_reads_it: under a 300 s ceiling"500"and500.0are a choice (240 s) and"600"and600.0are the default (3600 s).test_a_malformed_window_under_a_short_turn_ceiling_keeps_the_full_cap:"soon",true,nulland5.5load as the field default (asserted) and wait 3600 s under a 300 s ceiling.test_the_window_is_read_from_the_two_documents_as_the_loader_merges_them: five splits of the ceiling and the window acrossconfig.jsonandconfig.local.json; the overlay wins key by key, for whether a window was written as well as for its number.test_an_overlay_the_loader_cannot_use_leaves_the_window_in_the_base: invalid JSON, a JSON array and an empty file asconfig.local.jsonare ignored by the loader, and the window inconfig.jsonis waited (240 s under a 300 s ceiling, asserted).test_a_window_between_the_default_and_the_cap_is_waited: a set 1000 s is waited.test_a_window_set_in_the_local_overlay_is_waited: a 90 s window set only inconfig.local.json, which the loader merges overconfig.json, is waited.test_a_configured_window_above_the_cap_is_capped: a set 7200 s is capped at 3600 s.test_a_zero_window_is_raised_by_the_loader_not_replaced_by_the_cap: a hand-written 0 loads as 30 and waits 30 s.test_a_window_written_as_the_default_is_read_as_unset: 599 and 601 are waited; a hand-written 600 waits 3600 s.test_a_malformed_window_keeps_the_full_cap: a window of the wrong type falls back to the default in the loader and waits 3600 s.test_an_unreadable_config_keeps_the_full_cap: a config read that raises waits 3600 s.Manual verification
N/A: the change is the wait's window and the notice's text. The tests drive the real
_stream_taskapproval path with a fake provider and an unanswered card.Related Issues
None found for the ignored window. Searched PRs and issues, open and merged, for
_APPROVAL_TIMEOUT_SECS,channel approval timeout,tool_approval_timeout_secs channel,channel approval card unansweredandapproval window channel. Related, about the notice rather than the window: PR #15083, PR #13574, issue #10555. Of the 20 open PRs that touchsrc/kiro_crew/channel.pyor the test file,git merge-treegives the same conflicted files on origin/main with and without this branch for every one (four of them already conflict insrc/kiro_crew/channel.pywith origin/main alone), so this branch adds no conflict to any of them.Pattern harvest
Rule candidate: review-prompt
Pattern: one surface honours a configured window through a shared helper while a sibling surface waits on its own constant for the same concept.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)