fix: escape strings in sandbox (#2156)

Co-authored-by: Sarah Wooders <sarahwooders@gmail.com>
This commit is contained in:
Kevin Lin
2024-12-03 19:37:17 -08:00
committed by GitHub
parent d255b58661
commit 9ac7e9b5d2
2 changed files with 13 additions and 3 deletions

View File

@@ -388,6 +388,18 @@ def test_e2b_sandbox_core_memory_replace(check_e2b_key_is_set, core_memory_repla
assert result.func_return is None
@pytest.mark.e2b_sandbox
def test_e2b_sandbox_escape_strings_in_args(check_e2b_key_is_set, core_memory_replace_tool, test_user, agent_state):
new_name = "Matt"
args = {"label": "human", "old_content": "Chad", "new_content": new_name + "\n"}
sandbox = ToolExecutionSandbox(core_memory_replace_tool.name, args, user_id=test_user.id)
# run the sandbox
result = sandbox.run(agent_state=agent_state)
assert new_name in result.agent_state.memory.get_block("human").value
assert result.func_return is None
@pytest.mark.e2b_sandbox
def test_e2b_sandbox_core_memory_replace_errors(check_e2b_key_is_set, core_memory_replace_tool, test_user, agent_state):
nonexistent_name = "Alexander Wang"