fix(kimi): capture replies from kimi-code native wire logs; gate pane fallback#267
Open
agnitum2009 wants to merge 1 commit into
Open
fix(kimi): capture replies from kimi-code native wire logs; gate pane fallback#267agnitum2009 wants to merge 1 commit into
agnitum2009 wants to merge 1 commit into
Conversation
… fallback Deployed on o13 production CCB (generation 175/176, 2026-07-19) after the 2026-07-18/19 orchestration stalls. Backup of the live hotfix so CCB upgrades can re-apply it; patch applies byte-clean on upstream/main (v8.2.1+5214ce03). native_log.py: - Support the kimi-code session layout ~/.kimi-code/sessions/ wd_<basename[:40]>_<sha256(workdir)[:12]>/<session>/agents/*/wire.jsonl alongside the legacy ~/.kimi layout (root cause of 8+ truncated and 3 empty-failed completion replies: the native observer never found wire files, so every kimi job fell back to pane scraping or timed out). - Detect turn completion from context.append_loop_event/step.end with finishReason != tool_use (kimi-code wire has no TurnEnd), plus a finalize-on-next-turn-start safety net. - Strict-then-loose CCB_REQ_ID matching: prefer the 'CCB_REQ_ID: <id>' prompt header so co-located agents sharing one work_dir stop cross-matching each other's sessions; substring fallback kept for legacy prompt formats. - Fix session_id extraction for the <session>/agents/<agent> layout. execution.py: - Pane fallback is rescue-only (native observation is None). A prematurely-stable pane snapshot (input box visible during answer generation) can no longer truncate an in-progress native turn. Validated offline against real wire logs: 4/4 incident req_ids resolve to the correct session with clean verdict-first replies; legacy TurnBegin/ TurnEnd layout and in-flight turns unaffected. Post-restart replay (job_7567cc588895) delivered the verdict block at top with no transcript prepending.
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
The kimi native turn observer looks for wire logs only under the legacy layout
~/.kimi/sessions/<md5(workdir)>/<session>/wire.jsonl. The current kimi-code runtime writes them to~/.kimi-code/sessions/wd_<basename[:40]>_<sha256(workdir)[:12]>/<session>/agents/<agent>/wire.jsonl, so the native observer never fires: every kimi job falls back to pane scraping. In production (8-agent CCB deployment, 2026-07-18/19) this caused:... (N more lines, ctrl+o to expand), tool-output chrome),kimi_native_turn_timeout,reply_chars=0) even though the full replies existed in the provider wire logs.Two further issues surfaced while fixing this:
work_dirshare one sessions root, so a req_id mentioned in another agent's prompt could win the observation (wrong session).Fix
lib/provider_backends/kimi/native_log.py.kimilayout (kimi_code_project_dirname,kimi_code_sessions_root, glob*/agents/*/wire.jsonl); hash/naming rule verified against real session dirs.context.append_loop_event/step.endwithfinishReason != tool_use(kimi-code wire logs have noTurnEnd), plus a finalize-on-next-turn-start safety net.CCB_REQ_ID: <id>header (fixes cross-agent session confusion); plain substring matching kept as fallback for legacy prompt formats.session_idextraction for the<session>/agents/<agent>/wire.jsonllayout.lib/provider_backends/kimi/execution.pyNone); it can no longer replace an anchored but still-running native turn.Validation
completed=True, with clean verdict-first reply text — including the 3 jobs that had failed empty (their 1.3–1.5 KB replies were in the wire logs all along).TurnBegin/TurnEndlayout still completes; thinking parts (part.think) are excluded from the reply; an in-flight turn (nostep.endyet) stays not-completed.verdict: PASS+ full verdict block at the top with zero transcript prepending (job_7567cc588895). All 8 agents healthy after restart, no lost jobs.Notes
upstream/mainat 5214ce0 (post-v8.2.1).