Skip to content

fix(core): wire real turn_tool_calls counter and collapse delegate boilerplate#6328

Merged
bug-ops merged 1 commit into
mainfrom
feat/issue-6273/turnsummary-delegate-cleanup
Jul 16, 2026
Merged

fix(core): wire real turn_tool_calls counter and collapse delegate boilerplate#6328
bug-ops merged 1 commit into
mainfrom
feat/issue-6273/turnsummary-delegate-cleanup

Conversation

@bug-ops

@bug-ops bug-ops commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • TurnSummary::tool_calls was hardcoded to 0 at 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 a turn_tool_calls counter to LifecycleState, mirroring the existing turn_llm_requests pattern: reset in begin_turn, incremented in check_and_update_quota for every tool call in a dispatch batch, and read into TurnSummary::tool_calls when the turn's notification summary is built.
  • Collapsed 9 of 10 identified near-identical CommandError-wrapping delegate boilerplate blocks in agent_access_impl.rs into a single delegate_cmd! declarative macro. Covers lsp_status, handle_skill, handle_skills, handle_feedback_command, handle_plan (scheduler feature), handle_experiment, list_worktrees, clean_worktrees, and handle_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) — clean
  • cargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings — clean
  • cargo nextest run --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins -p zeph-core — 13810/13810 passed
  • Targeted nextest across quota/worktree/notification/cocoon sites — all pass
  • gitleaks protect --staged — no leaks
  • Manual trace confirms turn_tool_calls has exactly one reset site (begin_turn) and one increment site (check_and_update_quota, single caller) — no double-counting or cross-turn leakage
  • All 9 delegate_cmd!-converted sites verified byte-identical in behavior to their pre-change originals

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate bug Something isn't working size/M Medium PR (51-200 lines) labels Jul 16, 2026
@bug-ops
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
bug-ops force-pushed the feat/issue-6273/turnsummary-delegate-cleanup branch from b46e9cc to d9910c0 Compare July 16, 2026 18:38
@bug-ops
bug-ops merged commit ae917f9 into main Jul 16, 2026
43 checks passed
@bug-ops
bug-ops deleted the feat/issue-6273/turnsummary-delegate-cleanup branch July 16, 2026 18:46
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

1 participant