Skip to content

[BUG] Executor truncates output to 3000 chars and fails on non-UTF-8 bytes, losing evidence #206

Done

Description

@OkiriGabriel

Problem

SafeExecutor._exec returns stdout.decode().strip()[-3000:] and stderr …[-1000:], with a fixed 60s timeout:

  • Evidence is mostly lost. The containment tools ([FEATURE] Approval-gated containment: isolate pod, cordon node, disable key, block IP (evidence first) #168) collect kubectl logs --tail=2000, describe and pod YAML as forensic evidence, but only the last 3000 characters reach the incident store. Any output longer than a page is cut the same way, so the agent only sees the end of it.
  • Non-UTF-8 output fails the whole command. .decode() is strict, so one binary byte (common in container logs or dmesg) raises UnicodeDecodeError. The generic except then returns an error and discards the output.
  • Large outputs such as journalctl or kubectl get -A -o yaml can hit 60s on slow clusters, with no way to raise the limit per call.

Proposed fix

  • Decode with errors="replace".
  • Keep two limits: what goes to the model (truncate with a clear …[truncated N bytes] marker, keeping the head and tail rather than only the tail), and what goes to storage. Evidence callers get the full output up to a cap, e.g. EXECUTOR_MAX_OUTPUT_BYTES=1MB.
  • Add a timeout parameter (default 60, evidence 180) and EXECUTOR_TIMEOUT_SEC.
  • Tests: a binary byte in the output, long output keeps both head and tail with the marker, evidence keeps its full size.

Files

tools/executor.py, tools/containment.py (_evidence), tests/test_executor_safety.py

Activity

  1. added
    bug
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions