> This page is for version 0.7.0.
> For other versions, use one of these documentation indexes:
> - Main (default): https://docs.nvidia.com/nemo/gym/main/llms.txt
> - 0.7.0: https://docs.nvidia.com/nemo/gym/v0.7.0/llms.txt
> - 0.6.0: https://docs.nvidia.com/nemo/gym/v0.6.0/llms.txt
> - 0.5.1: https://docs.nvidia.com/nemo/gym/v0.5.1/llms.txt
> - 0.5.0: https://docs.nvidia.com/nemo/gym/v0.5.0/llms.txt
> - 0.4.0: https://docs.nvidia.com/nemo/gym/v0.4.0/llms.txt
> - 0.3.0: https://docs.nvidia.com/nemo/gym/v0.3.0/llms.txt
> - 0.2.1: https://docs.nvidia.com/nemo/gym/v0.2.1/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/gym/llms.txt.

# nemo_gym.agents.utils.agent_context

Resolve the files an agent session's agent_context names.

## Module Contents

### Functions

| Name                                                                                                    | Description                                                                                            |
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
| [`resolve_agent_context_artifact`](#nemo_gym-agents-utils-agent_context-resolve_agent_context_artifact) | The artifact's path under `root`, checked to stay inside it, through symlinks too, and to be a `kind`. |

### Data

[`_PATH_ERRNOS`](#nemo_gym-agents-utils-agent_context-_PATH_ERRNOS)

### API

```python
nemo_gym.agents.utils.agent_context.resolve_agent_context_artifact(
    artifact: nemo_gym.server_runtime.agent_context.AgentContextArtifact,
    root: pathlib.Path,
    kind: typing.Literal['file', 'directory']
) -> pathlib.Path
```

The artifact's path under `root`, checked to stay inside it, through symlinks too, and to be a `kind`.

Raises AgentSeedRejectedError otherwise, or when the path cannot be looked up (too long, no permission), so an
agent that resolves its artifacts while seeding refuses the session with a terminal 422 instead of failing its
first activation. The check runs on resolved paths: a directory under `root` that is a symlink to other
storage counts as outside, so configure the real directory as the root.

For a `directory`, only the directory itself is checked. Files under it can be symlinks to anywhere, so an
agent that reads them resolves each one and checks that it stays under the returned directory.

```python
nemo_gym.agents.utils.agent_context._PATH_ERRNOS = frozenset({errno.EACCES, errno.EPERM, errno.ENAMETOOLONG, errno.ELOOP, errno.ENO...
```