Skip to content

Commit 000266d

Browse files
committed
small adjustments
1 parent fa25725 commit 000266d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

hud/environment/environment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ async def __aexit__(
406406
self._tool_routing_built = False
407407
self._prompt_routing_built = False
408408
self._resource_routing_built = False
409+
self._active_session = None # Clear stale scenario state
409410

410411
async def run_async(
411412
self,

hud/environment/scenarios.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,21 +237,20 @@ async def run_scenario_setup(self, scenario_name: str, args: dict[str, Any]) ->
237237
env_name = getattr(self, "_source_env_name", None) or self.name
238238
prompt_id = f"{env_name}:{scenario_name}"
239239

240-
# Use router to find which connection serves this prompt
241-
conn_name = self._router.get_prompt_connection(prompt_id) # type: ignore[attr-defined]
242-
logger.debug(
243-
"Remote scenario: prompt_id=%s, connection=%s",
244-
prompt_id,
245-
conn_name or "(not found in router)",
246-
)
247-
248240
# Serialize args for MCP prompt (only supports string values)
249241
serialized_args: dict[str, str] = {}
250242
for key, value in args.items():
251243
serialized_args[key] = value if isinstance(value, str) else json.dumps(value)
252244

253245
try:
254246
result = await self.get_prompt(prompt_id, serialized_args) # type: ignore[attr-defined]
247+
# Get connection AFTER get_prompt succeeds (routing is now guaranteed built)
248+
conn_name = self._router.get_prompt_connection(prompt_id) # type: ignore[attr-defined]
249+
logger.debug(
250+
"Remote scenario: prompt_id=%s, connection=%s",
251+
prompt_id,
252+
conn_name or "(not found in router)",
253+
)
255254
except Exception as e:
256255
# Fetch available scenarios for error context
257256
try:

0 commit comments

Comments
 (0)