feat: Initial library extraction from PIN LLM benchmark
DockerSandbox + LangChain file/shell tools extracted into a standalone package. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
25
docker_agent_sandbox/tools/_utils.py
Normal file
25
docker_agent_sandbox/tools/_utils.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""_utils.py – shared helpers for file-ops tools."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import posixpath
|
||||
|
||||
_MAX_OUTPUT_LINES = 200
|
||||
_MAX_OUTPUT_CHARS = 20_000
|
||||
_TRUNCATION_NOTICE = "\n... [output truncated] ..."
|
||||
|
||||
|
||||
def truncate_output(output: str) -> str:
|
||||
"""Truncate *output* to avoid hitting token limits."""
|
||||
lines = output.splitlines(keepends=True)
|
||||
if len(lines) > _MAX_OUTPUT_LINES:
|
||||
output = "".join(lines[:_MAX_OUTPUT_LINES]) + _TRUNCATION_NOTICE
|
||||
if len(output) > _MAX_OUTPUT_CHARS:
|
||||
output = output[:_MAX_OUTPUT_CHARS] + _TRUNCATION_NOTICE
|
||||
return output
|
||||
|
||||
|
||||
def _parent(path: str) -> str:
|
||||
"""Return the parent directory of *path* (best-effort, no I/O)."""
|
||||
parent = posixpath.dirname(path.rstrip("/"))
|
||||
return parent or "."
|
||||
Reference in New Issue
Block a user