refactor: improve error handling in global context info function

Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-03 17:01:47 +00:00
parent b8eb110cf4
commit eb667d310c
+10 -8
View File
@@ -845,14 +845,16 @@ def _apply_global_context_info(event: AstrMessageEvent, req: ProviderRequest) ->
# Parse the original UMO to extract platform, message type, and session info
try:
parts = original_umo.split(":", 2)
if len(parts) == 3:
platform_id, message_type, session_id = parts
context_info = f"[Context: Platform={platform_id}, Type={message_type}, Session={session_id}]"
# Prepend context info to the user prompt
if req.prompt:
req.prompt = f"{context_info} {req.prompt}"
else:
req.prompt = context_info
if len(parts) != 3:
logger.warning(
f"Original UMO format is invalid (expected 3 parts): {original_umo}"
)
return
platform_id, message_type, session_id = parts
context_info = f"[Context: Platform={platform_id}, Type={message_type}, Session={session_id}]"
# Prepend context info to the user prompt
req.prompt = f"{context_info} {req.prompt or ''}"
except Exception as e:
logger.warning(f"Failed to parse original UMO for global context: {e}")