feat: make pctx/Code Mode an optional dependency via 'code-mode' feature (#7567)

This commit is contained in:
jh-block
2026-02-27 16:51:13 +01:00
committed by GitHub
parent e37ac4a517
commit 69ad519373
6 changed files with 21 additions and 7 deletions
+3 -2
View File
@@ -8,7 +8,8 @@ repository.workspace = true
description.workspace = true
[features]
default = []
default = ["code-mode"]
code-mode = ["dep:pctx_code_mode"]
cuda = ["candle-core/cuda", "candle-nn/cuda", "llama-cpp-2/cuda"]
[lints]
@@ -123,7 +124,7 @@ shellexpand = { workspace = true }
indexmap = "2.12.0"
ignore = { workspace = true }
which = { workspace = true }
pctx_code_mode = "^0.2.3"
pctx_code_mode = { version = "^0.2.3", optional = true }
unbinder = "0.1.7"
pulldown-cmark = "0.13.0"
llama-cpp-2 = { git = "https://github.com/jh-block/llama-cpp-rs.git", branch = "goose-patches", features = ["sampler"] }
@@ -1,5 +1,6 @@
pub mod apps;
pub mod chatrecall;
#[cfg(feature = "code-mode")]
pub mod code_execution;
pub mod developer;
pub mod ext_manager;
@@ -88,6 +89,7 @@ pub static PLATFORM_EXTENSIONS: Lazy<HashMap<&'static str, PlatformExtensionDef>
},
);
#[cfg(feature = "code-mode")]
map.insert(
code_execution::EXTENSION_NAME,
PlatformExtensionDef {
+4
View File
@@ -8,6 +8,7 @@ use serde_json::{json, Value};
use tracing::debug;
use super::super::agents::Agent;
#[cfg(feature = "code-mode")]
use crate::agents::platform_extensions::code_execution;
use crate::conversation::message::{Message, MessageContent, ToolRequest};
use crate::conversation::Conversation;
@@ -146,10 +147,13 @@ impl Agent {
tools.push(frontend_tool.tool.clone());
}
#[cfg(feature = "code-mode")]
let code_execution_active = self
.extension_manager
.is_extension_enabled(code_execution::EXTENSION_NAME)
.await;
#[cfg(not(feature = "code-mode"))]
let code_execution_active = false;
if code_execution_active {
tools.retain(|tool| {
if let Some(owner) = crate::agents::extension_manager::get_tool_owner(tool) {