Skip to main content

ya-agent-environment

Environment abstractions for general agents.

ya-agent-environment provides the shared base interfaces used by YA agents:

  • Environment
  • FileOperator
  • Shell
  • ResourceRegistry
  • resumable resources
  • environment-owned temporary storage via tmp_dir and resolve_tmp_path()

The Python import package is ya_agent_environment.

Environment and File Backend Contracts

Environment owns temporary-directory configuration and lifecycle. While entered, env.tmp_dir exposes the agent-facing root (or None) and env.resolve_tmp_path(relative_path) safely resolves a contained path, rejecting absolute paths and parent traversal. Temporary paths are handled through the normal FileOperator methods; there is no separate temporary-file operator or routing API. Environment cleanup closes registered resources, the shell, and the file operator before _teardown() releases backend/container and temporary-directory resources. The same ordering is preserved after partial setup failures and during cancellation. The base class does not assume a filesystem backing store and never deletes _tmp_dir itself: custom environments must allocate their agent-facing temporary backend in _setup() and remove only owned storage in _teardown().

A FileOperator implementation exposes one logical path space by implementing its public abstract methods directly. read_bytes_stream() returns an AsyncIterator directly, so consume the returned iterator without awaiting the method call.

Workspace-backed concrete environments allocate owned temporary instances below .tmp/ya-agent-<id>. Each instance contains a self-ignoring .gitignore, and teardown removes only that owned instance. Custom environments remain responsible for allocating and tearing down their own temporary backend.

LocalFileOperator.walk_files() returns paths relative to default_path when possible and directly reusable absolute paths for explicitly allowed roots outside it. glob and grep may search those roots explicitly; root="." does not implicitly include temporary storage.

Bounded Output

Shared output-bounding policy lives in ya_agent_environment.output. It provides head/tail budget splitting, character and UTF-8 byte truncation, and incremental bounded text accumulation. Shell ingestion and SDK previews should reuse these helpers instead of defining independent truncation policies.

Shell Backend Contract

Custom Shell backends implement _create_process() and return an ExecutionHandle with stream, wait, and kill callbacks. Shell.execute() is the final public foreground boundary and must not be overridden: the base class owns process creation, timeout, cancellation, foreground/background registration, and session-reset cleanup. The foreground timeout budget begins before process creation, but shell-owned creation still resolves and terminates any eventual handle before reporting timeout. Class creation raises TypeError when final MRO resolution replaces execute(), so direct and mixin-based legacy overrides fail fast instead of silently bypassing lifecycle ownership; migrate their process creation into _create_process(). A wait callback must not report natural completion while owned descendants remain, and a kill callback must not return until backend execution is confirmed terminated; raising preserves the handle for a later reset retry. Backends must retain a stable execution identity through termination: a POSIX numeric PGID is no longer an ownership handle after its leader is reaped, so residual-group cleanup requires a live guardian or an equivalent platform-owned primitive.

Development

This package is maintained as a workspace member in ya-mono.

uv run python -m pytest packages/ya-agent-environment/tests -vv
uv run python -m pyright
uv build --package ya-agent-environment -o dist

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ya_agent_environment-1.20.1.tar.gz (57.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ya_agent_environment-1.20.1-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

Details for the file ya_agent_environment-1.20.1.tar.gz.

File metadata

  • Download URL: ya_agent_environment-1.20.1.tar.gz
  • Upload date:
  • Size: 57.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ya_agent_environment-1.20.1.tar.gz
Algorithm Hash digest
SHA256 60c2f11be5000f1bf30299fc2937c34d2975445d79075a3b28ffc2a9bc4f3b39
MD5 df18e9f70de4cd61dc4e0c998a381d63
BLAKE2b-256 268228ea243da98975b3fc608ded37a884f4ec48295c90156b10a61f4ef09509

See more details on using hashes here.

File details

Details for the file ya_agent_environment-1.20.1-py3-none-any.whl.

File metadata

  • Download URL: ya_agent_environment-1.20.1-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ya_agent_environment-1.20.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f558ca396a4e2f14e634fef1b6a2e1a302c8d06cffff768d0973acf48636e442
MD5 c3451dd845735d577f6c05bb7ebed694
BLAKE2b-256 888135fdf27f7bc67b3a5b6b905854aa17729f0065c8cc2bed2122ecd299290b

See more details on using hashes here.

Release history Release notifications | RSS feed

2.10.0

2 files

2.9.0

2 files

2.8.3

2 files

2.8.2

2 files

2.8.1

2 files

2.8.0

2 files

2.7.3

2 files

2.7.2

2 files

2.7.1

2 files

2.7.0

2 files

2.6.0

2 files

2.5.1

2 files

2.5.0

2 files

2.4.2

2 files

2.4.1

2 files

2.4.0

2 files

2.3.2

2 files

2.3.1

2 files

2.3.0

2 files

2.2.0

2 files

2.1.0

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.21.0

2 files

This release

1.20.1 This release

2 files

1.20.0

2 files

1.19.2

2 files

1.19.1

2 files

1.19.0

2 files

1.18.0

2 files

1.17.1

2 files

1.17.0

2 files

1.16.3

2 files

1.16.2

2 files

1.16.1

2 files

1.16.0

2 files

1.15.0

2 files

1.14.2

2 files

1.14.1

2 files

1.14.0

2 files

1.13.1

2 files

1.13.0

2 files

1.12.3

2 files

1.12.2

2 files

1.12.1

2 files

1.12.0

2 files

1.11.2

2 files

1.11.1

2 files

1.11.0

2 files

1.10.4

2 files

1.10.3

2 files

1.10.2

2 files

1.10.1

2 files

1.10.0

2 files

1.9.1

2 files

1.9.0

2 files

1.8.0

2 files

1.7.2

2 files

1.7.1

2 files

1.7.0

2 files

1.6.0

2 files

1.5.1

2 files

1.5.0

2 files

1.4.4

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.0

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.93.0

2 files

0.92.0

2 files

0.91.2

2 files

0.91.1

2 files

0.91.0

2 files

0.90.0

2 files

0.89.0

2 files

0.88.0

2 files

0.87.1

2 files

0.87.0

2 files

0.86.0

2 files

0.85.5

2 files

0.85.4

2 files

0.85.3

2 files

0.85.2

2 files

0.85.1

2 files

0.85.0

2 files

0.84.1

2 files

0.84.0

2 files

0.83.0

2 files

0.82.0

2 files

0.81.0

2 files

0.80.3

2 files

0.80.2

2 files

0.80.1

2 files

0.80.0

2 files

0.79.0

2 files

0.78.0

2 files

0.77.0

2 files

0.76.2

2 files

0.76.1

2 files

0.76.0

2 files

0.75.0

2 files

0.74.1

2 files

0.74.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page