fix(tui): filter metrics always zero in native tool execution path (#1939)#1946
Merged
fix(tui): filter metrics always zero in native tool execution path (#1939)#1946
Conversation
…ls loops In the native tool execution path, two "remaining tools" loops (self-reflection success path and error path) discarded filter_stats from tool outputs, sending ToolOutputEvent with filter_stats: None and skipping metric updates. This caused filter_raw_tokens, filter_saved_tokens, and filter_applications to remain zero in the TUI even when tools produced filtered output. Both loops now extract filter_stats from Ok(Some(out)) results, update filter_* metrics (same pattern as the normal processing loop), and pass inline_stats to ToolOutputEvent. Adds a regression test that verifies filter_* metrics increment when the native tool path processes a tool returning FilterStats. Closes #1939
…reflection path test Move the filter-stats metric update block into Agent::record_filter_metrics (utils.rs), matching the existing method in legacy.rs which is now removed. All three call sites in native.rs are replaced with self.record_filter_metrics(fs). Add filter_stats_metrics_recorded_in_self_reflection_remaining_tools_loop test: two parallel tool calls via native path, first returns [error] triggering self-reflection, second returns FilterStats. Verifies filter_applications/filter_raw_tokens/filter_saved_tokens are recorded from the remaining-tools loop — the code path fixed in #1939. Closes review findings on fe715d9.
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
filter_raw_tokens,filter_saved_tokens, andfilter_applicationsmetrics in the TUI dashboard always showed zero even when tool execution with output filtering occurred via the native pathcrates/zeph-core/src/agent/tool_execution/native.rs(self-reflectionOk(true)andErr(e)branches) silently discardedFilterStatsfrom parallel tool outputs without recording metricsrecord_filter_metricsextracted toagent/utils.rsas a sharedpub(super)helper; now called from all four metric-recording sites (3 native + 1 legacy)Changes
crates/zeph-core/src/agent/tool_execution/native.rs: fixed both remaining-tools loops to extractfilter_statsand callrecord_filter_metricscrates/zeph-core/src/agent/utils.rs: newrecord_filter_metricsmethod (DRY consolidation)crates/zeph-core/src/agent/tool_execution/legacy.rs: removed duplicaterecord_filter_metricsdefinition; delegates toutils.rscrates/zeph-core/src/agent/tests.rs: two new regression testsTest plan
cargo nextest run --config-file .github/nextest.toml -p zeph-core— 1939 tests passcargo clippy --workspace --features full -- -D warnings— cleancargo +nightly fmt --check— cleanfilter_stats_metrics_increment_on_normal_native_tool_pathexercises the normal single-tool pathfilter_stats_metrics_recorded_in_self_reflection_remaining_tools_loopdirectly exercises the fixed self-reflection remaining-tools branchCloses #1939