Added timeout and limit to script entries

This commit is contained in:
Niels Geens
2024-11-13 17:48:39 +01:00
parent 65478e0b17
commit 834ce12e8f
21 changed files with 262 additions and 141 deletions

View File

@@ -123,10 +123,10 @@ class WorkingMemoryTest(unittest.TestCase):
# Add different types of entries
entries = [
ReasoningEntry("test reasoning", "reasoning-1", self.test_timestamp),
ParseErrorEntry("bad content", "error msg", "error-1", self.test_timestamp),
ReadEntry(io_buffer, "read-1", self.test_timestamp),
WriteEntry("test output", io_buffer, "write-1", self.test_timestamp)
ReasoningEntry("reasoning-1", self.test_timestamp, "test reasoning"),
ParseErrorEntry("error-1", self.test_timestamp, "bad content", "error msg"),
ReadEntry("read-1", self.test_timestamp, io_buffer),
WriteEntry("write-1", self.test_timestamp, "test output", io_buffer)
]
for entry in entries:
@@ -161,7 +161,7 @@ class WorkingMemoryTest(unittest.TestCase):
def test_remove_entry_cleanup(self):
"""Test that removing an entry triggers cleanup"""
# Create and start background process
entry = BackgroundEntry("sleep 10", "test-id", self.test_timestamp)
entry = BackgroundEntry("test-id", self.test_timestamp, "sleep 10")
self.memory.add_entry(entry)
# Wait for process to start and get PID
@@ -181,7 +181,7 @@ class WorkingMemoryTest(unittest.TestCase):
# Add multiple background processes
pids = []
for i in range(3):
entry = BackgroundEntry("sleep 10", f"id-{i}", self.test_timestamp)
entry = BackgroundEntry(f"id-{i}", self.test_timestamp, "sleep 10")
self.memory.add_entry(entry)
self.assertTrue(self.wait_for_process_start(entry))
context = entry.generate_context()
@@ -201,7 +201,7 @@ class WorkingMemoryTest(unittest.TestCase):
def test_cleanup_on_memory_deletion(self):
"""Test that deleting memory properly cleans up all entries"""
# Add a background process
entry = BackgroundEntry("sleep 10", "test-id", self.test_timestamp)
entry = BackgroundEntry("test-id", self.test_timestamp, "sleep 10")
self.memory.add_entry(entry)
# Wait for process to start and get PID
@@ -221,7 +221,7 @@ class WorkingMemoryTest(unittest.TestCase):
"""Test getting all entries"""
# Add multiple entries
entries = [
ReasoningEntry(f"content {i}", f"id-{i}", self.test_timestamp)
ReasoningEntry(f"id-{i}", self.test_timestamp, f"content {i}")
for i in range(3)
]
@@ -239,7 +239,7 @@ class WorkingMemoryTest(unittest.TestCase):
def test_get_entries_returns_copy(self):
"""Test that get_entries returns a copy of the list"""
# Add an entry
entry = ReasoningEntry("test content", "test-id", self.test_timestamp)
entry = ReasoningEntry("test-id", self.test_timestamp, "test content")
self.memory.add_entry(entry)
# Get entries and modify the returned list