A failing run hides in a window around the first error. Passing heartbeats before and after add tokens without adding signal.
The trimmer below keeps flagged lines plus 3 lines before and 5 after. On a 40-line toy log with flagged lines at 28 and 29, it keeps lines 25 to 34: 10 of 40 lines.
import sys
ERR = (28, 29)
def build_log():
lines = []
for i in range(40):
if i in ERR:
lines.append(f"{i:04d} ERROR dma timeout on channel {i - 27}")
elif i % 9 == 4:
lines.append(f"{i:04d} WARN temperature {70 + i} C")
else:
lines.append(f"{i:04d} INFO heartbeat ok")
return lines
def trim(lines, before=3, after=5):
keep = set()
for i, ln in enumerate(lines):
if "ERROR" in ln:
for j in range(i - before, i + after + 1):
if 0 <= j < len(lines):
keep.add(j)
return sorted(keep)
def main():
lines = build_log()
kept = trim(lines)
bad = 0
if len(lines) != 40:
bad += 1
if kept != list(range(25, 35)):
bad += 1
if not all(i in kept for i in ERR):
bad += 1
if not (len(kept) < len(lines)):
bad += 1
if bad == 0:
print(f"PASS: kept {len(kept)} of {len(lines)} lines around {len(ERR)} flagged lines")
else:
print(f"FAIL: {bad} checks wrong")
sys.exit(1)
main()The same rule applies to source context. Send the failing module with its interfaces, and drop unrelated blocks even when they feel relevant.
Keep for a DMA timeout debug | Drop for now |
|---|---|
The DMA channel module under suspicion | Unrelated peripherals and their drivers. |
Interface definitions it instantiates | Full commit history of the block. |
The constraint snippet driving the failing case | Passing testbenches from other blocks. |
Trimming never justifies sending secrets or keys, or sending proprietary IP to a deployment not approved for it. Redact first, and treat log text as untrusted data that may carry injected instructions.
Assume about 10 tokens per log line and 3 units per million input tokens as stated EXAMPLE figures. A 20000-line log then costs 0.6 units, while its 200-line slice costs 0.006 units.
EXAMPLE rule: about 10 tokens per log line
full log: 20000 lines x 10 = 200000 tokens
slice: 200 lines x 10 = 2000 tokens
ratio = 200000 / 2000 = 100, so 100:1
EXAMPLE rate: 3 units per million input tokens
full cost = 200000 x 3 / 1000000 = 600000 / 1000000 = 0.6 units
slice cost = 2000 x 3 / 1000000 = 6000 / 1000000 = 0.006 units
budget split example: instructions 10% + chunks 30% + slice 40% + output 20%
check: 10 + 30 + 40 + 20 = 100Budget share | Spends tokens on | If it grows too far |
|---|---|---|
Instructions, 10% | Role, schema and the current question | Repeated boilerplate crowds out evidence. |
Retrieved chunks, 30% | Top-ranked background | Low-ranked chunks dilute the prompt. |
Failing slice, 40% | Log window and RTL under debug | Wider windows regress toward the full dump. |
Output allowance, 20% | Room for the answer itself | Starved answers truncate before the verdict. |
Three lines before the first flag and five lines after the last flag: 28 minus 3 is 25, and 29 plus 5 is 34.
The full log costs 0.6 units and the slice costs 0.006 units, a 100:1 ratio.