Skip to content

fix: add missing cfg guard for code-mode feature in reply_parts.rs#8127

Closed
soilSpoon wants to merge 1 commit into
aaif-goose:mainfrom
soilSpoon:fix/code-mode-cfg-guard
Closed

fix: add missing cfg guard for code-mode feature in reply_parts.rs#8127
soilSpoon wants to merge 1 commit into
aaif-goose:mainfrom
soilSpoon:fix/code-mode-cfg-guard

Conversation

@soilSpoon
Copy link
Copy Markdown
Contributor

Summary

The if code_execution_active { ... } block in reply_parts.rs references code_execution::get_tool_disclosure() and pctx_code_mode::config::ToolDisclosure variants without a #[cfg(feature = "code-mode")] guard. When code-mode is disabled, the code_execution module and pctx_code_mode crate are not available, causing 4 compilation errors.

The existing guards correctly set code_execution_active = false when the feature is off, but the compiler still needs to resolve the types inside the if-block at compile time. Adding the cfg attribute to the if-block itself ensures the entire block is excluded from compilation when code-mode is disabled.

Follows the same pattern established in #7976 (local-inference feature gate) and #8080 (aws-providers feature gate).

Changes:

  • crates/goose/src/agents/reply_parts.rs — Add #[cfg(feature = "code-mode")] to the if code_execution_active block (1 line addition)

Testing

  • cargo check -p goose --no-default-features --features rustls-tls — now succeeds (previously failed with 4 errors)
  • cargo check -p goose — compiles with all defaults (no behavior change)

Related Issues

N/A

Screenshots/Demos (for UX changes)

N/A (backend-only change, no UI impact)

The `if code_execution_active` block references `code_execution::get_tool_disclosure()`
and `pctx_code_mode::config::ToolDisclosure` variants without a `#[cfg(feature = "code-mode")]`
guard. When `code-mode` is disabled, the `code_execution` module and `pctx_code_mode` crate
are not available, causing compilation to fail with 4 errors.

The existing guards correctly set `code_execution_active = false` when the feature is off,
but the compiler still needs to resolve the types inside the if-block. Adding the cfg attribute
to the if-block itself ensures the entire block is excluded from compilation when code-mode
is disabled.

Verified: `cargo check -p goose --no-default-features --features rustls-tls` now succeeds.
Signed-off-by: DaeHee Lee <lee111dae11@proton.me>
@soilSpoon soilSpoon force-pushed the fix/code-mode-cfg-guard branch from f72d7de to 2571b89 Compare March 26, 2026 01:53
Copy link
Copy Markdown
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

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

LGTM — the guard on the block is the correct fix. The unguarded block causes type-checking errors on types even when the feature is disabled.

@DOsinga DOsinga added this pull request to the merge queue Mar 26, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Mar 26, 2026
@r0x0d
Copy link
Copy Markdown
Contributor

r0x0d commented Mar 26, 2026

#8111 same fix was merged before, I think its fine to close this

@DOsinga
Copy link
Copy Markdown
Collaborator

DOsinga commented Mar 26, 2026

thanks @r0x0d - so many incoming. And thanks @soilSpoon for helping out!

@DOsinga DOsinga closed this Mar 26, 2026
@soilSpoon soilSpoon deleted the fix/code-mode-cfg-guard branch March 27, 2026 00:51
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.

3 participants