Shrinking Yocto, CMake and engine output to the lines that matter

Anyone who has asked an AI assistant to help with an embedded Linux build, a large C++ project or a game engine compile knows the pattern. The build fails, the log runs to thousands of lines, and pasting it all into the chat either hits a size limit or burns through a large share of the usage allowance in a few exchanges. Beginners debugging something as ordinary as getting a display working on a single-board computer report exhausting a monthly plan's daily limit astonishingly fast this way.
The fix is not a bigger model or a bigger plan. It is sending less, and sending the right part. This guide shows how to extract the lines that actually explain a failure, add the context a model needs to reason about it and iterate without resending everything. The techniques work with any assistant, paid or free.
Frequently asked questions
Why do build logs consume so many tokens?
They are long, repetitive and full of paths, flags and hashes that tokenize poorly. A single verbose build can produce more tokens than hours of normal conversation, and in a chat each later message resends earlier content.
Which part of a log is usually most useful?
The first real error, not the last line. Later errors are often consequences of the first. The lines just before the first error, showing what was being built and with which command, are usually needed too.
How does an embedded build log differ from an application log?
Embedded build systems run many separate tasks for many packages, each with its own log. The top-level output often only says which task failed and where its detailed log lives. That detailed log is what you need.
Should I let a coding agent read the logs itself?
Only if it limits what it reads. Agents that read entire log files into context can exhaust limits quickly. Instruct them to search for errors and read only surrounding lines.
Which model is better for build debugging, a paid flagship or a free one?
For obscure toolchain interactions and unusual hardware setups, frontier models with deep technical knowledge are noticeably stronger. For common compiler errors and missing dependencies, a mid-sized model often suffices once the log is trimmed.
Is it safe to paste build logs into an AI tool?
Logs can contain internal hostnames, usernames, paths and occasionally credentials from environment variables or URLs. Scan for secrets before sharing, especially with third-party endpoints.
Can a free model handle a long log at all?
With a 32,000-token context, a trimmed log of a few hundred lines fits easily. A raw log of tens of thousands of lines does not fit any reasonable request, which is another reason to trim first.
- Why sending the whole log backfires
- Step one: find the failing task or target
- Step two: extract the error with context
- Step three: add the minimum environment context
- Step four: write a focused question
- Step five: iterate with diffs, not full reruns
- Teaching an agent to read logs efficiently
- Choosing a model and keeping logs safe
Step by step
- Identify the failing component — From the top-level output, note the recipe, target or module that failed and find its detailed log file.
- Extract the first error with context — Run a script that prints about 30 lines before and 10 after the first error match, falling back to the log's tail.
- Add minimal environment details — Write five to ten lines on target, build system, host, recent changes, the exact command and relevant configuration lines.
- Ask one focused question — Request the most likely cause, a first check and the single extra file or output that would confirm the hypothesis.
- Iterate with short updates — After each fix, send only the new first error and what you changed, and start a new thread for each new problem.
Why sending the whole log backfires
It seems helpful to give the model everything. In practice, a full log hides the important lines among thousands of routine ones: compiler invocations, progress messages, warnings that have always been there. Models handle this better than humans scanning by eye, but attention still dilutes, and the answer may focus on a harmless warning instead of the fatal error.
Cost and limits make it worse. Each follow-up question in a chat carries the earlier log along, so the second and third messages cost as much as the first. A few rounds of this can use up a daily allowance on a subscription or a noticeable amount of money on an API.
The first error is usually the real one
Build systems often continue after a failure or report cascades of follow-on errors. The earliest error line, together with the command that produced it, almost always carries the actual cause.
Warnings rarely explain failures
Long lists of deprecation and unused-variable warnings are typical in large C and C++ builds. Unless one directly relates to the failing step, they are noise for the purpose of debugging.
Step one: find the failing task or target
Start from the top-level output and identify which component failed. In embedded build systems, this is the recipe and task name, along with a path to the task's own log. In CMake or Make builds, it is the target and the compile or link command. In game engines, it is often the module or plugin that failed to compile.
Note this information in one or two lines. It frames everything else you send and tells the model where to look.
Embedded builds point to their own logs
When a task fails in a Yocto-style build, the summary typically names the recipe, the task and a log file under a temporary work directory. Open that file; the top-level output alone is rarely enough to diagnose the issue.

Step two: extract the error with context
Search the relevant log for the first line matching error patterns, then take a window of lines around it: perhaps thirty before and ten after. Before the error, you see what was being compiled and with which flags; after it, you see whether the build stopped or carried on.
A short script makes this repeatable. The version below finds the first match for common error markers and prints a window around it, with optional additional matches if they look independent.
Fall back to the tail
If no pattern matches, the last few dozen lines are the next best guess. The script prints them automatically so you still have something focused to send.
Strip timestamps and progress bars
Lines that differ only in a counter or timestamp add tokens without information. Removing them, or collapsing repeated lines into one with a count, often halves the size further.
import re
import sys
PATTERN = re.compile(r"(\berror\b|fatal|undefined reference|No such file|ERROR:)", re.I)
BEFORE, AFTER, MAX_HITS = 30, 10, 3
lines = open(sys.argv[1], encoding="utf-8", errors="replace").read().splitlines()
hits = [i for i, line in enumerate(lines) if PATTERN.search(line)]
shown_until = -1
for i in hits[:MAX_HITS]:
if i <= shown_until:
continue
start, end = max(0, i - BEFORE), min(len(lines), i + AFTER + 1)
print(f"--- lines {start + 1}-{end} ---")
print("\n".join(lines[start:end]))
shown_until = end
if not hits:
print("\n".join(lines[-60:]))Step three: add the minimum environment context
An error line alone can be ambiguous. Add a short block describing the environment: target hardware, build system and version, host operating system, the toolchain and what you changed since the last successful build. Five to ten lines are usually enough.
For configuration-related failures, include the specific configuration lines involved rather than whole files. In embedded work, that might be the relevant lines from a layer configuration or machine definition; in CMake, the lines that define the failing target.
Say what you already tried
Listing the fixes you attempted prevents the model from suggesting them again and often hints at where the problem is not, which narrows the search.
- Target: board or platform, architecture.
- Build system and version, host OS.
- What changed since the last working build.
- The exact command you ran.
- Relevant configuration lines, not entire files.

Step four: write a focused question
End the message with one clear question. "What is the most likely cause of the first error, and what should I check first?" is better than "Why doesn't this work?". Asking for the most likely cause and a first check keeps the answer short and actionable.
Ask the model to state what extra information would confirm its hypothesis. That way, the next exchange contains only the specific file or command output it needs, not another full log.
One problem per thread
Once a problem is solved, start a new conversation for the next one. Carrying a solved issue's logs into the next question only adds cost and confusion.
Environment:
- Target: ARM single-board computer, display over DSI
- Build: Yocto-based image, host Ubuntu
- Changed: added a display overlay to the machine config
First error (with 30 lines before, 10 after):
<paste trimmed excerpt>
Question: What is the most likely cause of this first error, what should I check first,
and which single file or command output would confirm it?Step five: iterate with diffs, not full reruns
After applying a suggested fix, rebuild and, if it still fails, repeat the extraction. Send only the new first error and a one-line note on what you changed. If the error is the same, say so instead of pasting it again.
If the error changed, that is progress worth noting explicitly. Models reason better when they see the sequence: original error, fix applied, new error. That narrative is also cheaper than full logs at every step.
Keep a debugging journal
A short text file with each attempt, its result and the relevant log excerpt helps you and the model. When you return the next day or switch tools, paste the journal instead of reconstructing history.
Know when to stop asking
If several rounds produce plausible but wrong suggestions, the model may lack specific knowledge of your hardware or toolchain version. Vendor documentation, release notes and community issue trackers then become the better source.

Teaching an agent to read logs efficiently
Coding agents can read logs themselves, which is convenient and risky. Without guidance, an agent may load an entire multi-megabyte log into context. Add rules to its instructions: search with grep for error patterns first, read only the surrounding lines, and never read files over a size limit in full.
Many agent tools let you define such rules in a project file. The same approach helps with other noisy outputs such as test suites and package manager logs. The article on why token counts climb in agent sessions explains why tool output is often the largest cost.
Cap command output
Pipe long commands through tail or head in agent workflows, or configure the agent to truncate tool output. Unbounded output is the single biggest source of runaway context.
## Reading logs
- Never read a log file in full if it is larger than 200 KB.
- First run: grep -n -m 5 -iE 'error|fatal|undefined reference' <log>
- Then read only 30 lines before and 10 after the first match.
- Summarise findings in five lines before proposing a fix.Choosing a model and keeping logs safe
For common failures, such as missing headers, linker errors and dependency conflicts, a mid-sized model working from a trimmed excerpt often finds the cause. The keyless endpoint on this site serves free-ai, an independent open-weight model of about 35B parameters. It is not Claude, and the site is not affiliated with Anthropic. Its 32,000-token context holds a well-trimmed log with room to spare.
For unusual hardware, vendor-specific toolchains and subtle interactions between layers, frontier models such as Claude bring broader technical knowledge and usually do better. Whichever you use, scan logs for secrets first: tokens in URLs, passwords in environment dumps and internal hostnames. The article on who can read prompts sent through proxies explains why that matters more with unknown endpoints, and prompting compact models helps when you use a smaller one.
Mask secrets automatically
Add a step to the extraction script that replaces anything resembling a token, password assignment or private hostname with a placeholder. A few regular expressions catch most cases, and the masked excerpt is just as useful to the model, because it needs the structure of the error rather than the secret values.
Free limits suit this workflow
With trimmed excerpts, each request is small, so the free endpoint's per-IP limits of one request per second and a daily token budget rarely matter during a debugging session.

Send a test prompt to the keyless free-ai endpoint from the chat box on the home page, no sign-up or key required.
Read also
- How to Analyse an Ad Campaign Export With an LLM API, Step by Step
- Why Don't AI Agents Know Today's Date or the User's Time Zone?
- Why Does a Coding Assistant Keep Adding Its Own Vendor's API?
- Coding-Tuned Model vs All-Round Model: Which Suits Everyday Work?
- Huge Context Window vs a 32K One: Which Does Your Task Really Need?