fix(agent-core): allow skill questions in auto mode#925
Conversation
🦋 Changeset detectedLatest commit: b0f7284 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0f72842a1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| evaluate(context: PermissionPolicyContext): PermissionPolicyResult | undefined { | ||
| if (this.agent.permission.mode !== 'auto') return; | ||
| if (context.toolCall.name !== 'AskUserQuestion') return; | ||
| if (currentRequestIsLoadedSkill(this.agent.context?.history ?? [])) return; |
There was a problem hiding this comment.
Preserve skill context after compaction
When auto/full compaction runs during a long skill-triggered turn, ContextMemory.applyCompaction() replaces the compacted prefix, including the original skill_activation user message, with an assistant compaction_summary. This policy then scans history for the latest non-internal user message and can no longer see that the current request came from a loaded skill, so subsequent AskUserQuestion calls from that same skill are denied again in auto mode. Please persist the active skill/request origin outside compactable history or teach the compaction summary path to preserve it.
Useful? React with 👍 / 👎.
Summary
Fixes #824.
Auto permission mode still blocks normal
AskUserQuestioncalls, but loaded skills can now ask clarifying questions when the current request comes from a skill activation.The policy now looks at the most recent non-internal user request:
AskUserQuestionin auto modeAskUserQuestionthrough so it reaches the question UIAlso updates the auto-mode reminder text and adds a changeset for the CLI-visible behavior fix.
Validation
pnpm --filter @moonshot-ai/agent-core exec vitest run test/agent/permission.test.tspnpm --filter @moonshot-ai/agent-core exec vitest run test/agent/tool.test.tspnpm --filter @moonshot-ai/agent-core run testpnpm --filter @moonshot-ai/agent-core run typecheckpnpm exec oxlint --type-aware packages/agent-core/src/agent/permission/policies/auto-mode-ask-user-question-deny.ts packages/agent-core/src/agent/injection/permission-mode.ts packages/agent-core/test/agent/permission.test.ts packages/agent-core/test/agent/tool.test.ts --quietpnpm --filter @moonshot-ai/agent-core run buildgit diff --checkChecklist
AI Assistance Disclosure
I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.