anveesa 0.3.9 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Cargo.lock CHANGED
@@ -60,7 +60,7 @@ dependencies = [
60
60
 
61
61
  [[package]]
62
62
  name = "anveesa"
63
- version = "0.3.9"
63
+ version = "0.4.1"
64
64
  dependencies = [
65
65
  "anyhow",
66
66
  "base64",
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "anveesa"
3
- version = "0.3.9"
3
+ version = "0.4.1"
4
4
  edition = "2024"
5
5
  default-run = "anveesa"
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anveesa",
3
- "version": "0.3.9",
3
+ "version": "0.4.1",
4
4
  "description": "A terminal CLI that wraps AI providers (OpenAI-compatible APIs and local CLIs) into a single unified command",
5
5
  "main": "bin/anveesa.js",
6
6
  "bin": {
@@ -485,24 +485,24 @@ fn parse_tool_round_limit(value: Option<&str>) -> usize {
485
485
 
486
486
  fn tool_limit_message(max_tool_rounds: usize) -> Value {
487
487
  json!({
488
- "role": "system",
488
+ "role": "user",
489
489
  "content": format!(
490
- "Anveesa has already run {max_tool_rounds} tool rounds for this answer. Do not call tools again. Use the tool results already provided to produce the best final answer. If the requested work is not complete, say exactly what remains."
490
+ "[system: Anveesa has already run {max_tool_rounds} tool rounds for this answer. Do not call tools again. Use the tool results already provided to produce the best final answer. If the requested work is not complete, say exactly what remains.]"
491
491
  )
492
492
  })
493
493
  }
494
494
 
495
495
  fn length_continuation_message() -> Value {
496
496
  json!({
497
- "role": "system",
498
- "content": "Your previous response was cut off because it reached the output token limit. Continue from exactly where you left off. Do not repeat text you already produced and do not restart the answer. If you were in the middle of a tool call, re-issue that complete tool call now."
497
+ "role": "user",
498
+ "content": "[system: Your previous response was cut off because it reached the output token limit. Continue from exactly where you left off. Do not repeat text you already produced and do not restart the answer. If you were in the middle of a tool call, re-issue that complete tool call now.]"
499
499
  })
500
500
  }
501
501
 
502
502
  fn tool_intent_reprompt_message() -> Value {
503
503
  json!({
504
- "role": "system",
505
- "content": "Your previous message said you would inspect/read/check the workspace, but it did not call any tool or provide a final answer. Do not narrate future tool use. If you need information, call the relevant Anveesa tools now. Otherwise, answer the user directly."
504
+ "role": "user",
505
+ "content": "[system: Your previous message said you would inspect/read/check the workspace, but it did not call any tool or provide a final answer. Do not narrate future tool use. If you need information, call the relevant Anveesa tools now. Otherwise, answer the user directly.]"
506
506
  })
507
507
  }
508
508
 
@@ -686,14 +686,23 @@ fn build_messages(
686
686
  prompt_cache: bool,
687
687
  ) -> Vec<Value> {
688
688
  let mut messages = Vec::new();
689
- if let Some(system) = &request.system {
690
- messages.push(json!({ "role": "system", "content": system }));
691
- }
692
- if let Some(workspace_context) = &request.workspace_context {
693
- messages.push(json!({ "role": "system", "content": workspace_context }));
694
- }
695
- messages
696
- .push(json!({ "role": "system", "content": tools::guidance(policy.allows_write_tools()) }));
689
+
690
+ // Merge all system-level content into a single system message.
691
+ // Many providers (Qwen3, etc.) only allow one system message and require
692
+ // it to be the very first message — multiple system messages cause HTTP 400.
693
+ let guidance = tools::guidance(policy.allows_write_tools());
694
+ let system_content = [
695
+ request.system.as_deref(),
696
+ request.workspace_context.as_deref(),
697
+ Some(guidance.as_str()),
698
+ ]
699
+ .into_iter()
700
+ .flatten()
701
+ .collect::<Vec<_>>()
702
+ .join("\n\n");
703
+
704
+ messages.push(json!({ "role": "system", "content": system_content }));
705
+
697
706
  for message in &request.history {
698
707
  let role = match message.role {
699
708
  ChatRole::User => "user",
@@ -1136,7 +1145,7 @@ mod tests {
1136
1145
  #[test]
1137
1146
  fn length_continuation_message_asks_to_resume_without_repeating() {
1138
1147
  let message = length_continuation_message();
1139
- assert_eq!(message["role"], json!("system"));
1148
+ assert_eq!(message["role"], json!("user"));
1140
1149
  let content = message["content"].as_str().unwrap();
1141
1150
  assert!(content.contains("cut off"));
1142
1151
  assert!(content.contains("Do not repeat"));
@@ -1193,7 +1202,7 @@ mod tests {
1193
1202
  #[test]
1194
1203
  fn tool_limit_message_forces_final_answer() {
1195
1204
  let message = tool_limit_message(3);
1196
- assert_eq!(message["role"], json!("system"));
1205
+ assert_eq!(message["role"], json!("user"));
1197
1206
  assert!(
1198
1207
  message["content"]
1199
1208
  .as_str()