@@ -22,15 +22,29 @@ def read_console(
2222 "Get messages after this timestamp (ISO 8601)" ] | None = None ,
2323 format : Annotated [Literal ['plain' , 'detailed' ,
2424 'json' ], "Output format" ] | None = None ,
25- include_stacktrace : Annotated [bool ,
26- "Include stack traces in output" ] | None = None
25+ include_stacktrace : Annotated [bool | str ,
26+ "Include stack traces in output (accepts true/false or 'true'/'false') " ] | None = None
2727) -> dict [str , Any ]:
2828 ctx .info (f"Processing read_console: { action } " )
2929 # Set defaults if values are None
3030 action = action if action is not None else 'get'
3131 types = types if types is not None else ['error' , 'warning' , 'log' ]
3232 format = format if format is not None else 'detailed'
33- include_stacktrace = include_stacktrace if include_stacktrace is not None else True
33+ # Coerce booleans defensively (strings like 'true'/'false')
34+ def _coerce_bool (value , default = None ):
35+ if value is None :
36+ return default
37+ if isinstance (value , bool ):
38+ return value
39+ if isinstance (value , str ):
40+ v = value .strip ().lower ()
41+ if v in ("true" , "1" , "yes" , "on" ):
42+ return True
43+ if v in ("false" , "0" , "no" , "off" ):
44+ return False
45+ return bool (value )
46+
47+ include_stacktrace = _coerce_bool (include_stacktrace , True )
3448
3549 # Normalize action if it's a string
3650 if isinstance (action , str ):
0 commit comments