fix(code-exec): preserve interrupt cancellation source
This commit is contained in:
@@ -46,6 +46,7 @@ from tools.code_execution_tool import (
|
||||
EXECUTE_CODE_SCHEMA,
|
||||
_TOOL_DOC_LINES,
|
||||
_execute_remote,
|
||||
_format_interrupted_output,
|
||||
)
|
||||
from tools.registry import registry
|
||||
|
||||
@@ -81,6 +82,33 @@ class TestSandboxRequirements(unittest.TestCase):
|
||||
self.assertIn("code", EXECUTE_CODE_SCHEMA["parameters"]["required"])
|
||||
|
||||
|
||||
class TestInterruptedOutput(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
from tools.interrupt import set_interrupt
|
||||
|
||||
set_interrupt(False)
|
||||
|
||||
def test_uses_recorded_interrupt_source(self):
|
||||
from tools.interrupt import set_interrupt
|
||||
|
||||
set_interrupt(True, reason="superseded by a new live turn")
|
||||
|
||||
self.assertEqual(
|
||||
_format_interrupted_output("partial output"),
|
||||
"partial output\n[execution interrupted — superseded by a new live turn]",
|
||||
)
|
||||
|
||||
def test_unknown_interrupt_source_is_neutral(self):
|
||||
from tools.interrupt import set_interrupt
|
||||
|
||||
set_interrupt(True)
|
||||
|
||||
self.assertEqual(
|
||||
_format_interrupted_output(""),
|
||||
"[execution interrupted]",
|
||||
)
|
||||
|
||||
|
||||
class TestHermesToolsGeneration(unittest.TestCase):
|
||||
def test_generates_all_allowed_tools(self):
|
||||
src = generate_hermes_tools_module(list(SANDBOX_ALLOWED_TOOLS))
|
||||
|
||||
Reference in New Issue
Block a user