Skip to content

Commit 0ab2398

Browse files
committed
fix: fix for Gemini
1 parent fe91c10 commit 0ab2398

File tree

6 files changed

+65
-16
lines changed

6 files changed

+65
-16
lines changed

agents/anda_assistant/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "anda_assistant"
33
description = "Anda -- an AI Assistant powered by the Knowledge Interaction Protocol (KIP)."
44
repository = "https://github.com/ldclabs/anda/tree/main/agents/anda_assistant"
55
publish = true
6-
version = "0.4.3"
6+
version = "0.4.4"
77
edition.workspace = true
88
keywords.workspace = true
99
categories.workspace = true

anda_engine/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "anda_engine"
33
description = "Agents engine for Anda -- an AI agent framework built with Rust, powered by ICP and TEEs."
44
repository = "https://github.com/ldclabs/anda/tree/main/anda_engine"
55
publish = true
6-
version.workspace = true
6+
version = "0.9.6"
77
edition.workspace = true
88
keywords.workspace = true
99
categories.workspace = true

anda_engine/src/memory.rs

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use anda_db::{
1313
use anda_db_schema::{AndaDBSchema, FieldEntry, FieldType, Ft, Fv, Json, Schema, SchemaError};
1414
use anda_db_tfs::jieba_tokenizer;
1515
use anda_kip::{
16-
CommandType, DescribeTarget, KIP_FUNCTION_DEFINITION, KipError, META_SYSTEM_NAME, MetaCommand,
16+
CommandType, DescribeTarget, KipError, META_SYSTEM_NAME, MetaCommand,
1717
PERSON_TYPE, Request, Response,
1818
};
1919
use candid::Principal;
@@ -33,8 +33,37 @@ use crate::{
3333
rfc3339_datetime, rfc3339_datetime_now, unix_ms,
3434
};
3535

36-
pub static FUNCTION_DEFINITION: LazyLock<FunctionDefinition> =
37-
LazyLock::new(|| serde_json::from_value(KIP_FUNCTION_DEFINITION.clone()).unwrap());
36+
pub static FUNCTION_DEFINITION: LazyLock<FunctionDefinition> = LazyLock::new(|| {
37+
serde_json::from_value(json!({
38+
"name": "execute_kip",
39+
"description": "Executes one or more KIP (Knowledge Interaction Protocol) commands against the Cognitive Nexus to interact with your persistent memory.",
40+
"parameters": {
41+
"type": "object",
42+
"properties": {
43+
"command": {
44+
"type": "string",
45+
"description": "A complete, multi-line KIP command (KQL, KML or META) string to be executed. Mutually exclusive with 'commands'."
46+
},
47+
"commands": {
48+
"type": "array",
49+
"description": "An array of KIP commands for batch execution (reduces round-trips). Mutually exclusive with 'command'. Each element can be a string (uses shared 'parameters') or an object with 'command' and optional 'parameters' (overrides shared parameters). Commands are executed sequentially; execution stops on first error.",
50+
"items": {
51+
"type": "string"
52+
}
53+
},
54+
"parameters": {
55+
"type": "object",
56+
"description": "An optional JSON object of key-value pairs used for safe substitution of placeholders in the command string(s). Placeholders should start with ':' (e.g., :name, :limit). IMPORTANT: A placeholder must represent a complete JSON value token (e.g., name: :name). Do not embed placeholders inside quoted strings (e.g., \"Hello :name\"), because substitution uses JSON serialization."
57+
},
58+
"dry_run": {
59+
"type": "boolean",
60+
"description": "If set to true, the command(s) will only be validated for syntactical and logical correctness without being executed.",
61+
"default": false
62+
}
63+
}
64+
}
65+
})).unwrap()
66+
});
3867

3968
#[derive(Debug, Clone, Deserialize, Serialize, AndaDBSchema)]
4069
pub struct Conversation {
@@ -665,7 +694,7 @@ impl Tool<BaseCtx> for GetResourceContentTool {
665694
name: self.name(),
666695
description: self.description(),
667696
parameters: self.schema.clone(),
668-
strict: Some(true),
697+
strict: None,
669698
}
670699
}
671700

@@ -733,7 +762,7 @@ impl Tool<BaseCtx> for ListConversationsTool {
733762
name: self.name(),
734763
description: self.description(),
735764
parameters: self.schema.clone(),
736-
strict: Some(true),
765+
strict: None,
737766
}
738767
}
739768

@@ -804,7 +833,7 @@ impl Tool<BaseCtx> for SearchConversationsTool {
804833
name: self.name(),
805834
description: self.description(),
806835
parameters: self.schema.clone(),
807-
strict: Some(true),
836+
strict: None,
808837
}
809838
}
810839

@@ -910,7 +939,7 @@ impl Tool<BaseCtx> for MemoryTool {
910939
name: self.name(),
911940
description: self.description(),
912941
parameters: self.schema.clone(),
913-
strict: Some(true),
942+
strict: None,
914943
}
915944
}
916945

anda_engine/src/model/gemini/types.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl From<ContentPart> for Part {
238238
}
239239

240240
impl From<Part> for ContentPart {
241-
fn from(value: Part) -> Self {
241+
fn from(mut value: Part) -> Self {
242242
match value.data {
243243
PartKind::Text(text) if value.thought == Some(true) => ContentPart::Reasoning { text },
244244
PartKind::Text(text) => ContentPart::Text { text },
@@ -270,7 +270,10 @@ impl From<Part> for ContentPart {
270270
call_id: id,
271271
remote_id: None,
272272
},
273-
_ => ContentPart::Any(json!(value.data)),
273+
_ => {
274+
value.thought_signature = None;
275+
ContentPart::Any(json!(value.data))
276+
}
274277
}
275278
}
276279
}
@@ -308,7 +311,7 @@ pub enum PartKind {
308311
#[serde(skip_serializing_if = "Option::is_none")]
309312
scheduling: Option<String>,
310313
#[serde(skip_serializing_if = "Option::is_none")]
311-
parts: Option<Vec<Part>>,
314+
parts: Option<Vec<Value>>,
312315
},
313316
InlineData {
314317
mime_type: String,
@@ -634,12 +637,15 @@ pub enum BlockReason {
634637
#[derive(Debug, Serialize, Deserialize, Clone)]
635638
#[serde(rename_all = "camelCase")]
636639
pub struct UsageMetadata {
640+
#[serde(default)]
637641
pub prompt_token_count: u32,
638642

639-
pub candidates_token_count: u32,
640-
643+
#[serde(default)]
641644
pub total_token_count: u32,
642645

646+
#[serde(default)]
647+
pub candidates_token_count: u32,
648+
643649
#[serde(default)]
644650
pub thoughts_token_count: u32,
645651
}
@@ -654,6 +660,20 @@ pub struct ThinkingConfig {
654660
/// The number of thoughts tokens that the model should generate.
655661
#[serde(skip_serializing_if = "Option::is_none")]
656662
pub thinking_budget: Option<u32>,
663+
/// Controls the maximum depth of the model's internal reasoning process before it produces a response. If not specified, the default is HIGH. Recommended for Gemini 3 or later models. Use with earlier models results in an error.
664+
#[serde(skip_serializing_if = "Option::is_none")]
665+
pub thinking_level: Option<ThinkingLevel>,
666+
}
667+
668+
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq)]
669+
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
670+
pub enum ThinkingLevel {
671+
#[default]
672+
ThinkingLevelUnspecified,
673+
Minimal,
674+
Low,
675+
Medium,
676+
High,
657677
}
658678

659679
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq)]

anda_engine_server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "anda_engine_server"
33
description = "A http server to serve multiple Anda engines."
44
repository = "https://github.com/ldclabs/anda/tree/main/anda_engine_server"
55
publish = true
6-
version = "0.9.5"
6+
version = "0.9.6"
77
edition.workspace = true
88
keywords.workspace = true
99
categories.workspace = true

anda_web3_client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "anda_web3_client"
33
description = "The Rust SDK for Web3 integration in non-TEE environments."
44
repository = "https://github.com/ldclabs/anda/tree/main/anda_web3_client"
55
publish = true
6-
version.workspace = true
6+
version = "0.9.6"
77
edition.workspace = true
88
keywords.workspace = true
99
categories.workspace = true

0 commit comments

Comments
 (0)