Repository navigation
fix(agents): keep a default its workspace checkout still declares - #16562
Conversation
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The description describes a different implementation than the one in the diff, so reviewers are checking claims the code doesn't make. Watch
[DESIGN-REVIEWED] b0c503b Description read[DESCRIPTION-READ] b1b7b79f231415c94d68c55847cf072b8102b9094866914cfbe6722046f6c101 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The Not justified as shipped
What this change shipsInventory (5 items) — 3 justifiedIntent: the owner's default agent stays put while the alias's own workspace still declares its template. This is a FIX (#16555, with a test that fails on base).
[FIRST-PRINCIPLES-REVIEWED] b0c503b Description read[DESCRIPTION-READ] f7da9ba689f867a187453913dcd06d147e46634b82662877f8dafc81902296cd That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
The default-agent healer takes its removal evidence from the user-level agents directory only. kiro-cli resolves --agent against the session's project directory first, so a global spec uninstalled while the alias's workspace checkout still declared a same-named spec left the default dispatching there, yet the healer read it as removed and durably reset default_agent to "default". Before resetting, the healer now scans the alias's workspace, placed by workspace_dir_from_entry (the named entry, else default_workspace, as dispatch does). The scan covers <workspace>/.kiro/agents, the only project location the backend activates, and uses the same scan as the snapshot, so it knows whether it was complete. The healer declines when that checkout still declares the template, when the scan was partial, when the listing fails, and when the workspace path is sensitive (never read). The locked config write re-derives the row's workspace from the document it holds and declines if it changed. Fixes #16555
0e37389 to
b0c503b
Compare
Problem / Motivation
Goal: the default-agent healer never resets a default that the alias's workspace checkout still declares.
Repro (#16555), now
test_a_default_its_workspace_still_declares_is_not_reset:pkgrunsreviewerin workspaceprojand is the default. Both~/.kiro/agents/reviewer.jsonandproj/.kiro/agents/reviewer.jsondeclarereviewer.default_agenttodefaultinconfig.json. On origin/main the test fails with'default' == 'pkg'.Cause:
reset_dangling_default_agent(config/loader.py) takes its removal evidence (_MATERIALIZED_SEENminus the current snapshot) from the user-level agents directory only. kiro-cli resolves--agentagainst the session's project directory first (config.paths.project_agents_dir), so the default still dispatches in that workspace. The healer cannot see that.Why it matters
A durable, silent change to the owner's setting, for a default that still works. Nothing puts it back.
Not a goal
What changed (motivation → approach → change)
_alias_workspace_dirplaces the alias's workspace the way dispatch does: the named entry, elsedefault_workspace, throughworkspace_dir_from_entry. That is the one placement rule, so a relativedirlands under the data home and not the gateway's cwd._workspace_declares(template, workspace_dir)scans<workspace>/.kiro/agentswith the same scan as the snapshot (_scan_materialized_index). That directory, in both spec forms, is the only project location the backend activates; the legacy.agent-spec.jsonfiles are not counted. Using the same scan also tells it whether the scan was complete..kiro/agentsdeclares nothing._locked_workspace_dirre-derives the row's workspace from the document it holds. The write is declined if that differs from the workspace that was checked.Backwards compatibility
Compatible. A default whose template is gone from both the user-level directory and its workspace is still reset; the test also covers that step.
Tests
New in
test/test_config_loader.py::TestDanglingDefaultAgentReset, each paired with the targeted mutation that fails it:test_a_default_its_workspace_still_declares_is_not_reset(also resets once the checkout drops it)test_a_relative_workspace_is_placed_under_the_data_homePath(dir).expanduser()test_a_workspace_spec_that_cannot_be_read_is_not_evidence_eithertest_a_row_repointed_at_another_workspace_inside_the_locked_write_is_keptRegression proof on this branch: with
loader.pyreverted to the release/0.8.0 tip, the 4 new tests fail.Gates:
test_config_loader.py,test_agent_execution_catalog.pyandtest_config_api.py: 723 passed.test/integration: 20786 passed. The 2 failures are thetest_chat_runner_composition_contract.pyones that fail identically on origin/main.Manual verification
N/A. The tests drive real refreshes over a real agents directory, a real project checkout and a real
config.json.Related Issues
Fixes #16555. Follow-up to #16410, #16455 and #16512. A release/0.8.0 backport follows, on top of #16385.
Pattern harvest
Rule candidate: review-prompt
Pattern: "X is gone" evidence must come from every place the consumer resolves X. A self-healing write keyed on one directory is wrong when the resolver also searches another.
Checklist