Skip to content

Commit

Permalink
Use incrementing integer for command IDs instead of UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Nov 21, 2024
1 parent 33abd47 commit 1700acf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions openhands/runtime/utils/bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def _remove_command_prefix(command_output: str, command: str) -> str:
class BashSession:
POLL_INTERVAL = 0.5
PS1 = CmdOutputMetadata.to_ps1_prompt()
_command_counter = 0 # Class variable to track command IDs across all sessions

def __init__(
self,
Expand All @@ -101,7 +102,7 @@ def __init__(
if username:
window_command = f'su {username}'

session_name = f'openhands-{username}-{uuid.uuid4()}'
session_name = f'openhands-{username}-{int(time.time())}'
self.session = self.server.new_session(
session_name=session_name,
window_name='bash',
Expand Down Expand Up @@ -300,9 +301,9 @@ def execute(self, action: CmdRunAction) -> CmdOutputObservation | ErrorObservati
if self.output_file and self.output_file.exists():
self.output_file.unlink()

# Create new output file for this command
command_id = str(uuid.uuid4())
self.output_file = self.output_dir / f'{command_id}.txt'
# Create new output file for this command with incrementing ID
BashSession._command_counter += 1
self.output_file = self.output_dir / f'cmd_{BashSession._command_counter:06d}.txt'
if action.command.strip() == '' and self.prev_status not in {
BashCommandStatus.CONTINUE,
BashCommandStatus.NO_CHANGE_TIMEOUT,
Expand Down

0 comments on commit 1700acf

Please sign in to comment.