Skip to content

fix(processes): let read_log take a negative offset to mean "the last N lines" - #146938

Open
princejain756 wants to merge 1 commit into
NousResearch:mainfrom
princejain756:fix/process-log-negative-offset
Open

princejain756 wants to merge 1 commit into
NousResearch:mainfrom
princejain756:fix/process-log-negative-offset

Conversation

@princejain756

Copy link
Copy Markdown

Summary

Fixes #146914 - process_manage(action="log") with an explicit negative offset returned empty output: lines[offset:offset + limit] for offset=-80, limit=80 slices lines[-80:0], which is always empty. Models pass negative offsets to mean "the last N lines" and got "" with no error.

  • read_log now normalizes the slice start: offset < 0 counts back from the end (max(total_lines + offset, 0)), so offset=-80 reads "80 lines ending at the tail". Positive/None/0 offsets are unchanged.
  • The offset schema description now documents the negative form so models discover it.

Test plan

  • scripts/run_tests.sh tests/tools/test_process_registry_read_log.py - new file, 2 tests: negative offset returns the tail, and a beyond-start offset clamps to the whole log
  • scripts/run_tests.sh tests/tools/test_process_registry.py - 99 pass, 0 fail (19 platform-gated skips on darwin)
  • python scripts/check - 13 checks ok (the fix is line-neutral inside the already-over-cap file)

… N lines"

lines[offset:offset + limit] with offset=-N becomes lines[-N:0], which is
always empty, so a model asking for a log tail via a negative offset got
"output": "" back with no hint why. Normalize the start index so a
negative offset counts back from the end (clamped at 0), and document it
in the offset schema description.

Fixes NousResearch#146914
@alt-glitch alt-glitch added comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists type/bug Something isn't working labels Oct 30, 2026
@whyyagswhy

Copy link
Copy Markdown

Verified at head a4df6c9f (fetched to refs/review/146938, SHA matches headRefOid a4df6c9f53370a6b51dc3b2f7c211209084ce4a4), in a detached worktree at that head via scripts/run_tests.sh:

  • tests/tools/test_process_registry_read_log.py (PR's own test file) — 2 passed, 0 failed
  • Neighbor tests/tools/test_process_registry.py — 112 passed, 0 failed, 4 skipped (Windows-only, host is linux)
  • ruff check on tools/process_registry.py + test file — clean

Change quote: tools/process_registry.py:2040 — start = (offset or 0) if offset is None or offset >= 0 else max(total_lines + offset, 0), so offset=-80 reads the tail instead of lines[-80:0] returning empty; schema text at :2613 now documents the negative form.

Gaps stated honestly: ran only the PR's own test file plus the closest neighbor, not the full tests/tools/ suite; no live process-log pagination exercised beyond the unit tests.

@princejain756

Copy link
Copy Markdown
Author

Thanks for running this against test_process_registry.py in a clean worktree @whyyagswhy.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: process_manage log with a negative offset returns empty output when offset + limit >= 0

3 participants