Skip to content

fix: remove empty --allowedTools arg that breaks Claude Code ask mode#46

Open
yicheny wants to merge 1 commit intoDoctor-wu:mainfrom
yicheny:fix/ask-mode-empty-allowed-tools
Open

fix: remove empty --allowedTools arg that breaks Claude Code ask mode#46
yicheny wants to merge 1 commit intoDoctor-wu:mainfrom
yicheny:fix/ask-mode-empty-allowed-tools

Conversation

@yicheny
Copy link
Copy Markdown

@yicheny yicheny commented Mar 20, 2026

Problem

/ask mode in Discord always fails with:

❌ Error: Input must be provided either through stdin or as a prompt argument when using --print

Root Cause

askModeArgs is set to ["--allowedTools", ""]. When Claude Code is invoked in auto permission mode, the final command becomes:

claude -p --output-format stream-json --verbose --allowedTools "" "actual prompt"

Claude Code 2.1.80 treats the empty string "" from --allowedTools as the positional prompt argument, causing the actual prompt to be silently dropped.

Fix

Remove the empty --allowedTools flag from ask-mode args. The resulting command correctly passes the prompt as the positional argument:

claude -p --output-format stream-json --verbose "actual prompt"

Changes

  • packages/core/src/agent/tools.ts — Changed askModeArgs from ["--allowedTools", ""] to []
  • Updated corresponding tests in tools.test.ts and session.test.ts

Fixes #45

Summary by CodeRabbit

  • Tests
    • Updated ask mode argument handling test expectations to reflect removal of --allowedTools flag from generated arguments

Claude Code 2.1.80 treats the empty string from `--allowedTools ""` as the
positional prompt argument, causing the actual prompt to be silently dropped
and producing:

  Error: Input must be provided either through stdin or as a prompt argument
  when using --print

Remove the empty `--allowedTools` flag from ask-mode args so the prompt is
passed correctly.

Fixes Doctor-wu#45
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 20, 2026

📝 Walkthrough

Walkthrough

The changes fix a bug in /ask mode where an empty --allowedTools "" flag was causing Claude Code 2.1.80 to ignore the actual prompt argument. The fix removes this problematic flag from ask mode arguments entirely, restoring proper prompt parsing across source code and tests.

Changes

Cohort / File(s) Summary
Ask Mode Arguments Fix
packages/core/src/agent/tools.ts
Changed askModeArgs from ['--allowedTools', ''] to [] to eliminate the empty flag that interfered with prompt argument parsing in Claude Code 2.1.80.
Test Assertions
packages/core/src/agent/__tests__/session.test.ts, packages/core/src/agent/__tests__/tools.test.ts
Updated test expectations to assert that ask mode generates an empty arguments array instead of ['--allowedTools', ''], aligning tests with the bug fix.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hollow toolbox haunted the ask command's way,
Empty flags made prompts vanish astray.
No longer—askModeArgs now flows free and clean,
The prompt runs true where it should have been! 🎯✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: removing the empty --allowedTools argument that was breaking Claude Code ask mode.
Linked Issues check ✅ Passed The PR implements the fix for issue #45 by removing the empty --allowedTools flag from askModeArgs and updating related tests accordingly.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the ask-mode issue: modifying askModeArgs and updating corresponding test expectations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can disable poems in the walkthrough.

Disable the reviews.poem setting to disable the poems in the walkthrough.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/core/src/agent/__tests__/session.test.ts (1)

74-74: Add a direct assertion against empty string args.

Line 74 verifies the flag is gone, but the original failure mode also depended on an empty positional token. Add a guard for '' to make the regression test tighter.

Suggested test hardening
   expect(args).not.toContain('--allowedTools');
+  expect(args).not.toContain('');
   expect(args).toContain('--resume');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/agent/__tests__/session.test.ts` at line 74, The test
verifies the --allowedTools flag was removed but misses the regression where an
empty positional token ('') could remain; update the test in session.test.ts to
also assert that args does not contain the empty string by adding an assertion
against args (the variable used in the test) ensuring it does not include '' in
addition to the existing expect(args).not.toContain('--allowedTools').
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/core/src/agent/__tests__/session.test.ts`:
- Line 74: The test verifies the --allowedTools flag was removed but misses the
regression where an empty positional token ('') could remain; update the test in
session.test.ts to also assert that args does not contain the empty string by
adding an assertion against args (the variable used in the test) ensuring it
does not include '' in addition to the existing
expect(args).not.toContain('--allowedTools').

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 09e5b5bc-a8c1-46e7-b46f-7617f04ba3af

📥 Commits

Reviewing files that changed from the base of the PR and between 1c82bee and 629caca.

📒 Files selected for processing (3)
  • packages/core/src/agent/__tests__/session.test.ts
  • packages/core/src/agent/__tests__/tools.test.ts
  • packages/core/src/agent/tools.ts

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.

[Bug] /ask mode fails with Claude Code 2.1.80: --allowedTools "" causes prompt argument to be ignored

1 participant