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, andstderr. - Return a dictionary with
status,total,failed,first_failure_cmd, andredacted_logs. statusis"passed"when no command failed, otherwise"failed".- A command fails when
exit_code != 0. first_failure_cmdis the first failing command, orNone.redacted_logsincludes stdout and stderr lines withsk-...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