spacedriveapp / spacedriveapp/spacebot

Workers should auto-truncate large tool outputs to prevent context overflow

Open
#504 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.4k
Forks
367
PR merge metrics
No merged PRs in 30d

Description

Feature Request / Improvement

Workers that run shell commands with large outputs (e.g., journalctl, cat, find) can easily fill the model's context window. There is no automatic truncation of tool results before they are sent to the LLM, causing model_context_window_exceeded errors (see related issue about non-retriable context overflow).

Current Behavior

  • Shell tool returns full stdout/stderr to the worker's context
  • A single journalctl --no-pager -n 500 can produce 100KB+ of text
  • Multiple large tool results accumulate and exceed the context window
  • Worker fails with context overflow (related: retries are wasted on non-retriable error)

Proposed Behavior

  • Implement automatic truncation of large tool outputs (e.g., max 4000-8000 characters per tool result)
  • When truncation occurs, append a note: [Output truncated: N characters omitted. Use pagination or filtering to see more.]
  • Allow per-tool configuration of max output size (e.g., shell tool might have a higher limit than file_read)
  • Consider adding a context usage check before API calls — if approaching the limit, proactively summarize oldest tool results

Impact

  • Prevents context overflow from killing workers mid-task
  • Reduces token usage and API costs
  • Makes workers more reliable for log analysis and system administration tasks
  • Complements the non-retriable context overflow fix

Examples Where This Would Help

  • journalctl -u spacebot --no-pager --since "2026-03-21" — easily 50-100KB
  • find / -name "*.log" — can produce thousands of lines
  • cat /var/log/some-service.log — unbounded file size
  • Multiple parallel curl responses with large JSON bodies

Environment

  • Spacebot version: 0.3.3
  • Model: zai_anthropic/glm-5-turbo (128k context but fills fast with raw logs)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file, test, or entry point is named in the issue. Trace how shell and other tool outputs enter worker messages, then define bounded and configurable results with an omission note; verify that large and repeated outputs no longer trigger context overflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
ai, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.