The activity_logging.py module#
Summary#
Return a logging-safe copy of |
|
Compact rendering of a tool’s return payload. |
|
Render an iterable as a compact comma-separated string. |
|
Public truncation helper for one-line stdout/stderr summaries. |
Description#
Helpers for compact, redaction-safe logging of tool calls and live session interactions.
Used by:
- Backend
run_codeimplementations: Logs the snippet that was sent to the live solver and the response it produced.
- Backend
An optional higher-level agent layer (when installed): Logs every tool invocation (name, sanitized arguments, latency, and brief result). This package exposes the helpers. It does not import that layer.
All records flow through Python’s logging module on dedicated child
loggers under the ansys.cfx.mcp namespace so they are captured by
the session log file installed by
ansys.cfx.mcp.common.session_logging without callers needing to
know that file exists.
Module detail#
- activity_logging.sanitize_args(args: Any, *, limit: int = _DEFAULT_VALUE_LIMIT) Any#
Return a logging-safe copy of
args.Redacts secret-looking keys.
Truncates string values longer than
limit.Recursively descends into dictionaries, lists, and tuples.
Other scalar types (int, float, bool, None) are returned as-is.
- Parameters:
- args
Any Positional arguments forwarded to the wrapped call.
- limit
int Maximum number of items or characters to include.
- args
- Returns:
AnyResult produced by the function.
- activity_logging.summarise_result(result: Any, *, limit: int = _DEFAULT_VALUE_LIMIT) Any#
Compact rendering of a tool’s return payload.
Tool handlers return a wide variety of dictionaries (some with large nested
state,snapshot, orpreviewblobs). Top-level keys are kept, but values are truncated aggressively so the log line stays under a few kilobytes. Non-dictionary returns are truncated.- Parameters:
- result
Any Result object to summarize for logging.
- limit
int Maximum number of items or characters to include.
- result
- Returns:
AnyResult produced by the function.
- activity_logging.format_iterable_inline(items: Iterable[Any], *, limit: int = 200) str#
Render an iterable as a compact comma-separated string.
- activity_logging.truncate_text(text: str, *, limit: int = _DEFAULT_TEXT_LIMIT) str#
Public truncation helper for one-line stdout/stderr summaries.
- activity_logging.TOOL_LOGGER#
- activity_logging.SESSION_LOGGER#