Repository navigation
fix(skills): [Crew pulse] run the dedupe and merge judges on a fresh conversation - #30878
Closed
jasonzzj97 wants to merge 1 commit into
Closed
jasonzzj97 wants to merge 1 commit into
jasonzzj97 wants to merge 1 commit into
Conversation
Each judge prompt is self-contained, but both judges ran as one more turn of the shared _bg conversation, so every request resent the earlier judges' prompts and replies until the 70% / 40-prompt recycle. Ask background_turn for fresh_conversation=True, as consolidation already does. Part of kirodotdev#30197
5 tasks done
Contributor
|
[operator: bolichen97] Continuing this in #36730; thanks for the start. |
KiroCrewCaptain
pushed a commit
that referenced
this pull request
Nov 13, 2026
…36730) The skill dedupe and merge judges run on the shared background session _bg, and each call was sent as one more turn of its conversation. Every request therefore resent every earlier judge's prompt and reply until the recycle at 70% context or 40 prompts, about 81% of the dedupe judge's input, and the next _bg job inherited that history too. Both judges now pass fresh_conversation=True to background_turn, the same flag consolidation already uses: each judge leaves _bg on an empty conversation of the same warm runtime before its permit is released, and the context recycle no longer runs after it. On _bg the flag applies only when the provider swaps conversations in place. On a backend with no shared runtime, _bg's one-liner handles wait on the _bg entry itself, and the reset fallback would pop it under them, so such a _bg turn recycles as before. Builds on #30878 by @jasonzzj97. Part of #30197 Co-authored-by: Ziji Zhang <42743036+jasonzzj97@users.noreply.github.com>
Contributor
Author
|
Superseded by #36730, which landed this change (plus a guard for backends without a shared runtime) on main. Closing in favour of it. Thanks @KiroCrewCaptain for carrying it through. The knowledge-pool half of #30197 will follow in a separate PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem / Motivation
Goal: The skill dedupe and merge judges stop resending earlier judges' prompts and replies with every request.
Both judges run on the shared background session
_bg. Each judge prompt is self-contained, but each call was sent as one more turn of_bg's conversation, so every request also carried every earlier judge's prompt and reply on that key until the recycle at 70% context or 40 prompts. Any_bgjob that follows, such as a chat title, inherits that history too. This is the first of the two places #30197 describes; the knowledge pool is the second.Why it matters
In live Crew traffic about 81% of the skill dedupe judge's input is resent history (#30197). It costs tokens, makes each request larger and slower, and gives the judge earlier candidates and an older skill list it was never meant to read.
Not a goal
knowledge/llm_pool.py). ItsAcpWorkerhas no cheap reset yet, so a per-call reset there would restart the process for every chunk; that is the second step of [Crew Pulse] Skill judges and knowledge extraction resend their conversation history on every call (~76% of their input) #30197 and a separate PR._bgcaller. Channel auto-titles (messaging/auto_title.py) stack on_bgthe same way, but a title is user-visible, so they keep the shared conversation until the 6 s wait below is fixed.What changed (motivation → approach → change)
Consolidation fixed the same pattern in #22207:
HistoryConsolidator._call_llmasksbackground_turnforfresh_conversation=True, which opens a new conversation on the running process before the permit is released._dedupe_judgeand_merge_skill_updateinsrc/kiro_crew/history_consolidation_skills.pynow pass the same flag. Each judge keeps what_bgwas chosen for (#392, #2253): the same warm runtime, the same queue and the same cheap model. Only the history is dropped, and the context recycle no longer runs after a judge because the conversation is already empty.docs/system-specs/modules/history.mdnotes it next to the existing line that the judges stay on_bg.#30197 asked whether the fallback reset could reload
_bg's old conversation, since_bgis a persistent key. It cannot:_bg's session id is never written to the session map (session_lifecycle_parts/fleet.py,key != constants.background_key), and_ensure_backgroundstarts it with no resume id. A new test runs that fallback for real.Backwards compatibility
Compatible: the judges' prompts, replies, model and session key are unchanged; only the conversation each one runs in is new.
Removes nothing: no field, key, config value or caller is removed or renamed;
background_turnalready acceptedfresh_conversation.Tests
test/test_consolidation_fresh_conversation.py, next to fix(memory): start every global consolidation job on an empty conversation (#20463) #22207's tests and on the same real-path harness (a realSessionManageron the packaged fake ACP backend, which records each request):_bgeach send turn 1 of their own conversation on one process, and none carries an earlier judge's text;new_conversationfailing, the reset fallback on_bg(a persistent key, unlike_consolidate) starts new conversations with none of the judges' history.test/test_history_coverage.py: the two judge tests that assertedrecycle_backgroundwas awaited now assert a fresh conversation instead.Proof: PROVEN test/test_consolidation_fresh_conversation.py::test_skill_judges_each_send_only_their_own_prompt_on_bg, test/test_consolidation_fresh_conversation.py::test_the_reset_fallback_on_bg_does_not_resume_the_judges_history, test/test_history_coverage.py::TestDedupeJudge::test_returns_text_and_releases_session, test/test_history_coverage.py::TestMergeSkillUpdate::test_returns_merged_body_and_prompts_with_all_inputs (head 2e8d9ef)
python3 scripts/local-gate.py: 1810 related backend tests passed. black, isort, flake8, mypy on the changed files and./scripts/docs-lint.share clean.Manual verification
Ran six dedupe judges (real
build_dedupe_promptprompts), one merge judge and one chat-title turn on_bgin an isolated Crew in Docker built fromd775742d19(Crew 0.13.0, kiro-cli 2.27.1 and the bundled KAS), on this branch and on main, through a realSessionManager. Context is what kiro-cli reports per call; KAS reports none.Verdicts and credits varied from run to run on both arms, so these runs show no effect on either.
The reset is not the 0.15 s #30197 quotes.
session/newtakes about 0.15 s; the new session then waits out the 6 s MCP-readiness ceiling (_MCP_DRAIN_NO_REPORT_CEILING), becausekirocrew-litehas no MCP servers to report. With the ceiling at 0 the reset took 0.45-0.62 s. Until that is fixed, each judge holds_bgabout 6 s longer, as each consolidation job already holds_consolidate. On kiro-cli each new session also logs onepre-turn drain discarded 1 leftover frame(s)warning.Screenshots / video
None
Related Issues
Part of #30197
Sibling sweep
Swept: git grep -n "background_turn(" -- src/kiro_crew
Sibling: src/kiro_crew/history_consolidation_pass.py:1434 -- not affected -- consolidation already passes fresh_conversation=True
Sibling: src/kiro_crew/messaging/auto_title.py:559 -- tracked in #30197
Sibling: src/kiro_crew/knowledge/llm_pool.py -- tracked in #30197
Pattern harvest
Not generalizable: the remaining callers of background_turn on a shared key each need a judgement on whether their prompt is self-contained, which a lint cannot make.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.