Skip to content

Commit 1606bef

Browse files
committed
fix: only attempt xml deserialization if native tools format is not supported or disabled
1 parent f6e8884 commit 1606bef

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

nerve-core/src/agent/generator/groq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl Client for GroqClient {
170170

171171
let mut request = builder::RequestBuilder::new(self.model.clone()).with_stream(false);
172172

173-
if state.lock().await.native_tools_support {
173+
if state.lock().await.use_native_tools_format {
174174
let mut tools = vec![];
175175

176176
for group in state.lock().await.get_namespaces() {

nerve-core/src/agent/generator/ollama.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl Client for OllamaClient {
117117
// Generate tools vector.
118118
let mut tools = vec![];
119119

120-
if state.lock().await.native_tools_support {
120+
if state.lock().await.use_native_tools_format {
121121
for group in state.lock().await.get_namespaces() {
122122
for action in &group.actions {
123123
let mut required = vec![];

nerve-core/src/agent/generator/openai.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl OpenAIClient {
5959
let mut tools = vec![];
6060

6161
// if native tool calls are supported (and XML was not forced)
62-
if state.lock().await.native_tools_support {
62+
if state.lock().await.use_native_tools_format {
6363
// for every namespace available to the model
6464
for group in state.lock().await.get_namespaces() {
6565
// for every action of the namespace

nerve-core/src/agent/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ pub struct Agent {
104104
task_timeout: Option<Duration>,
105105

106106
serializer: serialization::Strategy,
107-
force_strategy: bool,
107+
use_native_tools_format: bool,
108108
}
109109

110110
impl Agent {
@@ -117,7 +117,7 @@ impl Agent {
117117
force_strategy: bool,
118118
max_iterations: usize,
119119
) -> Result<Self> {
120-
let use_native_tools_support = if force_strategy {
120+
let use_native_tools_format = if force_strategy {
121121
log::info!("using {:?} serialization strategy", &serializer);
122122
false
123123
} else {
@@ -142,7 +142,7 @@ impl Agent {
142142
task,
143143
embedder,
144144
max_iterations,
145-
use_native_tools_support,
145+
use_native_tools_format,
146146
)
147147
.await?,
148148
));
@@ -153,7 +153,7 @@ impl Agent {
153153
state,
154154
max_history,
155155
task_timeout,
156-
force_strategy,
156+
use_native_tools_format,
157157
serializer,
158158
})
159159
}
@@ -372,7 +372,7 @@ impl Agent {
372372
let (response, tool_calls) = self.generator.chat(self.state.clone(), &options).await?;
373373

374374
// parse the model response into invocations
375-
let invocations = if tool_calls.is_empty() || self.force_strategy {
375+
let invocations = if !self.use_native_tools_format {
376376
// use our own parsing strategy
377377
self.serializer.try_parse(response.trim())?
378378
} else {

nerve-core/src/agent/serialization/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Strategy {
9797
let storages = storages.join("\n\n");
9898
let guidance = task.guidance()?;
9999

100-
let available_actions = if state.native_tools_support {
100+
let available_actions = if state.use_native_tools_format {
101101
// model supports tool calls, no need to add actions to the system prompt
102102
"".to_string()
103103
} else {

nerve-core/src/agent/state/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct State {
4040
// runtime metrics
4141
pub metrics: Metrics,
4242
// model support stool
43-
pub native_tools_support: bool,
43+
pub use_native_tools_format: bool,
4444
}
4545

4646
pub type SharedState = Arc<tokio::sync::Mutex<State>>;
@@ -51,7 +51,7 @@ impl State {
5151
task: Box<dyn Task>,
5252
embedder: Box<dyn mini_rag::Embedder>,
5353
max_iterations: usize,
54-
native_tools_support: bool,
54+
use_native_tools_format: bool,
5555
) -> Result<Self> {
5656
let complete = false;
5757
let mut variables = HashMap::new();
@@ -169,7 +169,7 @@ impl State {
169169
metrics,
170170
rag,
171171
events_tx,
172-
native_tools_support,
172+
use_native_tools_format,
173173
})
174174
}
175175

0 commit comments

Comments
 (0)