Skip to content

feat(tui): show tool and MCP schema costs - #5603

Closed
wuisabel-gif wants to merge 1 commit into
Hmbown:mainfrom
wuisabel-gif:wuisabel/5553-context-cost
Closed

feat(tui): show tool and MCP schema costs#5603
wuisabel-gif wants to merge 1 commit into
Hmbown:mainfrom
wuisabel-gif:wuisabel/5553-context-cost

Conversation

@wuisabel-gif

Copy link
Copy Markdown
Contributor

Summary

Addresses the approved display-only slice of #5553.

The context inspector now shows bounded schema-cost estimates from the last model tool catalog:

  • a catalog total and per-built-in-tool rows sorted by estimated token cost;
  • a bounded row list with an omitted-count summary for large catalogs;
  • one row per discovered MCP server with estimated cost and known/announced tool counts;
  • explicit zero-cost rows for servers with no announced tools.

The estimates serialize the existing Tool definitions and use the same conservative character-to-token approximation already used by the inspector. MCP server rows match announced model_name entries against the last transmitted catalog, so deferred/not-yet-transmitted tools are not falsely counted as present in the current request.

No prompt assembly, tool catalog construction, MCP discovery, or cache behavior changes.

Tests

Passed:

  • cargo fmt --all -- --check
  • git diff --check
  • cargo test -p codewhale-tui --lib 'tui::context_inspector' --locked (13 passed)
  • CARGO_INCREMENTAL=0 cargo clippy -p codewhale-tui --all-targets --locked -- -D warnings

Coverage includes catalog ordering and row bounds, MCP server attribution, empty MCP servers, existing context-inspector output, and localization regression coverage.

No provider credentials or network access are required.

No-Issue: This PR addresses the approved #5553 display-only slice without automatically closing the broader issue.

Add bounded per-tool catalog estimates and per-server MCP announcement totals to the context inspector without changing prompt assembly or cache behavior. Cover ordering, truncation, and empty-server cases for Hmbown#5553.
@wuisabel-gif
wuisabel-gif requested a review from Hmbown as a code owner August 24, 2026 16:12
@github-actions

Copy link
Copy Markdown
Contributor

Thanks @wuisabel-gif for taking the time to contribute.

This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant recurring PR access by commenting /lgtm on a pull request.

Hmbown pushed a commit that referenced this pull request Aug 24, 2026
Display-only slice of #5553 by Isabel Wu (wuisabel-gif). Estimates
bounded schema-token cost for the built-in tool catalog and each
discovered MCP server in the context inspector; no prompt assembly,
catalog, or cache behavior change.
@Hmbown

Hmbown commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Taken into the 0.9.12 integration branch (3451c0f58 on codex/v0912-integration-20260823) — merge commit, authorship preserved. Verified there: focused context_inspector slice 14/14, full tui lib suite 11172 passed / 0 failed, clippy --lib --tests clean, sync-changelog.sh produced no drift. The GitHub-side merge into main follows the 0.9.12 release flow.

@Hmbown Hmbown left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the context-inspector schema-cost slice. Catalog vs MCP attribution is bounded, prompt assembly is unchanged, and the inspector test covers catalog totals, row cap, MCP match, and empty servers. CI is green. Taking this onto main.

Hmbown commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Taking this via #5611 — rebased onto main after #5604 with authorship preserved. This fork branch now conflicts on CHANGELOG, so the GitHub-side merge of this PR is blocked; 5611 is the landing path.

Hmbown commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Already integrated on codex/v0912-integration-20260823 as 3451c0f58 (Merge PR #5603: show tool and MCP schema costs in the context inspector). Closing this PR as superseded / already-integrated; not merging via GitHub.

Hmbown commented Aug 27, 2026

Copy link
Copy Markdown
Owner

@wuisabel-gif — same class of mistake as #5608, and the same apology.

This PR was closed as already on the 0.9.12 integration branch (3451c0f58). The rebase vehicle #5611 was then also closed as "byte-identical on integration." I just checked current origin/main (a96ea6cb). Neither is on main.

On main right now: no push_tool_schema_costs, no MAX_SCHEMA_COST_ROWS, no tool_schema_tokens, no inspector_reports_catalog_and_mcp_schema_costs_with_bounded_rows. The context inspector does not show tool/MCP schema costs.

The display-only #5553 slice is therefore still outstanding. Closing these PRs as landed was true of a stale integration head, not of origin/main.

Rescue plan: local worktree cw-pr5603-rescue-20260827, two commits on top of current main, your authorship on the feature:

  • c6855bb70 feat(tui): show tool and MCP schema costs — Isabel Wu
  • e82a70e23 fix(tui): give schema costs a distinct localized section — maintainer follow-through for the duplicate "Recent Tools" header that the feat(tui): show tool and MCP schema costs (#5603) #5611 review caught (MessageId::CtxInspToolSchemaCosts)

That branch is not yet an origin PR. Another lane owns opening/merging it. I am not reopening this fork PR or #5611; both heads are stale. I am not merging from this lane.

Credit stays with you. #5553 remains the broader issue and should not auto-close from this slice.

Hmbown commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Re-landing this on current main as #5653.

#5603 (and the later grok rebase #5611) were closed as already integrated on the 0.9.12 integration branch, but the work never reached origin/main. Authorship of the feature commit is preserved for @wuisabel-gif.

Hmbown added a commit that referenced this pull request Aug 27, 2026
Rescue of @wuisabel-gif #5603 onto main. Authorship preserved.

The original PR never reached origin/main despite being closed as landed.

Hmbown commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Landed on main via #5653 (d4d9a567d).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants