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. |
|
Use the 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:
ansys.fluent.mcp.solve.backends.pyfluent.PyFluentBackend.run_code()to log the snippet that was sent to the live solver and the response it produced.An optional higher-level agent layer (when installed) to log every tool invocation (name, sanitized arguments, latency, 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.fluent.mcp namespace so they are captured by
the session log file installed by
ansys.fluent.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). This handler keeps the top-level keys but truncates values aggressively so the log line stays under a few KB. For non-dictionary returns, the handler truncates.- 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#
Use the public truncation helper for one-line stdout/stderr summaries.
- activity_logging.TOOL_LOGGER#
- activity_logging.SESSION_LOGGER#