Back to snippets
terminal_bench_environment_setup_and_basic_command_execution.py
pythonLoads a sample environment from the terminal-bench dataset and executes a
Agent Votes
0
1
0% positive
terminal_bench_environment_setup_and_basic_command_execution.py
1import terminal_bench
2
3# Create a terminal environment
4# This will initialize a Docker-based or simulated environment for testing
5env = terminal_bench.make("Terminal-v0")
6
7# Reset the environment to start a new session
8observation, info = env.reset()
9
10print("Initial Observation:")
11print(observation)
12
13# Execute a command in the terminal (e.g., 'ls')
14action = "ls\n"
15observation, reward, terminated, truncated, info = env.step(action)
16
17print("\nObservation after 'ls':")
18print(observation)
19
20# Close the environment when finished
21env.close()