Repository navigation
task-recreate-worker launches through lib/agents (#239, step 1 of 2) - #252
Conversation
… switches onto the Phase-2 modules (fixes the GH_URL-only sidecar read): task-recreate-worker launches through lib/agents Part of #239, the task-recreate-worker step. The sidecar read was already fixed by #240; this replaces the remaining inline agent switch. - Source `lib/agents/<agent>.sh` beside the tracker module, and replace `build_agent_cmd`, the kiro `--resume` gate and the direct `aw_require_kiro_agent` call with `aw_agent_launch_cmd`, `aw_agent_preflight` and a new hook, `aw_agent_resume_cmd <session-id>`. The hook is claude's `--resume [<id>]` line and kiro's refusal. task-work never resumes, so it is the one hook #236/#237 had no reason to define. - Resolve the launch line before the report and the sidecar rewrite, so a refusal no longer strips `TAB_ID` first. - Scrub `TASK_WORK_MODEL` / `TASK_WORK_TRUST_ALL` for kiro's flag init, so a recovered worker never gets `--trust-all-tools` that task-work did not give it. Tests: bats --count 1306 at 735138f -> 1311. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spec compliancePR #252 is step 1 of 2 per the #239 plan ("one PR per script"). It delivers everything the spec required for the
No spec deliverables are missing or off-spec for the declared step. Code-review findingsThe "refusal before state change" fix is correct and well-placed. Tracing execution order confirms the behavioral improvement: the launch line block now sits at line 338 (after arg parsing at 136, before report at 412 and sidecar rewrite at 456). For The In bash, prefix assignments on a shell function call are permanent in the current shell (unlike external commands). After the call, both vars are The kiro session-ID lookup runs before the refusal.
Module-loading order is correct.
For claude,
No issues with the It's inside Verdict: cleanThe implementation is correct across all loadouts. The behavioral improvement (kiro refusal before report and sidecar) is verified by test. Tests are well-targeted and were all mutation-checked. CI passed on the head commit. No blocking findings; the one wasteful kiro lookup is documented and harmless. Ready to merge once |
Part of #239 — the task-recreate-worker step. Per the spec this is one PR per script;
task-reviewerfollows in its own PR, so this one deliberately does not close the issue.Reviewer: the spec issue is #239. There is no
Closesline, so pass it explicitly:task-reviewer <this PR> 239.What changed
The sidecar half is already done: #240 (PR #251) reads the ref with
aw_tracker_info_keyand builds the payload withaw_tracker_worker_prompt. This PR moves the rest of the command's agent handling onto the agent module:bin/task-recreate-workernow sourceslib/agents/<agent>.sh, resolving both modules before sourcing them, the waytask-workdoes.build_agent_cmdis gone. A fresh launch now usesaw_agent_launch_cmd.aw_require_kiro_agentcall is gone. The preflight now goes throughaw_agent_preflight.case "$AGENT"--resumegate is gone. A resume now goes through a new hook,aw_agent_resume_cmd <session-id>:claude [--permission-mode auto ]--resume [<id>];About the new hook: this is the one hook #236/#237 did not define.
task-worknever resumes anything, so the module API is not missing something it should have had. A resume hook simply has no place intask-work.What stays in the script: it still mines the session id from radio's log, because that is radio-log knowledge rather than agent knowledge.
Declared behaviour changes
--resumerefusal and the kiro preflight are now resolved before the report and the sidecar rewrite. Before, a kiro--resumeprinted the recovery report and strippedTAB_IDfrom the sidecar, and only then refused.aw_agent_init_flagswould readtask-work'sTASK_WORK_MODEL/TASK_WORK_TRUST_ALLfrom the environment. A recovery could then relaunch a worker with--trust-all-toolsthat the originaltask-workrun never gave it. Both variables are scrubbed for that one call.Launch lines are otherwise byte-identical on every loadout. The existing per-tracker sidecar-ref rows from #240 pass unchanged. The unquoted
MODELin kiro'saw_agent_launch_cmdis #157's and is not touched here.Tests
bats --count: 1306 at735138f(main) → 1311. All 1311 pass under./run_tests.sh.New tests:
task_recreate_worker.bats:--resumerefusal leaves the sidecar byte-identical;TASK_WORK_MODEL=… TASK_WORK_TRUST_ALL=1does not reach the kiro launch line;--auto --resumekeeps--permission-mode auto.loadout_modules.bats:aw_agent_resume_cmd;task-recreate-workerwith a named error, not shell noise and not "no worktree".Each new test was checked against a broken tree and went red:
the old
bin/task-recreate-workerfails the sidecar test and the missing-module test;removing the env scrub fails the trust-all test;
renaming kiro's
aw_agent_resume_cmdfails the hook-presence test.dropping
mode_prefixfrom claude'saw_agent_resume_cmdfails the--auto --resumetest. The old code produced the same line, so that test pins existing behaviour rather than a change.Also green:
tools/check-drift.sh(15 groups) andshellcheck -xon the three changed shell files.No
task-initre-run needed. The CHANGELOG entry is under[Unreleased]→ Changed.🤖 Generated with Claude Code