fix(kohaku): clean runtime display when kt is the core#3
Merged
Conversation
When kt is the core, the chat flooded with backend runtime detail and the delegation sentinel leaked into the live bubble. Root causes (all inside the kohaku adapter, per the provider-differences-stay-in-the-adapter invariant): - The consumer mirrored every `kt --json` protocol line as terminal output, replaying the whole machine stream into the live-execution card. Only genuine non-JSON stdout is now surfaced; protocol lines are parsed-only. - kt's native vocabulary (text/activity/turn_start/turn_end/error) was unknown to the shared recognizers, so activity/turn_start rendered as generic [activity] markers. classify() now recognizes the full vocabulary; turn.rs drops telemetry + turn_start and translates genuine tool/subagent calls into normalized (collapsed) tool_call cards. - The sentinel streamed token-by-token, leaking fragments into the bubble. A stateful SentinelDisplayFilter withholds any BEGIN..END block (and partial markers split across deltas) from the display channel while the full body still reaches the router for delegation. - Structured turn errors are surfaced as the response reason instead of a raw JSONL dump; no-delta turn_end.text bodies now stream live. Frontend: renderMessageBody strips sentinel blocks defensively (complete + unclosed-trailing) regardless of delegate parsing. The shared strip_sentinel_blocks stays conservative (no cross-provider behavior change). Tests: fake_kt gained a split-sentinel path; a new integration test asserts no protocol mirroring and no sentinel leakage into the chat. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…eadline
The live-execution card showed "正在运行 kt.exe" and counted the driver as a
command, while the real kt tool activity wasn't counted. Both stemmed from the
kt.exe execution_telemetry feeding the frontend's `commandLine` (which drives
both the running headline and `commandCount`):
- Stop emitting execution_telemetry for kohaku — kt.exe is Switchyard's own
driver, not a model action. The resolved invocation is still recorded in the
archived raw-output artifact for replay/diagnostics.
- Map genuine kt tool/subagent activity to command_execution items (was
tool_call) so the live card counts them ("已运行 N 条命令") and shows the
running one in its headline ("正在运行 <tool>") — the same surfaces
codex/claude drive via their command items. start->done/error merge (by
command) into one transitioning card.
The integration test now asserts kohaku emits no execution_telemetry and that
tool activity surfaces as counted command_execution items.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
After kohaku stopped emitting the kt.exe execution_telemetry, a turn whose
tools had all completed (none currently running, and no launcher commandLine
to fall back on) fell through to the "Provider 正在运行,暂无工具事件…" status
even while `commandCount` showed commands had run — a confusing contradiction.
The live-execution card now falls back to the most recent command that ran
("已运行 <cmd>") when none is currently active, keeping the headline consistent
with the count. This also improves codex/claude (the last real command shows
between batches instead of the launcher invocation).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
When KohakuTerrarium (
kt) is the core, the chat surfaced backend runtime detail instead of the model's message. Three fixes, all keeping provider differences inside the adapter.1. Show only the LLM message, not kt runtime noise (
cc7fc11)kt --jsonprotocol line as terminal output, replaying the whole machine stream into the live-execution card. Now only genuine non-JSON stdout is surfaced; protocol lines are parsed-only.classify()recognizes kt's full vocabulary (text / activity / turn_start / turn_end / error);turn.rsdrops telemetry + turn_start and translates genuine tool/subagent calls into normalized items.SentinelDisplayFilterwithholds the<<<SWITCHYARD_JSON_BEGIN>>>…END>>>delegation block (incl. markers split across deltas) from the live bubble while the full body still reaches the router for delegation. Structured errors are surfaced as the response reason; no-deltaturn_end.textbodies stream live.renderMessageBodystrips sentinel blocks defensively; the sharedstrip_sentinel_blocksstays conservative (no cross-provider behavior change).2. Count kt tool activity as commands; drop the kt.exe driver headline (
04f8e1e)execution_telemetryfor kohaku —kt.exeis Switchyard's driver, not a model action (it was hijacking the "正在运行 kt.exe" headline and inflating the command count). The resolved invocation stays in the archived raw-output artifact.command_executionitems so the live card counts them ("已运行 N 条命令") and shows the running one in its headline.3. Reflect completed commands on the live card, not "暂无工具事件" (
ed8caee)commandCount > 0. The card now falls back to the most recent command that ran, consistent with the count (also improves codex/claude).Verification
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace --all-targets, and the frontendnpm run buildall pass. New: a split-sentinel path infake_ktand an integration test asserting no protocol mirroring, no sentinel leakage, noexecution_telemetry, and tool activity surfaced as countedcommand_executionitems.🤖 Generated with Claude Code