Skip to content

Commit c8d425e

Browse files
committed
feat: Adopt AgentRole enum for agent roles and add connection error handling during agent registration.
1 parent f4fab05 commit c8d425e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

agents/attackers/interactive_tui/interactive_tui.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from textual import on
1313
from textual.reactive import reactive
1414
from NetSecGameAgents.agents.attackers.interactive_tui.assistant import LLMAssistant
15-
from netsecgame.game_components import Network, IP, ActionType, Action, GameState, Observation, AgentStatus
15+
from netsecgame.game_components import Network, IP, ActionType, Action, GameState, Observation, AgentStatus, AgentRole
1616
from netsecgame import BaseAgent
1717
log_filename = os.path.dirname(os.path.abspath(__file__)) + "/interactive_tui_agent.log"
1818
logging.basicConfig(
@@ -113,7 +113,7 @@ def __init__(
113113
self,
114114
host: str,
115115
port: int,
116-
role: str,
116+
role: AgentRole,
117117
mode: str,
118118
llm: str,
119119
api_url: str,
@@ -129,8 +129,9 @@ def __init__(
129129
self.service_input = ""
130130
self.data_input = ""
131131
self.agent = BaseAgent(host, port, role)
132-
self.agent.register()
133-
self.current_obs = self.agent.request_game_reset()
132+
self.current_obs = self.agent.register()
133+
if self.current_obs is None:
134+
raise ConnectionError("Could not register agent. Check if any other agent is already connected.")
134135
self.mode = mode
135136

136137
# Keep track of the actions played previously
@@ -687,7 +688,7 @@ def _clear_state(self) -> None:
687688
app = InteractiveTUI(
688689
args.host,
689690
args.port,
690-
args.role,
691+
AgentRole.from_string(args.role),
691692
args.mode,
692693
args.llm,
693694
args.api_url,

0 commit comments

Comments
 (0)