fix(core): wire real turn_tool_calls counter and collapse delegate boilerplate#6328
Merged
Merged
Conversation
bug-ops
enabled auto-merge (squash)
July 16, 2026 18:28
…ilerplate TurnSummary::tool_calls was hardcoded to 0 at its only production construction site; wire a turn_tool_calls counter into LifecycleState, mirroring the existing turn_llm_requests pattern (reset in begin_turn, incremented per dispatched tool call in check_and_update_quota). Collapse 9 near-identical CommandError-wrapping delegate boilerplate blocks in agent_access_impl.rs into a single delegate_cmd! macro. Closes #6273 Closes #6262
bug-ops
force-pushed
the
feat/issue-6273/turnsummary-delegate-cleanup
branch
from
July 16, 2026 18:38
b46e9cc to
d9910c0
Compare
This was referenced Jul 16, 2026
bug-ops
added a commit
that referenced
this pull request
Jul 16, 2026
…counters (#6334) PR #6328 wired LifecycleState::turn_tool_calls into TurnSummary::tool_calls, replacing a hardcoded 0, but no test exercised a real turn to prove the counters reflect actual per-turn dispatch counts. Drives real turns through check_and_update_quota via the existing MockProvider/MockToolExecutor test doubles, covering the zero-tool-call baseline, multi-tool-call batch counting, and reset-timing between turns.
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
TurnSummary::tool_callswas hardcoded to0at its only production construction site, so any consumer of the per-turn completion notification always saw zero tool calls regardless of actual turn activity. Added aturn_tool_callscounter toLifecycleState, mirroring the existingturn_llm_requestspattern: reset inbegin_turn, incremented incheck_and_update_quotafor every tool call in a dispatch batch, and read intoTurnSummary::tool_callswhen the turn's notification summary is built.CommandError-wrapping delegate boilerplate blocks inagent_access_impl.rsinto a singledelegate_cmd!declarative macro. Coverslsp_status,handle_skill,handle_skills,handle_feedback_command,handle_plan(scheduler feature),handle_experiment,list_worktrees,clean_worktrees, andhandle_cocoon(cocoon feature).handle_mcp's_match arm was intentionally left inline since it's a match arm inside a larger match, not a standalone handler fn.Closes #6273
Closes #6262
Test plan
cargo +nightly fmt --check(workspace) — cleancargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings— cleancargo nextest run --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins -p zeph-core— 13810/13810 passedgitleaks protect --staged— no leaksturn_tool_callshas exactly one reset site (begin_turn) and one increment site (check_and_update_quota, single caller) — no double-counting or cross-turn leakagedelegate_cmd!-converted sites verified byte-identical in behavior to their pre-change originals