Repository navigation
perf: drop always-on tools from the fixed prompt - #463
Closed
hetaoBackend wants to merge 1 commit into
Closed
hetaoBackend wants to merge 1 commit into
hetaoBackend wants to merge 1 commit into
Conversation
- Only wire website_deploy (and its deploy-website / edit-deployed-website skills) when a MiniMax account access token is present. - Only expose goal tools when the session has a goal: none for no goal, get_goal only once complete, both otherwise. - Cap per-skill catalog descriptions at 300 code points (was 1024); the 5000-token total cap and protected skills are unchanged.
hetaoBackend
marked this pull request as ready for review
October 9, 2026 06:16
Collaborator
Author
|
Closing for now: changing the tool list mid-session (goal tools appearing/disappearing, website_deploy on login changes) would invalidate the prompt cache prefix, which costs more than the tokens saved. We can revisit the parts that are stable for the whole session (e.g. the skills description cap) separately. |
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.
Problem
A review of the fixed prompt (everything sent on every request before the user says anything) found tools and skill text that most sessions never use:
website_deploy(~867 tok) is registered unconditionally, plus thedeploy-website/edit-deployed-websiteskills (~121 tok in the catalog). The tool publishes through the managed MiniMax account gateway, so it cannot work without an account session (API-key and custom-provider users have no access token).update_goal(~769 tok) andget_goal(~55 tok) are sent whenever the thread-goal feature is on, even if the session has no goal. The model never creates goals (/goaland REST do), so with no goal it has nothing to read or update.Changes
buildLocalNativeRuntimeToolscreates the deploy adapter only whenauthContext.accessTokenis non-blank (newhasManagedAccountSession).deploy-website/edit-deployed-websiteare removed fromresolveFeatureAwareBuiltinSkillNamesvia a newwebsiteDeployAvailablegate, passed by both callers (local-native-tools.ts,hosted-agent-skill-capabilities.ts), so they drop out of the skill catalog and theskilltool together with the tool. Callers that don't pass the gate behave as before.GoalLifecycle.runtimeToolsFornow usessessionId: no goal record -> no tools;complete->get_goalonly; any other status (active, paused, budget_limited, blocked, usage_limited) -> both. The/goalkickoff turn already has the goal record when its tools are built, so it still gets both.LOCAL_SKILL_DESCRIPTION_MAX_CODE_POINTS1024 -> 300. Total cap (5000) and protected skills (mcode-tools-master,minimax-code-product) unchanged. Builtin descriptions are not rewritten.Does the API-key / custom-provider path have an
authContext? In the TUI (packages/tui/src/runtime/lifecycle.ts,launcher.ts)authContext.accessTokenis only populated from the MiniMax OAuth/CLI account login; BYOK providers resolve credentials in the model resolver, not throughauthContext. So API-key-only users now get nowebsite_deploy.Measured savings
Scenario: default
resolveAgentCapabilities()(all builtin tools), agentmavis, no MCP servers, 17 builtin skills. Tokens are counted with the repo'sgpt-tokenizer(OpenAI cl100k-style, NOT MiniMax's tokenizer, so read the numbers as relative). Tool size = JSON{type:function, function:{name, description, parameters}}. Both trees were measured with the same script (mainc172cf9vs this branch).This is below the 2.5k-3.5k first estimate for logged-in users; API-key users get ~2.2k. These tokens sit at the start of the request and are normally served from the prefix cache, so the real gain is cheaper cached reads and more context headroom (also a smaller first/uncached request and a smaller body for the 413 / body-limit problem), not fresh input tokens saved on every turn.
Tests
goal-lifecycle-runtime-tools.test.ts(no goal / complete / each unfinished status / disabled),feature-owned-skills-website-deploy.test.ts(gate +hasManagedAccountSession),skills-catalog-description-cap.test.ts(300 cap, protected skill untouched), and awebsite_deployauth matrix inlocal-native-tools.test.ts(no auth / no token / blank token / token).host-integration-settlement.test.ts:update_goalis no longer exposed for a complete goal, so that case asserts the tool list instead of the runtime rejection (the active-goal rejection case is kept).test/vitest-suites.jsonandrelease/public-source.json(other open PRs also edit these; expect add-line conflicts).node scripts/run-vitest-suite.mjs capability-> 217 files, 5404 passed, 18 skipped;pnpm typecheckandpnpm lintclean. Not run:check:standalone, byok/smoke (need a build; left to CI).Risks
lark-tools(1578),deep-research(948),visual-page(565),init(472),skill-creator,code-review,deploy-websitemid-text. Trigger phrases placed late are lost. Mitigation would be rewriting those builtin descriptions with the trigger up front; intentionally not done here./goalwhile a turn is running only gets tools on the next turn. A session whose login lapses loseswebsite_deployfrom the next turn.update_goal(can still be resumed/edited); onlycompleteis treated as finished.Open questions for Tao
website_deploy, or do some non-login hosts (e.g. Electron) need it via an explicit config flag?Draft, not ready for review; no reviewers requested.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.