Skip to content

fix: agent permissions override session on mode switch & lower default context window#641

Open
MrRealORG wants to merge 1 commit into
XiaomiMiMo:mainfrom
MrRealORG:fix/auto-202606150428-acp-perm-context-default
Open

fix: agent permissions override session on mode switch & lower default context window#641
MrRealORG wants to merge 1 commit into
XiaomiMiMo:mainfrom
MrRealORG:fix/auto-202606150428-acp-perm-context-default

Conversation

@MrRealORG

Copy link
Copy Markdown

Summary

Fixes two issues:

Fix #608: ACP plan_exit permission denied after mode switch

When switching to plan mode via ACP, plan_exit tool calls failed with permission denied because session-level deny rules (set at session creation) overrode the plan agent's plan_exit: allow rule.

Root cause: Permission.merge() placed agent permissions before session permissions. Since evaluate() uses findLast(), 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.tsresolveTools() and workflow model preapproved tools
  • session/prompt.ts — per-tool-call ask() and task/spawned agent ask
  • cli/cmd/debug/agent.ts — debug agent ruleset

This is safe because:

  • For mimo run: session has plan_exit: deny, agent defaults also have plan_exit: deny → result unchanged
  • For ACP plan mode: session has plan_exit: deny, plan agent has plan_exit: allow → allow now correctly wins

Fix #534: Local models show incorrect context usage percentage

DEFAULT_CONTEXT_WINDOW was 1,000,000 tokens. For local/OpenAI-compatible models without explicit limit.context config 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

  • Start ACP session, switch to plan mode, verify plan_exit tool is available and callable
  • Start ACP session in default mode, verify plan_exit is still denied for build agent
  • Configure a local model without limit.context, verify context percentage is more accurate
  • Verify mimo run behavior unchanged (plan tools still denied)

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant