EasyObservabilityPython 3

Command Log Classifier

Summarize command outcomes from an agent run while preserving safe review logs.

25m2 sample tests5 hidden tests

Implement classify_command_log(events), a helper that summarizes shell commands from an agent run.

Requirements

  • Each event is a dictionary with cmd, exit_code, stdout, and stderr.
  • Return a dictionary with status, total, failed, first_failure_cmd, and redacted_logs.
  • status is "passed" when no command failed, otherwise "failed".
  • A command fails when exit_code != 0.
  • first_failure_cmd is the first failing command, or None.
  • redacted_logs includes stdout and stderr lines with sk-... secrets replaced by [REDACTED].

Example

python
1events = [{"cmd": "pytest", "exit_code": 1, "stdout": "", "stderr": "failed"}] 2assert classify_command_log(events)["status"] == "failed"

Constraints

  • Preserve log line order.
  • Leave inputs untouched.

Editor