Skip to content

test(tools): comprehensive test suite for http_request truncation wrapper (+36 tests) - #140

Open
manus-use wants to merge 1 commit into
mainfrom
test/http-request-truncation
Open

test(tools): comprehensive test suite for http_request truncation wrapper (+36 tests)#140
manus-use wants to merge 1 commit into
mainfrom
test/http-request-truncation

Conversation

@manus-use

Copy link
Copy Markdown
Owner

Summary

Adds a comprehensive test suite for the http_request truncation wrapper (src/manus_agent/tools/http_request.py) — 36 fully-mocked tests covering all truncation logic paths.

What's tested

Category Tests Coverage
Passthrough (no truncation) 6 Small items, empty content, non-text items, exact-at-limit
Phase 1: Per-item truncation 4 Single/multiple oversized items, marker format
Phase 2: Proportional total truncation 3 Total exceeds limit, proportional ratio, exact-at-limit
Combined Phase 1 + Phase 2 2 Both phases cascade, Phase 1 sufficient alone
Edge cases 8 Missing content key, None text, non-dict items, empty text, extra keys preserved, single-char overflow
Exception handling 3 Logging failure, non-iterable content, None content
Custom limits 3 Patched MAX_OUTPUT_CHARS, MAX_TOTAL_OUTPUT_CHARS, env-var defaults
Inner function passthrough 2 tool_use and kwargs forwarded correctly
Logging behavior 3 log_tool_output_size called, print sizes, no print when no text
Immutability 2 Original result not mutated, new dict on truncation
Proportional math accuracy 2 Ratio calculation, zero-length items

Why this matters

http_request.py is the universal HTTP wrapper used by every tool that makes external API calls. Its truncation logic (per-item cap → proportional total reduction) prevents context-window blowouts, but had zero test coverage. The logic includes non-trivial proportional math and multiple phases that can interact.

Existing PRs checked (no overlap)

None of the above test http_request.py — this is the first test coverage for this module.

Test results

1194 passed, 3 deselected, 2 warnings in 24.38s

All existing tests continue to pass. Ruff check/format clean.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant