Skip to main content

agent-framework-kosa8

kosa8: Zero Trust cybersecurity infrastructure for AI agents. Every agent sealed in its own microVM. Every action verified and recorded.

Run a Microsoft Agent Framework agent's shell commands, Python code and file edits in a kosa8 Cloud microVM sandbox instead of on your machine.

Kosa8ShellTool implements Agent Framework's ShellExecutor protocol (from agent-framework-tools, the package behind LocalShellTool and DockerShellTool) on a kosa8 sandbox. Its as_function() returns the same kind of kind="shell" FunctionTool the built-in shell tools do, so it drops in wherever they go. Tested against agent-framework-core 1.26.0 and agent-framework-tools 1.0.0b261112 (Python).

Install

pip install agent-framework-kosa8

agent-framework-tools is still a beta on PyPI; this package asks for it by version, so pip installs it without --pre.

Set KOSA8_API_KEY to a kosa8 Cloud API key (create one at app.kosa8.com, or run kosa8 login). The Starter plan is free, no card. Plans are at kosa8.com/pricing.

Example

import asyncio

from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient
from agent_framework_kosa8 import Kosa8ShellTool


async def main() -> None:
    client = OpenAIChatClient(model="gpt-5.4-nano")
    async with Kosa8ShellTool(ttl_s=3600) as shell:
        agent = Agent(
            client=client,
            instructions="You work in a Linux sandbox.",
            tools=[client.get_shell_tool(func=shell.as_function())],
        )
        result = await agent.run("Write fizzbuzz.py in /workspace, run it and show the output.")
        print(result.text)


asyncio.run(main())

async with creates the sandbox and deletes it on the way out. Without it, the sandbox is created on the first command and deleted by await shell.close().

Any chat client works: pass shell.as_function() in tools=[...] directly when the provider has no get_shell_tool.

More tools on the same sandbox

agent = Agent(client=client, tools=shell.as_tools())
Tool What it does
run_shell (as_function()) one command under sh -c in workdir; returns stdout, stderr and the exit code
execute_python (as_code_function()) a Python 3 program, run with python3 in workdir
read_file, write_file, list_files (as_file_functions()) the kosa8 files API, no shell

You can also call the sandbox from your own code: await shell.run("make test") returns the framework's ShellResult; run_python, read_file, write_file, list_files and remove_file work the same way. shell.sandbox is the kosa8.AsyncCloudSandbox for anything else kosa8 does (previews, snapshots, checkpoints, sleep).

Approval

The microVM is the boundary: commands never run on your machine, so the tools default to approval_mode="never_require". Pass approval_mode="always_require" to have a person approve each call through the framework's user_input_requests. ShellPolicy allow and deny lists and the on_command audit hook work as in the built-in shell tools; like there, the policy is a pre-filter, not a boundary.

Options

Option Default
sandbox_id none attach to an existing sandbox instead of creating one
template "python" kosa8 template (Python 3.12 and a POSIX shell)
image none OCI image, instead of a template
size template size vCPU x GiB: 0.25x0.5, 0.5x1, 1x2, 2x4, 4x8, 8x16 or 16x32
region chosen by kosa8 us-ash1, eu-hel1, us or eu
ttl_s none lifetime: kosa8 deletes the sandbox this many seconds after it starts, even if close() never runs. Recommended
sleep_after_s account setting idle seconds before the sandbox sleeps; it wakes on its next command
persistent off one long-lived container, so the whole filesystem and background processes last between commands
env none environment for every command, sent with each command and never stored on the sandbox
internet on False turns off the open internet
egress_allow, egress_presets none hosts, or named host sets such as pypi, the sandbox may reach
secrets none names of org secrets the sandbox holds (set in the kosa8 dashboard or CLI)
labels, name none stored on the sandbox
workdir /workspace where commands start; relative file paths resolve against it
on_close "delete" ("keep" when attached) what close() does: "delete", "sleep" or "keep"
policy allow all a ShellPolicy checked before each command
timeout 30 s per-command timeout, enforced inside the sandbox; None disables
max_stdout_bytes, max_stderr_bytes 64 KiB each output returned to the model; the head and tail are kept
approval_mode "never_require" approval for every vended tool
on_command none audit hook called with each command
api_key, base_url, cloud KOSA8_API_KEY, https://api.kosa8.com or pass a ready kosa8.AsyncCloud (yours to close)

Limits

  • Each command runs in a fresh sh in workdir: files and installed packages persist, cd and shell variables do not (like the built-in tools' stateless mode). There is no persistent-shell mode.
  • Without persistent=True, only /workspace is promised to persist between commands.
  • A timed-out command returns timed_out=True and exit code 124, with its whole process group killed in the sandbox.
  • One tool instance is one sandbox: give each conversation or user its own and close it when done.

How commands run

Each command is started by a small POSIX sh wrapper in a process group of its own, with stdin at EOF and its output redirected to files. A watchdog inside the sandbox enforces timeout; cancelling the call kills the command too. The client waits in polls of at most 50 s, so a command can run longer than one 90 s kosa8 request, and output comes back base64-encoded, so any bytes survive.

Tests

uv run --group dev pytest            # unit tests against a mocked kosa8 API
KOSA8_API_KEY=... uv run --group dev pytest tests/test_live.py   # live tier on kosa8 Cloud
uv run --group dev ruff check .

The live tier gives each sandbox a 10-minute ttl_s and a label, deletes it, and checks it is gone. It also drives a real Agent Framework Agent with a scripted chat client, so no model is called.

License

MIT. kosa8 is not affiliated with Microsoft.

Metadata

Release files for agent-framework-kosa8 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-framework-kosa8 0.1.0
File Size Uploaded Provenance Actions
agent_framework_kosa8-0.1.0.tar.gz 23.7 kB Without provenance Details for agent_framework_kosa8-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agent-framework-kosa8 0.1.0
File Interpreter ABI Platform Actions
agent_framework_kosa8-0.1.0-py3-none-any.whl Python 3 none any Details for agent_framework_kosa8-0.1.0-py3-none-any.whl

Total release size: 41.5 kB

Release files / agent_framework_kosa8-0.1.0.tar.gz

Download URL agent_framework_kosa8-0.1.0.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1493dfef85d78cb35e6fa3ce681c5d693e59262173e8718637559f244d44ecbf
BLAKE2b-256 checksum
How to use checksums
31e2810e9faf1fab165364a7f2fa12941a2599aab249543afe9e74c8d2d8163d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / agent_framework_kosa8-0.1.0-py3-none-any.whl

Download URL agent_framework_kosa8-0.1.0-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3500cea01201548d5272fde3efde94279df8931adade9bce69322b201f801b07
BLAKE2b-256 checksum
How to use checksums
7b3ff0b247ee8e4de90245815fc1c7abae75bc9170e63d57e84400a4b429396f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Security for agent-framework-kosa8 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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