mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 15:37:55 +08:00
tools: keep tool output whole and let the request-prep pass cap it
run_argv, run_argv_batch, fetch, fetch_local, and the vcs tools now return their output whole, so the request-prep cap trims it on the wire and names its document. A fetched page or a long log reads on from the tool message, with no re-fetch and no re-run. The run_argv_batch run budget stays as an execution guard: it stops a runaway batch from spawning further huge-output steps. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This commit is contained in:
@@ -84,42 +84,6 @@ async def test_get_truncated_file_missing(workspace: Path) -> None:
|
||||
assert out.startswith("error:")
|
||||
|
||||
|
||||
async def test_get_truncated_serves_a_fetch_body_without_refetching(monkeypatch) -> None:
|
||||
"""A fetch body's token reads the stored remainder; the request is not repeated."""
|
||||
from plyngent.tools.net.fetch_local import format_fetch_result
|
||||
|
||||
fetch_module = importlib.import_module("plyngent.tools.net.fetch_local")
|
||||
|
||||
async def _must_not_refetch(*_args: object, **_kwargs: object) -> str:
|
||||
msg = "resuming a fetch body must not re-run the request"
|
||||
raise AssertionError(msg)
|
||||
|
||||
monkeypatch.setattr(fetch_module, "http_fetch", _must_not_refetch)
|
||||
first = format_fetch_result(
|
||||
status=200,
|
||||
final_url="https://example.com/x",
|
||||
content_type="text/plain",
|
||||
body_text="x" * 600,
|
||||
body_bytes=600,
|
||||
truncated=False,
|
||||
redirects=0,
|
||||
method="GET",
|
||||
security="public",
|
||||
warnings=[],
|
||||
body_kind="text",
|
||||
max_chars=200,
|
||||
)
|
||||
token = _extract_token(first)
|
||||
assert token is not None
|
||||
parsed = decode_truncate_token(token)
|
||||
assert parsed is not None
|
||||
assert parsed.kind == "memory"
|
||||
out = await call_async(get_truncated, token, max_chars=200)
|
||||
content, _, _ = out.partition("\n[Truncated")
|
||||
assert content == "x" * len(content)
|
||||
assert 0 < len(content) <= 200
|
||||
|
||||
|
||||
async def test_get_truncated_memory_chains() -> None:
|
||||
from plyngent.tools.truncate_token import truncate_generic
|
||||
|
||||
|
||||
Reference in New Issue
Block a user