Skip to content

Adds an --agent flag to job log for the robots#885

Open
mcncl wants to merge 12 commits into
mainfrom
feat/llm_optimised_logs
Open

Adds an --agent flag to job log for the robots#885
mcncl wants to merge 12 commits into
mainfrom
feat/llm_optimised_logs

Conversation

@mcncl

@mcncl mcncl commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Description

Fetching a Buildkite job log for an LLM/agent to read is wasteful: the raw log is full of ANSI colour codes, inline \x1b_bk;t=... timestamps, and carriage-return progress redraws that burn tokens without adding meaning.

This PR adds an opt-in --agent flag to bk job log that digests the log into a compact, LLM-friendly form via the terminal-to-llm library (strips escapes/timestamps, resolves CR redraws, collapses duplicate/progress lines, and applies failure-focused windowing). On a real job log this cut output by ~87%.

To see the reduction on any job:

go build -o /tmp/bk .
echo "raw:   $(/tmp/bk job log <uuid> | wc -c) bytes"
echo "agent: $(/tmp/bk job log <uuid> --agent | wc -c) bytes"

Changes

  • Add --agent to bk job log, routing output through digest.Process
  • Add supporting flags (only meaningful with --agent):
    • --format plain|markdown - render groups as Markdown headings/code blocks.
    • --max-tokens N — hard ceiling on estimated tokens (0 = unlimited).
    • --no-window — disable failure-focused windowing (keep all lines).

bk job log --help:

--no-timestamps     Strip timestamp prefixes from log output
--agent             Format output to be optimal for LLM consumption
                    (strips ANSI, deduplicates loops)
--format="plain"    Output rendering for `--agent`: plain or markdown
--max-tokens=INT    Hard ceiling on the estimated token count of `--agent` output (0 = unlimited)
--no-window         Disable failure-focused windowing in `--agent` output

Testing

  • Tests have run locally (with mise test)
  • Code is formatted (with mise format)

Also verified end-to-end against a real job log across each flag combination.

@mcncl mcncl requested review from a team as code owners June 21, 2026 23:48
Comment thread cmd/job/log.go Outdated
@socket-security

socket-security Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgithub.com/​mcncl/​terminal-to-llm@​v0.0.0-20260625015351-3819cf9f5f9b100100100100100

View full report

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.

2 participants