Repository navigation
fix: six findings from live perf-monitoring (#152 #153 #155 #156 #157 #158) - #160
Merged
Merged
Conversation
…ogress terminals
A free-text Subagent that ended StopNoProgress or an empty StopEndTurn
returned the opaque "(subagent produced no summary)", discarding the
child's work. Slow reasoning models (e.g. glm-5.2 via the router) emit
reasoning-only/empty turns, exhaust the no-progress nudges, and hit
StopNoProgress with empty final text — so whole delegated branches came
back empty.
- Widen the salvage trigger (salvageEmptyLimitStop -> salvageEmptyStop)
to any empty terminal stop via isEmptyTerminalStop {MaxTurns,
MaxToolCalls, Budget, NoProgress, EndTurn}; ResetUsage stays scoped to
StopBudget only (NoProgress/EndTurn must keep the carried budget as the
salvage-turn brake).
- Last-resort digestChildActivity: recover the child's last assistant
text when salvage yields nothing.
- StopNoProgress note names the reason and points at recovery; the
worst-case placeholder is no longer a dead end (resume via agentId).
- Result always carries the agentId trailer; never silently empty.
Closes #152
Co-Authored-By: Claude Opus 4.8 <[email protected]>
The Bash tool discarded the partial stdout/stderr the runner had already captured when Run returned a ctx error, telling the model only "command failed to run: <err>". A command that produced useful output before timing out gave the model nothing actionable. - Surface captured res.Stdout/res.Stderr on the runner-error path, with a classified reason trailer: timeout (naming timeout_ms only when set — never fabricating the runner's private default), cancel, no-shell, or generic. Result stays is_error so the model adapts. - Trailer is composed AFTER budgeting/truncating the body, so a runaway timed-out command (huge output) never loses its timeout signal to the 25000-byte cap. Export toolkit.TruncationMarker as the single source of truth for the reservation. - Do not print "[exit code: 0]" on the ctx-error path (it reads as success); the trailer is the status signal there. - bashDescription documents the behavior and that cancel/no-shell are not retryable (only timeouts are). Closes #153 Co-Authored-By: Claude Opus 4.8 <[email protected]>
…deltas mecatl_ttft_seconds never recorded for tool-call-first or reasoning-replay-blob turns: the TTFT anchor (noteContent) fired only on ChunkText/ChunkReasoning display deltas, so pure tool-call turns (the bulk of an agentic run) and reasoning-delivered-as-encrypted-blob turns left TTFTMs=0 and the telemetry >0 guard skipped every observation — the histogram never materialized. - Split the dual-duty noteContent into a turnLatency value object: noteFirstOutput (TTFT anchor on the FIRST observable output of any kind, first-only) and noteStreamDelta (inter-token gap accounting on genuine text/reasoning deltas only). ChunkToolCall/ChunkReasoningItem now anchor TTFT; ChunkText/ChunkReasoning seed the gap series. One clock read per delta preserved (byte-identical gap timing); a scripted-clock over-read oracle pins that parity (mutation-tested). - Gap series stays pure (a tool call never appends a spurious inter-token gap), proven for both empty and non-empty series. - TTFT now means "time to first observable output (text, reasoning, reasoning replay item, or tool call)"; event.go field doc + the metric description reworded (instrument name unchanged). ChunkPhase/Usage/Done still do not anchor. Closes #155 Co-Authored-By: Claude Opus 4.8 <[email protected]>
…"skipped" Agent defs ported from other harnesses were silently truncated and logged as "agent def skipped", which reads as "not loaded" — but the def was kept and functional, just clipped. - Raise the caps asymmetrically by blast radius: MaxAgentBodyBytes 8KiB -> 32KiB (cheap — in-context only for that one specialist engine, covers 10-20KB ported specialist prompts), MaxAgentDescriptionBytes 800 -> 2000 (expensive — rides every request x all agents on the byte-stable prompt-cache prefix, so kept conservative). One-time deterministic cache-prefix invalidation. (engine API const values changed -> api:update + engine/CHANGELOG.md, classified Changed.) - Replace the overloaded "agent def skipped" WARN with a STRUCTURAL split: SkipError.Fatal (set at the def-excluding sites) drives "agent def dropped" (excluded) vs "agent def adjusted" (kept), the latter carrying outcome="agent still loaded" so the operator knows it is usable. A closed-set classification test fails loudly if a future fatal site forgets Fatal:true. - Constants-only (no configurable override); deferred-config path noted. Closes #156 Co-Authored-By: Claude Opus 4.8 <[email protected]>
…antiles
The latency instruments used base-2 exponential-histogram views, which the
otel-prometheus exporter renders as native histograms — in the classic
text exposition (a plain `curl :9099/metrics`) those show only le="+Inf",
so a human/promtool could not get p50/p90/p99. (The perf-MCP reducer
already reconstructed quantiles from the native fields, so the agent path
was fine; only the human text path was blind.)
- Switch the latency instruments to explicit-bucket histograms with a
ms-to-minutes ladder {0.001 .. 300}s, so /metrics, promtool, and the MCP
reducer all yield real le= buckets and quantiles with zero scrape config.
The lost exponential-tail precision is unconsumed today (no OTLP metrics
reader is wired).
- Verified all six latency record sites feed SECONDS (msToSeconds /
Duration.Seconds), so the ms-scale low-end buckets have real resolution;
an end-to-end ms-resolution test now guards that conversion.
- New ADR 0045 supersedes ADR 0018 §5 decision 2 (histogram aggregation
only); 0018's body is unchanged (status pointer added).
Closes #158
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…measurement gap
Live monitoring fingered main-turn allocation churn (per-turn full
conversation re-marshal + SSE decode), but that path had ZERO offline
benchmark coverage — every bench drives mockllm, which bypasses the
adapter request-assembly and decode entirely — so the hypothesis could
never be ranked.
- Add internal/adapter/{anthropic,openai}/request_bench_test.go: benchmark
buildParams/buildMessages/buildInput (our glue), buildParams+json.Marshal
(the full per-turn re-marshal), and the test-only decodeSSE/translate
glue, over synthetic 50/200/500-message conversations.
- Profile (alloc_objects) verdict: the per-turn re-marshal is ~92%
(anthropic) / ~87% (openai) the provider SDK's reflection-based
json.Marshal — code we don't own — with our glue a small, already
capacity-presized remainder. No byte-identical win exists in our glue
without risking the byte-stable prompt-cache prefix. So: gap closed,
NO source change (matches the GC-absorbed live data: pauses <=262us).
- The benches are a runnable human A/B / regression guard; deliberately
NOT wired into the fail-closed allocs-gate (an SDK-dominated number
shifts on SDK bumps); glue-only gating noted as a follow-up.
Closes #157
Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Six issues found while live-monitoring a running
mecatui --perfsession, each delivered through the dev pipeline (architect → separate implementer → parallel review panel → iterate → commit-per-issue). One commit per issue; fulltask lint/task test/api:checkgreen on the complete branch.Opened as a single PR so the live-e2e CI lane exercises the behavior fixes against real models — notably #152 (triggered by a slow reasoner, glm-5.2) and #155 (TTFT across real tool-call/reasoning turns).
Fixes
b80d04e— Closes Subagent returns opaque "(subagent produced no summary)" on StopNoProgress / empty StopEndTurn, discarding its work #152 (fix(agent)): a subagent endingStopNoProgress/ emptyStopEndTurnreturned the opaque(subagent produced no summary), discarding its work. Now salvages a bounded wrap-up turn, then digests the child's last activity, then names the stop reason + points at recovery — always with theagentIdtrailer, never silently empty.befa45d— Closes Bash tool discards captured partial output on runner error (timeout/cancel), returning only the error reason #153 (fix(tools)): Bash discarded the partial output the runner had already captured on a timeout/cancel. Now surfaces it with a classified reason trailer that survives output truncation;is_errorstays true; cancel/no-shell flagged non-retryable.a337d90— Closes TTFT metric (mecatl_ttft_seconds) never recorded — "first content token" detection is coupled to display-delta chunk kinds #155 (fix(agent)):mecatl_ttft_secondsnever recorded for tool-call-first or reasoning-replay-blob turns (the anchor fired only on display deltas). Split into TTFT-anchor (first observable output of any kind) vs inter-token-gap (streaming deltas only), so TTFT records without polluting smoothness stats. One-clock-read parity pinned by a mutation-tested over-read oracle.140d187— Closes Agent-def caps (description 800B / body 8192B) truncate ported defs, and the "agent def skipped" log is misleading #156 (fix(agents)): raised agent-def caps (body 8KiB→32KiB, description 800→2000B — asymmetric by blast radius) so ported defs aren't silently truncated, and replaced the misleadingagent def skippedWARN with a structuraldroppedvsadjusted(kept,outcome="agent still loaded") split. Engine API const-value change →api:update+ CHANGELOG (Changed).92a5f9c— Closes Latency-histogram quantiles (p50/p90/p99) unavailable on the --perf Prometheus /metrics surface #158 (fix(telemetry)): latency histograms were exponential, which the Prometheus exporter renders as+Inf-only in the text exposition (no quantiles for a plaincurl/promtool). Switched to explicit-bucket histograms (ms→minutes ladder) for zero-config quantiles on/metrics, promtool, and the perf-MCP reducer. New ADR 0045 supersedes ADR 0018 §5 decision 2 (histogram aggregation only). (The premise was partly corrected during review — the perf-MCP path already reconstructed quantiles from native fields; only the human text path was blind.)4f734b4— Closes Optimize main-turn allocation churn (per-turn full-conversation re-marshal + chunk decode + render) #157 (perf(adapter)): profile-driven. The per-turn re-marshal path had zero offline benchmark coverage (mockllm bypasses it). Added adapter request-assembly + decode benches; the profile shows the cost is ~87–92% the provider SDK's reflectivejson.Marshal(not our code), with no byte-identical win that doesn't risk the prompt-cache prefix. Gap closed with measurement + a regression guard; no source change (matches the GC-absorbed live data). Benches deliberately not wired into the fail-closed allocs-gate (SDK-dominated number).Notes
0041onmain(direct-write-subagent,output-economy-default-prompt) — flagged for a separate cleanup, not touched here.🤖 Generated with Claude Code