更新梦境策略
curl --request PATCH \
--url https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"activity": {
"enabled": true,
"min_changed_sessions": 3
},
"schedule": {
"enabled": false
}
}
'import requests
url = "https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy"
payload = {
"activity": {
"enabled": True,
"min_changed_sessions": 3
},
"schedule": { "enabled": False }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({activity: {enabled: true, min_changed_sessions: 3}, schedule: {enabled: false}})
};
fetch('https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'activity' => [
'enabled' => true,
'min_changed_sessions' => 3
],
'schedule' => [
'enabled' => false
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy"
payload := strings.NewReader("{\n \"activity\": {\n \"enabled\": true,\n \"min_changed_sessions\": 3\n },\n \"schedule\": {\n \"enabled\": false\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"activity\": {\n \"enabled\": true,\n \"min_changed_sessions\": 3\n },\n \"schedule\": {\n \"enabled\": false\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"activity\": {\n \"enabled\": true,\n \"min_changed_sessions\": 3\n },\n \"schedule\": {\n \"enabled\": false\n }\n}"
response = http.request(request)
puts response.read_body{
"memory_store_id": "mstr_01h455vb4pex5vsknk084sn02q",
"agent_id": "agent_01h455vb4pex5vsknk084sn02q",
"activity": {
"enabled": true,
"min_changed_sessions": 3
},
"schedule": {
"enabled": false
},
"trigger_id": "trig_01h455vb4pex5vsknk084sn02q",
"environment_id": "env_01h455vb4pex5vsknk084sn02q",
"updated_at": "2026-01-02T00:00:00.000Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}整体替换单个记忆库的梦境策略。
- 请求体是对两个条件的整体替换而非合并。即使禁用,
activity和schedule也必填。 - 任一条件启用时
environment_id必填,且环境必须处于活跃状态。启用条件还要求调用方携带模型 API key,否则返回 401。 - 每次更新记录一个不可变的策略版本,并创建或更新策略持有的触发器。定时条件禁用期间触发器保持暂停。
- 已归档的记忆库只接受禁用两个条件的更新。
PATCH
/
v1
/
memory-stores
/
{memory_store_id}
/
dream-policy
更新梦境策略
curl --request PATCH \
--url https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"activity": {
"enabled": true,
"min_changed_sessions": 3
},
"schedule": {
"enabled": false
}
}
'import requests
url = "https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy"
payload = {
"activity": {
"enabled": True,
"min_changed_sessions": 3
},
"schedule": { "enabled": False }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({activity: {enabled: true, min_changed_sessions: 3}, schedule: {enabled: false}})
};
fetch('https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'activity' => [
'enabled' => true,
'min_changed_sessions' => 3
],
'schedule' => [
'enabled' => false
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy"
payload := strings.NewReader("{\n \"activity\": {\n \"enabled\": true,\n \"min_changed_sessions\": 3\n },\n \"schedule\": {\n \"enabled\": false\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"activity\": {\n \"enabled\": true,\n \"min_changed_sessions\": 3\n },\n \"schedule\": {\n \"enabled\": false\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/memory-stores/{memory_store_id}/dream-policy")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"activity\": {\n \"enabled\": true,\n \"min_changed_sessions\": 3\n },\n \"schedule\": {\n \"enabled\": false\n }\n}"
response = http.request(request)
puts response.read_body{
"memory_store_id": "mstr_01h455vb4pex5vsknk084sn02q",
"agent_id": "agent_01h455vb4pex5vsknk084sn02q",
"activity": {
"enabled": true,
"min_changed_sessions": 3
},
"schedule": {
"enabled": false
},
"trigger_id": "trig_01h455vb4pex5vsknk084sn02q",
"environment_id": "env_01h455vb4pex5vsknk084sn02q",
"updated_at": "2026-01-02T00:00:00.000Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}路径参数
记忆库 ID。
Pattern:
^mstr_[0-9a-hjkmnp-tv-z]{26}$请求体
application/json
用于整体替换某个记忆库的梦境设置。两个触发器都会整体替换。两者都禁用时,策略处于非活跃状态。
活动条件。即使未启用,该对象也必填。
Show child attributes
Show child attributes
调度条件。即使未启用,该对象也必填。
Show child attributes
Show child attributes
自动梦境使用的智能体。留空则选择平台官方梦境智能体。
Maximum string length:
128Pattern:
^agent_[0-9a-hjkmnp-tv-z]{26}$承载梦境会话的环境。任一条件启用时必填。
Maximum string length:
128Pattern:
^env_[0-9a-hjkmnp-tv-z]{26}$响应
替换后的策略,携带解析后的 agent_id、trigger_id 与 updated_at。
单个记忆库的梦境设置。
活动条件和定时条件分别判断,任一满足即触发。每次触发都会新建一个以读写方式挂载该记忆库的会话,并在策略持有的触发器下记录为一次触发器运行。
受此策略控制的记忆库。
Pattern:
^mstr_[0-9a-hjkmnp-tv-z]{26}$活动条件。始终存在,包括禁用时。
Show child attributes
Show child attributes
定时条件。始终存在,包括禁用时。
Show child attributes
Show child attributes
运行梦境会话的智能体。缺省表示使用平台默认梦境智能体。
Pattern:
^agent_[0-9a-hjkmnp-tv-z]{26}$此策略持有的触发器。未配置策略时缺省。
Pattern:
^trig_[0-9a-hjkmnp-tv-z]{26}$承载梦境会话的环境。未配置策略时缺省。
Pattern:
^env_[0-9a-hjkmnp-tv-z]{26}$策略上次更新的时间。未配置策略时缺省。
此页面对您有帮助吗?