Skip to content

feat(conductor): drop the chat context at a round close - #18113

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/conductor-reset-between-rounds
Oct 9, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/conductor-reset-between-rounds

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A goal conductor drops its own chat at each round close, so a patrol that runs for days stops paying for an ever-growing context on every quiet wake.

Every patrol wake re-sends the conductor's whole conversation. The state it needs already lives in the work ledger and its session ledger, and each wake already carries their snapshot. But the conductor could not reset: the tool was not in its grants, and the directive consumer refused reset_conversation from any turn a person did not start, so a patrol wake was always refused.

Why it matters

A conductor that runs for days pays the cost of its whole chat on every wake, even when nothing changed. That cost grows each round and buys nothing the ledgers do not already hold.

Not a goal

  • Any agent other than kirocrew-conductor gaining reset_conversation.
  • Letting a wake run set_project or chat_tag. They stay human-only.
  • Resetting mid-round, or on a timer.
  • Changing what a reset drops: still only the model's memory; the slot, its loop and the transcript stay.

What changed (motivation → approach → change)

Decision recorded in rfc-conductor-round-reset.md (#18097).

Part Change
Conductor grants (src/kiro_crew/agent.py, src/kiro_crew/agent_materialization/conductor_agents.py) reset_conversation added for kirocrew-conductor only, and to its shipped-grant history so a regenerated spec keeps it as Crew's
Directive consumer (src/kiro_crew/dashboard/session_directive_apply.py) a patrol wake may reset only if the slot runs kirocrew-conductor (or its deprecated alias), its loop is the slot's current, active loop, the self-arm trust record says the slot armed it itself, and no question card or tool approval is pending; otherwise refused and audited. The loop is re-read after the off-loop trust read. Each admitted wake reset logs a WARNING with the loop id
Where the reset lands (src/kiro_crew/dashboard/chat_runner.py, src/kiro_crew/dashboard/state.py) a reset a wake queued also waits at the turn boundary while a question or approval is pending; a person's own reset does not
Self-arm record (src/kiro_crew/autonudge_authz.py, src/kiro_crew/autonudge_selfarm.py) also written when a conductor slot arms itself; an outside arm, or any other agent's self-arm, never writes it. Losing the record never blocks a conductor's arm
Skill + prompt (src/kiro_crew/builtin_skills/goal-conductor/SKILL.md, src/kiro_crew/agent.py) at a round close, write goal, next (open item ids, worker keys, PRs) and patrol_base, then reset as the last call. Never mid-round or with a question open

The tool description in src/kiro_crew/mcp_tools/control.py and the specs in docs/system-specs/modules/session.md and docs/system-specs/modules/learn-cron-dashboard.md name the wake case. Two pinned tests change on purpose, each with a comment saying why.

Why the ledger write before a reset is prompt-enforced

The gateway checks who may reset and that nobody is waiting on an answer. That the ledger was written first is left to the skill and prompt: the work ledger already holds every item, worker binding and PR, so a reset after a failed session_ledger_record costs one wake that rebuilds next from it. A gateway check would need turn-scoped ledger provenance, a new mechanism for a cost that small.

Backwards compatibility

Compatible: a person's turn resets exactly as before; cron, sub-agent and unvouched wake turns are refused as before; crew/member self-arm rules are unchanged.

Removes nothing: the change only admits one new caller and writes one more trust entry.

Tests

  • test/test_conductor_wake_reset.py (new): a vouched wake queues the reset and logs the loop id; refused for no loop id, no loop, a different current loop, a stopped loop, an unrecorded loop, a down store, a pending question card, a pending slot approval, a pending coordinator approval; a settled approval does not refuse; a turn with neither mark is still refused; a wake still cannot set_project; a person's turn keeps its old path; a Pause landing inside the trust read refuses; only a wake reset is marked to wait at the boundary; a non-conductor agent's wake is refused and the deprecated conductor alias is admitted. Authorizer: a conductor's self-arm is recorded, an outside arm and other agents' self-arms are not, a down record still arms, and a record for an arm that failed is forgotten.
  • test/test_chat_runner_coverage.py: a wake's queued discard waits while a question is pending and lands once it clears; a person's discard does not wait.
  • test/test_conductor_agent.py, test/test_autonudge_member_self_arm.py, test/test_agent_refactor_contracts.py, test/test_agent_refactor_spec_bytes.py: updated on purpose for the new grant and prompt (the conductor and alias spec golden digests change because their allowedTools gain one entry).
  • Determinism: the new file passed 10 repeat runs and one run in reversed order.
  • Related backend set (118 files touching the changed modules): 7645 passed, 12 skipped; re-run after the agent checks: 4918 passed.

Manual verification

N/A — the effect is a gateway decision on a directive; the tests drive apply_session_directive and authorize_and_add_nudge directly.

Related Issues

Closes #18093

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 8, 2026 09:46
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision fe92431ee1b46f650ec6d026be1cb7f5bb14d17b touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of fe92431ee1b46f650ec6d026be1cb7f5bb14d17b — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

WAKE_RESET_AGENTS hardcodes the deprecated alias name, which DEPRECATED_AGENT_SPECS already records. That makes two lists that will drift when the alias is retired.

Not justified as shipped

  • Item 9 — duplicate of src/kiro_crew/agent_materialization/conductor_agents.py:797 (DEPRECATED_AGENT_SPECS): the diff adds frozenset({"kirocrew-conductor", "kirocrew-ledger-conductor"}), and its own comment points at conductor_agents.DEPRECATED_AGENT_SPECS. That table's comment says "A row is deleted together with its alias installer". This literal has no such tie, so when the alias is retired it is left behind and keeps admitting a removed name. Of 3 hits for "kirocrew-ledger-conductor", the frozenset is the only one outside the alias's own module.
    Subtraction: delete the alias literal and derive the set as {"kirocrew-conductor"} plus the keys of DEPRECATED_AGENT_SPECS that map to it.
    Clears when: WAKE_RESET_AGENTS names no alias literal of its own.

What this change ships

Inventory (9 items) — 8 justified

Intent: let a long-running goal conductor drop its own chat at each round close, so quiet patrol wakes stop paying for an ever-growing context. ADDITION, covered by rfc-conductor-round-reset.md (base status in-progress).

  1. A conductor's patrol wake can now reset its own conversation — justified
  2. The conductor's reset_conversation call is auto-approved, and regenerated specs keep the grant — justified
  3. A wake reset is refused, with an audited reason, unless the slot is a conductor on its own live, self-armed loop with nothing pending — justified
  4. A reset queued by a wake waits at the turn boundary while a question or approval is pending — justified
  5. A conductor's self-arm now writes the trust record, and a failed record write no longer blocks the arm — justified
  6. Each admitted wake reset logs a WARNING with the loop id — justified
  7. The conductor skill and prompt now default to writing the ledger and then resetting at round close — justified
  8. The tool description names the wake exception — justified
  9. The deprecated kirocrew-ledger-conductor alias is also admitted — duplicate of DEPRECATED_AGENT_SPECS

[FIRST-PRINCIPLES-REVIEWED] fe92431

Description read

[DESCRIPTION-READ] 25e9b7a4ea0a85c9ec2df91a2e9f9032d864ff83c305ca00a088db8da49a792c

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

Design-level review of fe92431ee1b46f650ec6d026be1cb7f5bb14d17b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

A wake's queued reset can land several turns after the round close that justified it, so it may wipe context the ledger never captured.

Watch

  • A late reset breaks the "ledger first, never mid-round" rule. _reset_conversation only sets slot._pending_discard_conversation_key, and the reply says it lands "later if a turn is still in flight on the session". The new boundary check also defers it while a question is pending (return torn_down). All the gate checks run when the reset is queued; nothing checks again when it lands, except that no question is pending. So a person's turn, or a mid-round dispatch, can run between the round close and the discard. That turn's decisions are then wiped, even though the ledger was written before them. The work ledger limits the damage, but this is exactly the case the description says the gateway prevents.
    Clears when: a wake-queued discard is dropped (not just deferred) if any turn starts after the one that queued it, or the loop is no longer the slot's current active loop, and a test pins this.
  • A conductor on the default patrol never gets its reset. The record is written only when is_self_arm(slot_key, initiator_slot_key) is true, so a conductor on the bind-time default patrol has every reset refused. Its context keeps growing on that path, which is the cost the Goal says this PR removes. The refusal is quiet: it is audited and the conductor just carries on.
    Clears when: the skill/prompt tells a conductor whose reset was refused because its loop wasn't self-armed to call monitor_start itself, or the description states that default-patrol slots are deliberately left out of the Goal.

[DESIGN-REVIEWED] fe92431

Description read

[DESCRIPTION-READ] 26e710dc6f28b7219230a53ce995e287d8741bdd1210b29d5432b3b497ef093d

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of fe92431ee1b46f650ec6d026be1cb7f5bb14d17b and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] fe92431

False positive or not applicable? A repository writer can comment:
/ai-review override gpt fe92431ee1b46f650ec6d026be1cb7f5bb14d17b: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed fe92431ee1b46f650ec6d026be1cb7f5bb14d17b — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] fe92431

Verdict parsed from the review's SHA-scoped output markers for commit fe92431ee1b46f650ec6d026be1cb7f5bb14d17b.

False positive or not applicable? A repository writer can comment:
/ai-review override fable fe92431ee1b46f650ec6d026be1cb7f5bb14d17b: <one-sentence reason>

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • No recorded decision on base span=a1e503e41f6d — needs-a-decision

The decision is recorded in RFC #18097 (docs-only, its own PR, same pattern as #17079), taken by the operator who owns the conductor patrol.
This lane reads RFC status from base. Clears when #18097 merges and this PR is rebased onto it; a maintainer may instead post the first-principles override.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • No recorded decision on base span=a98c59ef7182 — needs-a-decision

The decision is recorded in RFC #18097 (docs-only, its own PR, same pattern as #17079), taken by the operator who owns the conductor patrol.
This lane reads RFC status from base. Clears when #18097 merges and this PR is rebased onto it; a maintainer may instead post the first-principles override.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • No recorded decision on base span=2b41c90f3d75 — needs-a-decision

The decision is recorded in RFC #18097 (docs-only, its own PR, same pattern as #17079), taken by the operator who owns the conductor patrol.
This lane reads RFC status from base. Clears when #18097 merges and this PR is rebased onto it; a maintainer may instead post the first-principles override.

@iamwhatever
iamwhatever force-pushed the fix/conductor-reset-between-rounds branch from 8199d48 to 9c95512 Compare October 8, 2026 10:13
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • The gate does not check the agent span=865af5bf25df — fixed in 9c95512

_refuse_unvouched_wake_reset refuses first unless slot.agent is kirocrew-conductor or its deprecated alias kirocrew-ledger-conductor (_WAKE_RESET_AGENTS).
Pinned: test_a_non_conductor_wake_is_refused (default, kirocrew, kirocrew-worker) and test_the_deprecated_conductor_alias_is_admitted.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Specs still describe the old behaviour span=9911da394424 — fixed in 9c95512

docs/system-specs/modules/session.md and learn-cron-dashboard.md name the one admitted wake case; the autonudge_selfarm docstring states the record covers any dashboard self-arm and names both readers.
The RFC is #18097, which lands before this PR.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 8, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • One consumer, generalized span=f1fa66c64417 — fixed in ac5b50b

The record is written only for a crew/member self-arm or a self-arm of a slot running autonudge_selfarm.WAKE_RESET_AGENTS; the gate reads the same constant.
Pinned: test_other_agents_arming_themselves_are_not_recorded.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • No recorded decision on base span=5b95dd927e35 — needs-a-decision

The decision is RFC #18097 (docs-only, its own PR, same pattern as #17079). This lane reads RFC status from base.
Clears when #18097 merges and this PR is rebased onto it; a maintainer may instead post the first-principles override.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • No recorded decision on base span=8110066194aa — needs-a-decision

The decision is RFC #18097 (docs-only, its own PR, same pattern as #17079). This lane reads RFC status from base.
Clears when #18097 merges and this PR is rebased onto it; a maintainer may instead post the first-principles override.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Forbidden-list move rests on an unmerged RFC span=a3573214bf2d — needs-a-decision

The move is deliberate and is the RFC's decision (#18097). That PR lands first; this one is rebased onto it before merge.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Ledger-write precondition is prompt-only span=838adc5f2130 — rebutted

Accepted on purpose and stated in the PR body: the work ledger already holds every item, worker binding and PR, so a reset after a failed ledger write costs one wake rebuilding next.
A gateway check would need turn-scoped ledger provenance, a new mechanism for that cost. Mid-round is the same: the next wake re-reads the board.

@iamwhatever
iamwhatever force-pushed the fix/conductor-reset-between-rounds branch from 9c95512 to ac5b50b Compare October 8, 2026 10:31
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 8, 2026
@iamwhatever
iamwhatever force-pushed the fix/conductor-reset-between-rounds branch from ac5b50b to 4ed12b0 Compare October 8, 2026 11:08
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 8, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 8, 2026
@iamwhatever
iamwhatever force-pushed the fix/conductor-reset-between-rounds branch from 4ed12b0 to d9c6047 Compare October 8, 2026 17:15
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 8, 2026
@iamwhatever
iamwhatever force-pushed the fix/conductor-reset-between-rounds branch from d9c6047 to fe92431 Compare October 8, 2026 21:31
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision labels Oct 8, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • WAKE_RESET_AGENTS duplicates DEPRECATED_AGENT_SPECS span=66056bc250f4 — rebutted

autonudge_selfarm is a small trust module read by the authorizer and the directive consumer; deriving the set would import agent_materialization.conductor_agents (the spec installer) into it.
The set names two agents by policy, not by alias history; a new alias does not inherit wake-reset rights unless someone adds it here on purpose.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • A late reset breaks the ledger-first rule span=b3025c888ffa — rebutted

A deferred discard waits only for sub-agents or a pending question; it never lands mid-turn (skip_if_busy=True).
If it lands after a later turn, it drops only chat memory; the work ledger and session ledger still hold every item, worker and PR, and the next wake reads their snapshot.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • A conductor on the default patrol never gets its reset span=a621c84decc7 — rebutted

The conductor prompt's Patrol section and the goal-conductor skill already require the conductor to arm its own monitor_start, which replaces the default patrol (rfc-conductor-default-patrol).
Until it does, a refused reset changes nothing, and the skill says to carry on and retry at the next round close.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 8, 2026
@chenmingwei23
chenmingwei23 merged commit 5665e93 into main Oct 9, 2026
141 of 144 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/conductor-reset-between-rounds branch October 9, 2026 05:43
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 9, 2026
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.

Conductor: drop the chat context between rounds so long patrols stay cheap

2 participants