File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -428,6 +428,20 @@ function isReflectionMetadataType(type: unknown): boolean {
428428
429429function isOwnedByAgent ( metadata : Record < string , unknown > , agentId : string ) : boolean {
430430 const owner = typeof metadata . agentId === "string" ? metadata . agentId . trim ( ) : "" ;
431+
432+ // itemKind 只存在於 memory-reflection-item 類型
433+ // legacy (memory-reflection) 和 mapped (memory-reflection-mapped) 都沒有 itemKind
434+ // 因此 undefined !== "derived",會走原本的 main fallback(維持相容)
435+ const itemKind = metadata . itemKind ;
436+
437+ // 如果是 derived 項目(memory-reflection-item):不做 main fallback,
438+ // 且 derived 不允許空白 owner(空白 owner 的 derived 應完全不可見,防止洩漏)
439+ if ( itemKind === "derived" ) {
440+ if ( ! owner ) return false ;
441+ return owner === agentId ;
442+ }
443+
444+ // invariant / legacy / mapped:允許空白 owner 可見,維持原本的 main fallback
431445 if ( ! owner ) return true ;
432446 return owner === agentId || owner === "main" ;
433447}
You can’t perform that action at this time.
0 commit comments