Commit graph

4 commits

Author SHA1 Message Date
Mads Hvelplund
0640e5c9ea
fix(core): backstop single-chunk overflow; add helper tests
Code review findings:

- factory._wrap_exec_command: add post-compression backstop that calls
  truncate_exec_result when compress_exec_result returns an oversized
  result (happens when _split produces 1 chunk, e.g. a single very
  large JSON record — compress_large_output correctly returns it
  unchanged, but the result was never guarded against threshold after).

- tests/agents/test_factory_helpers.py (new): unit tests for
  _resolve_model (run_config vs settings fallback, None/whitespace
  error cases, non-string Model object guard) and _extract_task_hint
  (valid cmd, missing cmd, non-string cmd, invalid JSON, non-dict JSON).
2026-06-19 13:52:18 +02:00
Mads Hvelplund
eac81f8693
feat(core): MapReduce LLM compression for large exec_command outputs
Replaces plain truncation with a parallel summarisation pipeline when
exec_command output exceeds STRIX_MAX_TOOL_OUTPUT_CHARS (default 65536).
Output is split at JSON record or line boundaries; each chunk is
summarised via litellm.acompletion; summaries are consolidated into a
single result that fits the context window.

Falls back to truncate_exec_result on any compression error.

Closes #579
2026-06-19 13:52:13 +02:00
Mads Hvelplund
5aa61c5202
feat: truncate oversized exec_command output to prevent context overflow
exec_command output is now capped at STRIX_MAX_TOOL_OUTPUT_CHARS (default
65536). JSON arrays are parsed and trimmed to the first 50 records (valid
JSON preserved); plain text keeps the first 300 lines. Both include a
header showing the total size and record/line count so the agent retains
full awareness of what was produced.

A secondary character cap prevents single very long lines from bypassing
the line limit. Set STRIX_MAX_TOOL_OUTPUT_CHARS=0 to disable.
2026-06-19 13:45:26 +02:00
Mads Hvelplund
c91e4ca1b9
fix: bypass image-strip recovery for ContextWindowExceededError
ContextWindowExceededError carries status_code=400, which matched the
_INPUT_REJECTION_CODES guard and triggered image-strip retry logic.
Image stripping cannot reduce token count, so the agent wasted up to
3 retry cycles before parking as failed.

Add an explicit isinstance check before the status-code guard to detect
context-window overflow and park the agent as 'failed' immediately.
2026-06-19 13:40:45 +02:00