Skip to content

feat: add --disable-subagents flag and CRABCODE_DISABLE_SUBAGENTS env - #61

Closed
Blankeos wants to merge 1 commit into
mainfrom
feat/disable-subagents
Closed

Blankeos wants to merge 1 commit into
mainfrom
feat/disable-subagents

Conversation

@Blankeos

@Blankeos Blankeos commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Fixes #55.

Behavior

  • crabcode --disable-subagents (global flag, also works as crabcode --disable-subagents -p "…", crabcode --disable-subagents acp|serve) or CRABCODE_DISABLE_SUBAGENTS=1 disables subagents everywhere (TUI, print, ACP, serve).
  • When disabled, the task tool is omitted from the registry (registry.get("task") is None), filtered from model-facing tools, and dropped from the <available_subagents> prompt block so the model never spends tokens attempting calls that would fail.
  • Any task call — including direct @agent mentions, which run through the same Task flow — is rejected with a permission error telling the user how to re-enable.

Usage

crabcode --disable-subagents
crabcode --disable-subagents -p "fix the failing test"
CRABCODE_DISABLE_SUBAGENTS=1 crabcode

Env truthy values: 1 | true | yes | y | on (case-insensitive, same convention as CRABCODE_DISABLE_CLAUDE_CODE). Flag and env are OR-ed; there is no re-enable override. Remote serve hosts enforce the host process environment.

Tests

  • tools::task: env truthy/falsy values, flag/env precedence, disabled TaskTool::execute rejects with Permission without running a subagent.
  • config::runtime: explicit disable_subagents: true hides task but keeps read; default keeps task visible.
  • tools::init: disabled env omits task from the dynamic registry while keeping question.
  • CLI parsing: flag defaults off, parses after positionals, and is global for subcommands.
  • Targeted: 37 passed. Full suite: 1685 passed, 1 failed — session::compaction::…prior_summary_billed_tokens… fails identically on clean main (verified via stash), so pre-existing and unrelated.

Module/interface design note

Single owning module (tools::task: DISABLE_SUBAGENTS_ENV, subagents_disabled(), resolve_subagents_disabled(flag)) behind a one-bool interface (--disable-subagents / env / ConfigRuntimeOptions.disable_subagents). main converges flag→env once at startup, so the four enforcement points (permission kill-switch, registry omission, prompt suppression, execute rejection) share one seam with no per-entrypoint threading; ConfigRuntime keeps an explicit bool for env-free tests. Docs in _docs/config/index.mdx.

Fixes #55. Hides the task tool (registry omission + model tool
filtering + prompt listing) and rejects task/@agent calls with a
permission error across TUI, print, ACP, and serve.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T19:03:20.007400Z 16ded02 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying crabcode with  Cloudflare Pages  Cloudflare Pages

Latest commit: 16ded02
Status: ✅  Deploy successful!
Preview URL: https://d2389b1f.crabcode.pages.dev
Branch Preview URL: https://feat-disable-subagents.crabcode.pages.dev

View logs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 16ded02ac6

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/tools/init.rs
// `CRABCODE_DISABLE_SUBAGENTS=1` early in `main`, so this single env
// check covers flag + env without threading a bool through every
// `register_dynamic_tools` call site (TUI, print, ACP, serve).
if !super::task::subagents_disabled() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Disable the VLM fallback hint alongside the task tool

When subagents are disabled and an image is sent to a text-only model with a configured vlm-agent, llm/client.rs:726-728 still sets show_vlm_agent_hint to true. The converted user message therefore commands the model to call task, while this branch omits that tool, and the normal unsupported-image warning is also suppressed. Include the disabled state when deciding whether to advertise the VLM fallback so these requests receive the warning instead of an impossible tool instruction.

Useful? React with 👍 / 👎.

Comment thread src/tools/init.rs
async fn disabled_env_omits_task_tool_from_dynamic_registry() {
let _lock = crate::tools::task::disable_subagents_env_lock();
let prev = std::env::var(crate::tools::task::DISABLE_SUBAGENTS_ENV).ok();
std::env::set_var(crate::tools::task::DISABLE_SUBAGENTS_ENV, "1");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid process-wide env mutation in parallel tests

Under the default parallel Rust test runner, this process-wide environment mutation is serialized only against tests that explicitly acquire disable_subagents_env_lock; existing tests such as tools::task::tests::task_requires_parent_session_scoped_llm_config do not acquire it, yet TaskTool::execute now reads this variable. If those tests overlap, the latter returns the new disabled permission error instead of its expected missing-session error, making the suite nondeterministically fail. Use injected state for this test or ensure every reader participates in the same synchronization.

Useful? React with 👍 / 👎.

@Blankeos

Blankeos commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

Closing as superseded: the requested automatic-subagent disabling behavior already exists through top-level permission.task: "deny" in crabcode.jsonc, matching OpenCode’s permissions interface. Verified on main with six temporary regression tests plus existing permission/config/tool suites; the same core support is present in v0.0.13 source. No additional flag/env mechanism is needed. Usage and manual @agent/per-agent override caveats posted on #55. No changes from this PR should be merged.

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.

Add flag or Env to disable subagent

1 participant