File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -832,13 +832,16 @@ def _get_compress_provider(
832832
833833def _apply_global_context_info (event : AstrMessageEvent , req : ProviderRequest ) -> None :
834834 """Add platform and session information to user prompt when in global unified context mode."""
835- from astrbot .core .config .default import GLOBAL_UNIFIED_CONTEXT_UMO
835+ from astrbot .core .config .default import (
836+ GLOBAL_UNIFIED_CONTEXT_UMO ,
837+ ORIGINAL_UMO_KEY ,
838+ )
836839
837840 if event .unified_msg_origin != GLOBAL_UNIFIED_CONTEXT_UMO :
838841 return
839842
840843 # Get original UMO from extras
841- original_umo = event .get_extra ("original_umo" )
844+ original_umo = event .get_extra (ORIGINAL_UMO_KEY )
842845 if not original_umo :
843846 return
844847
Original file line number Diff line number Diff line change @@ -258,7 +258,9 @@ async def call(
258258 self , context : ContextWrapper [AstrAgentContext ], ** kwargs
259259 ) -> ToolExecResult :
260260 # In global context mode, default to original UMO if session not specified
261- original_umo = context .context .event .get_extra ("original_umo" )
261+ from astrbot .core .config .default import ORIGINAL_UMO_KEY
262+
263+ original_umo = context .context .event .get_extra (ORIGINAL_UMO_KEY )
262264 default_session = original_umo or context .context .event .unified_msg_origin
263265 session = kwargs .get ("session" ) or default_session
264266 messages = kwargs .get ("messages" )
Original file line number Diff line number Diff line change 1919
2020# Constant UMO for global unified context mode
2121GLOBAL_UNIFIED_CONTEXT_UMO = "global::global"
22+ # Key for storing original UMO in event extras when global context mode is enabled
23+ ORIGINAL_UMO_KEY = "original_umo"
2224
2325# 默认配置
2426DEFAULT_CONFIG = {
Original file line number Diff line number Diff line change @@ -170,7 +170,9 @@ async def process(
170170 )
171171
172172 # Restore original UMO before sending if in global context mode
173- original_umo = event .get_extra ("original_umo" )
173+ from astrbot .core .config .default import ORIGINAL_UMO_KEY
174+
175+ original_umo = event .get_extra (ORIGINAL_UMO_KEY )
174176 if original_umo :
175177 logger .debug (
176178 f"Restoring original UMO before sending: { event .unified_msg_origin } -> { original_umo } "
Original file line number Diff line number Diff line change @@ -82,12 +82,15 @@ async def process(
8282 ) -> None | AsyncGenerator [None , None ]:
8383 # apply global unified context mode
8484 if self .global_unified_context_mode :
85- from astrbot .core .config .default import GLOBAL_UNIFIED_CONTEXT_UMO
85+ from astrbot .core .config .default import (
86+ GLOBAL_UNIFIED_CONTEXT_UMO ,
87+ ORIGINAL_UMO_KEY ,
88+ )
8689
8790 original_umo = event .unified_msg_origin
8891 event .unified_msg_origin = GLOBAL_UNIFIED_CONTEXT_UMO
8992 # Store original UMO for reference in later stages
90- event .set_extra ("original_umo" , original_umo )
93+ event .set_extra (ORIGINAL_UMO_KEY , original_umo )
9194 logger .debug (
9295 f"Global unified context mode enabled. Changed UMO from { original_umo } to { GLOBAL_UNIFIED_CONTEXT_UMO } "
9396 )
You can’t perform that action at this time.
0 commit comments