未登记的客户端工具名在构造处截到 120 字符

- dispatch 兜底分支构造 UnknownClientToolRejection 时改用 bounded_echo,客户端给的超长工具名不再原样进 to_user_msg 与序列化诊断
- 该名字在构造处就有界,后续 clone/序列化都受同一上限约束

验证:cargo check --bin genarrative-ai-game-creator-shell --tests 通过;cargo fmt --check 通过
This commit is contained in:
2026-10-01 17:51:44 +08:00
parent 7d51504e09
commit 6a4efa15ee
2 changed files with 3 additions and 2 deletions
@@ -17,7 +17,7 @@ use crate::agent::tool::edit_image::error::EditImageError;
use crate::agent::tool::editor_execute::error::{EditorExecuteError, EditorKind};
use crate::agent::tool::environment_check::error::EnvironmentCheckError;
use crate::agent::tool::error::{
DirectExecutionGateRejection, DirectTurnGateRejection, ProjectManifestRejection,
bounded_echo, DirectExecutionGateRejection, DirectTurnGateRejection, ProjectManifestRejection,
ResourceCompletionRejection, ToolArgumentsRejection, ToolFailure, UnknownClientToolRejection,
};
use crate::agent::tool::generate_image::error::GenerateImageError;
@@ -4116,7 +4116,7 @@ async fn handle_direct_tool_bridge(
)),
_ => Err(ToolCallError::from(
&UnknownClientToolRejection {
tool: request.tool.clone(),
tool: bounded_echo(&request.tool),
},
)),
}
@@ -201,6 +201,7 @@ impl ToolFailure for DirectTurnGateRejection {
/// 客户端工具桥收到没有登记过的工具名。
///
/// 带上收到的名字:模型拼错工具名时要能从错误里看出自己写了什么,而不是只知道"不认识"。
/// 名字在构造处就截到 [`BOUNDED_ECHO_MAX_CHARS`],序列化后的诊断不会跟着被撑大。
#[derive(serde::Serialize, Debug)]
pub(crate) struct UnknownClientToolRejection {
pub(crate) tool: String,