Skip to content

fix: executor keeps evidence, handles binary output, stops timed-out commands (Fixes #206) - #218

Merged
OkiriGabriel merged 1 commit into
mainfrom
fix/executor-output-206
Nov 26, 2026
Merged

OkiriGabriel merged 1 commit into
mainfrom
fix/executor-output-206

Conversation

@OkiriGabriel

Copy link
Copy Markdown
Collaborator

Fixes #206.

Problems

Before After
Long output Only the last 3000 characters reached the agent, so the first error or header was lost Start and end kept, with …[truncated N characters]… in between and stdout_truncated_chars in the result. Size set by EXECUTOR_MAX_OUTPUT_CHARS (default 4000).
Containment evidence (#168) kubectl logs --tail=2000, describe and pod YAML were stored cut down to 3000 characters Evidence runs with max_output=EVIDENCE_MAX_OUTPUT_CHARS (1,000,000) and timeout=EVIDENCE_TIMEOUT_SEC (180). It's stored, not sent to the model.
Non-UTF-8 byte in output (container logs, dmesg) UnicodeDecodeError, so a successful command came back as an error with no output Decoded with errors="replace"
Timeout Fixed at 60s, and the process was left running in the background timeout per call or EXECUTOR_TIMEOUT_SEC. Commands run in their own process group, and the whole group is killed on timeout, children included.

Changes

  • tools/executor.py:
    • clip_output(): about a quarter of the limit for the start and the rest for the end.
    • run(..., timeout=, max_output=) and _exec(...). The keyword arguments are only passed through when set, so existing fakes of _exec(command, host) keep working.
    • start_new_session=True and os.killpg on timeout.
  • tools/containment.py: evidence capture asks for the full output and a longer timeout.
  • .env.example: the four new settings.

Tests

tests/test_executor_output.py, 9 tests, using real subprocesses:

  • Clipping keeps the start and the end.
  • printf '\377\376' succeeds.
  • seq 1 20000 keeps the first and last lines and shows the marker; with an evidence-size limit it's kept whole; the env setting changes the limit.
  • sh -c 'sleep 2; touch marker' with timeout=1 returns in under 4s, and the marker is never created, so the child was killed.
  • The timeout default comes from the env, and containment evidence asks for the full limits.

Full suite: 1457 passed, 4 skipped. Flake8 (CI selection) and bandit are clean.

…out commands (#206)

- Output is decoded with errors="replace": one non-UTF-8 byte no longer
  turns a successful command into an error with no output.
- Long output keeps the start AND the end with a "[truncated N characters]"
  marker (was: last 3000 chars only), plus stdout_truncated_chars.
  EXECUTOR_MAX_OUTPUT_CHARS (default 4000) and EXECUTOR_TIMEOUT_SEC (60).
- run()/_exec() take timeout and max_output; containment evidence uses
  EVIDENCE_TIMEOUT_SEC (180) and EVIDENCE_MAX_OUTPUT_CHARS (1,000,000), so
  stored forensic evidence is no longer cut to a page.
- Commands run in their own process group; on timeout the whole group is
  killed instead of being left running in the background.

Fixes #206
@OkiriGabriel
OkiriGabriel merged commit 3cf262b into main Nov 26, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant