From 954d39271c6f58fb8a7829d8b2644de79fc1a037 Mon Sep 17 00:00:00 2001 From: Vlado Djerek Date: Tue, 25 Nov 2025 21:30:59 +0100 Subject: [PATCH 1/5] add snippet to readme --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 051b350c..f6c0fa6f 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,36 @@ spec: This will create a new Sandbox named `my-sandbox` running the image you specify. You can then access the Sandbox using its stable hostname, `my-sandbox`. +For a more programatic approach you can use the [SDK](github.com/kubernetes-sigs/agent-sandbox/blob/main/clients/python/agentic-sandbox-client/README.md) like the following: +```python +from agentic_sandbox import Sandbox + +# The SDK abstracts all YAML into a simple context manager +try: + with Sandbox( + template_name="python-runtime-template", + namespace="ai-agents" + ) as sandbox: + + print("--- Sandbox is Ready! ---") + + # 1. Run a command inside the secure sandbox + result = sandbox.run("echo 'Hello from inside the sandbox!'") + print(f"Stdout: {result.stdout.strip()}") + + # 2. Write and read files + sandbox.write("test.txt", "This is a test file.") + content = sandbox.read("test.txt").decode('utf-8') + print(f"Read content: {content}") + +except Exception as e: + print(f"An error occurred: {e}") + +# The 'with' block automatically handles cleanup +print("--- Sandbox Cleaned Up ---") +``` + + For more complex examples, including how to use the extensions, please see the [examples/](examples/) and [extensions/examples/](extensions/examples/) directories. ## Motivation From 948ae415702ca840c41f921c19ab162aca818c97 Mon Sep 17 00:00:00 2001 From: Vlado Djerek Date: Tue, 25 Nov 2025 21:31:49 +0100 Subject: [PATCH 2/5] force https link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6c0fa6f..838c9665 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ spec: This will create a new Sandbox named `my-sandbox` running the image you specify. You can then access the Sandbox using its stable hostname, `my-sandbox`. -For a more programatic approach you can use the [SDK](github.com/kubernetes-sigs/agent-sandbox/blob/main/clients/python/agentic-sandbox-client/README.md) like the following: +For a more programatic approach you can use the [SDK](https://github.com/kubernetes-sigs/agent-sandbox/blob/main/clients/python/agentic-sandbox-client/README.md) like the following: ```python from agentic_sandbox import Sandbox From e05ae8fc9f9a15549430f92294ae8c519b7314dd Mon Sep 17 00:00:00 2001 From: Artur Kamalov Date: Mon, 1 Dec 2025 17:00:25 +0100 Subject: [PATCH 3/5] make links to examples in readme refer to github --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 838c9665..e5727184 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ print("--- Sandbox Cleaned Up ---") ``` -For more complex examples, including how to use the extensions, please see the [examples/](examples/) and [extensions/examples/](extensions/examples/) directories. +For more complex examples, including how to use the extensions, please see the [examples/](https://github.com/kubernetes-sigs/agent-sandbox/blob/main/examples/) and [extensions/examples/](https://github.com/kubernetes-sigs/agent-sandbox/blob/main/extensions/examples/) directories. ## Motivation From e3f0121dd5b1fc885e8e7266324ced6b13041f3e Mon Sep 17 00:00:00 2001 From: Artur Kamalov Date: Mon, 15 Dec 2025 16:16:03 +0100 Subject: [PATCH 4/5] small fixes to the sandbox code snippet in README.md --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e5727184..190edea0 100644 --- a/README.md +++ b/README.md @@ -59,28 +59,32 @@ spec: This will create a new Sandbox named `my-sandbox` running the image you specify. You can then access the Sandbox using its stable hostname, `my-sandbox`. -For a more programatic approach you can use the [SDK](https://github.com/kubernetes-sigs/agent-sandbox/blob/main/clients/python/agentic-sandbox-client/README.md) like the following: +For a more programmatic approach you can use the [SDK](clients/python/agentic-sandbox-client/README.md) like the following: ```python from agentic_sandbox import Sandbox # The SDK abstracts all YAML into a simple context manager try: with Sandbox( + # Using the template from the agent-sangbox repo. Make sure to specify your own if needed. template_name="python-runtime-template", - namespace="ai-agents" + namespace="default" ) as sandbox: - - print("--- Sandbox is Ready! ---") - # 1. Run a command inside the secure sandbox result = sandbox.run("echo 'Hello from inside the sandbox!'") + + if result.exit_code != 0: + print("The command inside the sandbox has failed.") + print(f"Stderr: {result.stderr.strip()}") + print(f"Stdout: {result.stdout.strip()}") # 2. Write and read files - sandbox.write("test.txt", "This is a test file.") + sandbox.write("test.txt", "This is a test file.".encode('utf-8')) content = sandbox.read("test.txt").decode('utf-8') print(f"Read content: {content}") +# Just catching everyting to keep the example short except Exception as e: print(f"An error occurred: {e}") @@ -89,7 +93,7 @@ print("--- Sandbox Cleaned Up ---") ``` -For more complex examples, including how to use the extensions, please see the [examples/](https://github.com/kubernetes-sigs/agent-sandbox/blob/main/examples/) and [extensions/examples/](https://github.com/kubernetes-sigs/agent-sandbox/blob/main/extensions/examples/) directories. +For more complex examples, including how to use the extensions, please see the [examples/](examples/) and [extensions/examples/](extensions/examples/) directories. ## Motivation From 1748d467b388e332d622e0485abd1a4ce2b2017e Mon Sep 17 00:00:00 2001 From: Artur Kamalov Date: Mon, 22 Dec 2025 09:12:39 +0100 Subject: [PATCH 5/5] remove the code snippet and keep only the link to client --- README.md | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/README.md b/README.md index 190edea0..f8235708 100644 --- a/README.md +++ b/README.md @@ -59,39 +59,7 @@ spec: This will create a new Sandbox named `my-sandbox` running the image you specify. You can then access the Sandbox using its stable hostname, `my-sandbox`. -For a more programmatic approach you can use the [SDK](clients/python/agentic-sandbox-client/README.md) like the following: -```python -from agentic_sandbox import Sandbox - -# The SDK abstracts all YAML into a simple context manager -try: - with Sandbox( - # Using the template from the agent-sangbox repo. Make sure to specify your own if needed. - template_name="python-runtime-template", - namespace="default" - ) as sandbox: - # 1. Run a command inside the secure sandbox - result = sandbox.run("echo 'Hello from inside the sandbox!'") - - if result.exit_code != 0: - print("The command inside the sandbox has failed.") - print(f"Stderr: {result.stderr.strip()}") - - print(f"Stdout: {result.stdout.strip()}") - - # 2. Write and read files - sandbox.write("test.txt", "This is a test file.".encode('utf-8')) - content = sandbox.read("test.txt").decode('utf-8') - print(f"Read content: {content}") - -# Just catching everyting to keep the example short -except Exception as e: - print(f"An error occurred: {e}") - -# The 'with' block automatically handles cleanup -print("--- Sandbox Cleaned Up ---") -``` - +To interact with the Sandbox from code, you can use the [SDK client](clients/python/agentic-sandbox-client/README.md). For more complex examples, including how to use the extensions, please see the [examples/](examples/) and [extensions/examples/](extensions/examples/) directories.