fix: agent permissions override session on mode switch & lower default context window#641
Open
MrRealORG wants to merge 1 commit into
Open
Conversation
…lower default context window Fixes XiaomiMiMo#608: ACP plan_exit permission denied after mode switch - Reversed Permission.merge() order so agent-level permissions come after session-level permissions. Since evaluate() uses findLast(), agent permissions now correctly override stale session-level deny rules when switching modes (e.g., plan mode's plan_exit: allow overriding the session's initial plan_exit: deny). - Updated all 4 merge sites: llm.ts (resolveTools + workflow), prompt.ts (ask + task agent), debug/agent.ts. Fixes XiaomiMiMo#534: Local models show incorrect context usage percentage - Changed DEFAULT_CONTEXT_WINDOW from 1,000,000 to 128,000 tokens. - For local/OpenAI-compatible models without explicit limit.context in config or models.dev, the previous 1M default made real usage (e.g. 12%) display as ~1-2%, masking potential context overflow.
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
Fixes two issues:
Fix #608: ACP
plan_exitpermission denied after mode switchWhen switching to plan mode via ACP,
plan_exittool calls failed with permission denied because session-level deny rules (set at session creation) overrode the plan agent'splan_exit: allowrule.Root cause:
Permission.merge()placed agent permissions before session permissions. Sinceevaluate()usesfindLast(), session-level rules always won, meaning mode-specific agent permissions could never override stale session-level restrictions.Fix: Reversed the merge order in all 4 merge sites so agent permissions come after session permissions:
session/llm.ts—resolveTools()and workflow model preapproved toolssession/prompt.ts— per-tool-callask()and task/spawned agent askcli/cmd/debug/agent.ts— debug agent rulesetThis is safe because:
mimo run: session hasplan_exit: deny, agent defaults also haveplan_exit: deny→ result unchangedplan_exit: deny, plan agent hasplan_exit: allow→ allow now correctly winsFix #534: Local models show incorrect context usage percentage
DEFAULT_CONTEXT_WINDOWwas 1,000,000 tokens. For local/OpenAI-compatible models without explicitlimit.contextconfig or models.dev entry, this made real usage (e.g. 12%) display as ~1-2%, masking potential context overflow.Changed to 128,000 — a conservative default that gives more accurate percentage display while the existing warning log directs users to configure the actual limit.
Test Plan
plan_exittool is available and callableplan_exitis still denied for build agentlimit.context, verify context percentage is more accuratemimo runbehavior unchanged (plan tools still denied)