Call an environment action Args: name: Name of the environment action: Name of the action input: Input for the action Returns: Action result
(self,
name: str,
action: str,
input: Dict[str, Any],
ctx: SessionContext = None,
**kwargs)
| 1402 | logger.error(f"| ❌ Error during environment context manager cleanup: {e}") |
| 1403 | |
| 1404 | async def __call__(self, |
| 1405 | name: str, |
| 1406 | action: str, |
| 1407 | input: Dict[str, Any], |
| 1408 | ctx: SessionContext = None, |
| 1409 | **kwargs) -> Any: |
| 1410 | """Call an environment action |
| 1411 | |
| 1412 | Args: |
| 1413 | name: Name of the environment |
| 1414 | action: Name of the action |
| 1415 | input: Input for the action |
| 1416 | |
| 1417 | Returns: |
| 1418 | Action result |
| 1419 | """ |
| 1420 | if ctx is None: |
| 1421 | ctx = SessionContext() |
| 1422 | |
| 1423 | if name in self._environment_configs: |
| 1424 | env_config = self._environment_configs[name] |
| 1425 | |
| 1426 | version = env_config.version |
| 1427 | env_instance = env_config.instance |
| 1428 | logger.info(f"| ✅ Using environment {name}@{version}") |
| 1429 | |
| 1430 | action_config = env_config.actions.get(action) |
| 1431 | if action_config is None: |
| 1432 | raise ValueError(f"Action {action} not found in environment {name}") |
| 1433 | action_function = action_config.function |
| 1434 | |
| 1435 | # Environment args |
| 1436 | env_args = { |
| 1437 | "ctx": ctx, |
| 1438 | } |
| 1439 | |
| 1440 | # Check if action_function is a bound method (already has self bound) |
| 1441 | # Bound methods have __self__ attribute, unbound methods don't |
| 1442 | if hasattr(action_function, '__self__'): |
| 1443 | # Bound method: call directly without passing instance |
| 1444 | return await action_function(**input, **env_args) |
| 1445 | else: |
| 1446 | # Unbound method: pass instance as first argument |
| 1447 | return await action_function(env_instance, **input, **env_args) |
| 1448 | else: |
| 1449 | raise ValueError(f"Environment {name} not found") |
nothing calls this directly
no test coverage detected