Cocos 执行结果给模型前恢复长度上限

- code 执行 32000 字符、operation 结果 2MiB

- 成功回执保留原文但按字符数收口
This commit is contained in:
2026-10-02 15:07:20 +08:00
parent 0ffa5bb1cc
commit b18b4935e4
@@ -3790,6 +3790,13 @@ fn cocos_execute_code(
cocos_execute_code_input(arguments)
}
/// Cocos code 执行结果的字符上限。
#[cfg(all(windows, feature = "cocos-editor-execute"))]
const DIRECT_TOOL_BRIDGE_COCOS_CODE_RESULT_MAX_CHARS: usize = 32_000;
/// Cocos operation 结果可能带预览载荷,给更大的上限。
#[cfg(all(windows, feature = "cocos-editor-execute"))]
const DIRECT_TOOL_BRIDGE_COCOS_OPERATION_RESULT_MAX_CHARS: usize = 2 * 1024 * 1024;
#[cfg(all(windows, feature = "cocos-editor-execute"))]
async fn bridge_cocos_execute(
state: &DirectToolBridgeState,
@@ -3887,7 +3894,17 @@ async fn bridge_cocos_call(
screenshots: images,
});
}
Ok(bridge_tool_result(report.to_string(), images))
Ok(bridge_tool_result(
crate::agent::redaction::truncate_agent_runtime_text(
&report.to_string(),
if operation.is_some() {
DIRECT_TOOL_BRIDGE_COCOS_OPERATION_RESULT_MAX_CHARS
} else {
DIRECT_TOOL_BRIDGE_COCOS_CODE_RESULT_MAX_CHARS
},
),
images,
))
}
failed => {
let (is_uncertain, error) = match failed {