mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
feat(tests): add live integration tests for file operations and shell noise filtering
- Introduce a new test suite in `test_file_tools_live.py` to validate file operations and ensure accurate command execution in a real environment. - Implement assertions to check for shell noise contamination in outputs, enhancing the reliability of command results. - Create fixtures for setting up a local environment and populating directories with known file contents for comprehensive testing. - Refactor shell noise handling in `process_registry.py` and `local.py` to support multiple noise patterns, improving output cleanliness.
This commit is contained in:
parent
23d0b7af6a
commit
1db5598294
3 changed files with 507 additions and 18 deletions
|
|
@ -87,13 +87,13 @@ class ProcessRegistry:
|
|||
- Cleanup thread (sandbox reaping coordination)
|
||||
"""
|
||||
|
||||
# Noise lines emitted by interactive shells when stdin is not a terminal.
|
||||
_SHELL_NOISE = frozenset({
|
||||
_SHELL_NOISE_SUBSTRINGS = (
|
||||
"bash: cannot set terminal process group",
|
||||
"bash: no job control in this shell",
|
||||
"bash: no job control in this shell\n",
|
||||
"no job control in this shell",
|
||||
"no job control in this shell\n",
|
||||
})
|
||||
"cannot set terminal process group",
|
||||
"tcsetattr: Inappropriate ioctl for device",
|
||||
)
|
||||
|
||||
def __init__(self):
|
||||
self._running: Dict[str, ProcessSession] = {}
|
||||
|
|
@ -106,10 +106,10 @@ class ProcessRegistry:
|
|||
@staticmethod
|
||||
def _clean_shell_noise(text: str) -> str:
|
||||
"""Strip shell startup warnings from the beginning of output."""
|
||||
lines = text.split("\n", 2)
|
||||
if lines and lines[0].strip() in ProcessRegistry._SHELL_NOISE:
|
||||
return "\n".join(lines[1:])
|
||||
return text
|
||||
lines = text.split("\n")
|
||||
while lines and any(noise in lines[0] for noise in ProcessRegistry._SHELL_NOISE_SUBSTRINGS):
|
||||
lines.pop(0)
|
||||
return "\n".join(lines)
|
||||
|
||||
# ----- Spawn -----
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue