Skip to content

feat(langgraph): add OpenShell sandbox integration for react_agent#269

Open
rrbanda wants to merge 2 commits into
red-hat-data-services:mainfrom
rrbanda:feature/langgraph-react-openshell-integration
Open

feat(langgraph): add OpenShell sandbox integration for react_agent#269
rrbanda wants to merge 2 commits into
red-hat-data-services:mainfrom
rrbanda:feature/langgraph-react-openshell-integration

Conversation

@rrbanda

@rrbanda rrbanda commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

TL;DR

Adds OpenShell support for the LangGraph ReAct template with one new BYOC container definition and one runbook. This does not change the existing Helm/OpenShift deployment path for react_agent.

Reviewer Guide

Review in this order:

  1. agents/langgraph/templates/react_agent/Containerfile.openshell
  2. agents/langgraph/templates/react_agent/OPENSHELL.md

The diff is intentionally small: one file defines the image/runtime adaptation, and the second documents build, launch, policy, and verification steps.

Summary

  • Add Containerfile.openshell for running the LangGraph ReAct agent inside an NVIDIA OpenShell sandbox
  • Add OPENSHELL.md with build/run instructions, network policy configuration, and verification steps

Motivation

None of the LangGraph templates currently include an OpenShell BYOC path. Adding it to react_agent provides the first example on the most mature LangGraph template.

Key Design Decisions

  • Use the same pinned UBI9 Python 3.12 base digest as the standard Dockerfile
  • Install iproute and nftables for OpenShell network namespace support and optional bypass detection
  • Pre-install components/auth before the main package so the existing tool.uv.sources path does not fail from /sandbox
  • Run Python dependency installs as UID 1001 so installed files are owned by the runtime user
  • Use explicit cleanup commands in the docs so the build snippet is safe to paste into an interactive shell

Reviewer Focus

  • Containerfile.openshell: verify the /sandbox layout, dependency install order, and non-root runtime setup
  • OPENSHELL.md: verify the build/run flow and policy example against current OpenShell CLI behavior
  • Open question: the example command uses direct -e environment injection in openshell sandbox create; if we want provider-backed secret handling, that should be documented explicitly with openshell provider create and --provider rather than implied by the current wording

Test Plan

Validated manually on OpenShift 4.18 with OpenShell v0.0.80 gateway:

  • Image builds successfully via oc start-build
  • GET /health returns {\"status\":\"healthy\",\"agent_initialized\":true}
  • GET /images/rh_logo.svg returns 200
  • POST /chat/completions works end-to-end with gemini/models/gemini-2.5-flash via a Llama Stack endpoint

No automated tests were added because this PR introduces an alternate container/deployment path plus documentation, and validation was performed as an in-cluster manual run.

@rrbanda
rrbanda requested a review from a team as a code owner July 16, 2026 16:35
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@kami619, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 20 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 39dd5223-978b-49f0-830d-309c1797e9ae

📥 Commits

Reviewing files that changed from the base of the PR and between bd3f453 and 7fb56fa.

📒 Files selected for processing (2)
  • agents/langgraph/templates/react_agent/Containerfile.openshell
  • agents/langgraph/templates/react_agent/OPENSHELL.md
📝 Walkthrough

Walkthrough

Adds an OpenShell BYOC container definition for the LangGraph ReAct agent and documentation covering image creation, sandbox startup, environment injection, endpoint verification, network policy, and cleanup.

Changes

OpenShell ReAct agent deployment

Layer / File(s) Summary
Container build and runtime setup
agents/langgraph/templates/react_agent/Containerfile.openshell
Builds a Python 3.12 UBI9 image, installs OpenShell and application dependencies, copies runtime assets, and configures non-root uvicorn execution on port 8080.
Sandbox deployment and verification
agents/langgraph/templates/react_agent/OPENSHELL.md
Documents image publication, sandbox creation, environment injection, port forwarding, health and chat checks, network egress policy, cleanup, and runtime behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Podman
  participant OpenShell
  participant Uvicorn
  participant LLM_API
  Podman->>OpenShell: Push BYOC container image
  OpenShell->>Uvicorn: Create sandbox and start uvicorn
  OpenShell->>Uvicorn: Forward port and inject environment
  Uvicorn->>LLM_API: Send chat completion request
  LLM_API-->>Uvicorn: Return model response
  Uvicorn-->>OpenShell: Return health or chat response
Loading

Suggested reviewers: andrewdonheiser

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the OpenShell sandbox integration added for the react_agent template.
Description check ✅ Passed The description accurately describes the new Containerfile and runbook for OpenShell support.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kami619 kami619 self-assigned this Jul 17, 2026
@kami619
kami619 force-pushed the feature/langgraph-react-openshell-integration branch from cedec00 to de369f7 Compare July 17, 2026 01:28

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
agents/langgraph/templates/react_agent/OPENSHELL.md (1)

65-81: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Make the policy creation copy-pasteable.

The snippet shows the YAML content and then a command that reads policy.yaml, but doesn't explicitly instruct the user to save the file. Consolidating this into a single cat <<EOF block ensures it can be executed seamlessly in one go.

♻️ Proposed fix
-The ReAct agent only needs outbound access to the configured LLM endpoint. Apply a restrictive policy:
-
-```yaml
-sandbox:
-  network:
-    egress:
-      - host: "vllm-svc.my-ns.svc.cluster.local"
-        port: 8000
-        methods: ["POST"]
-        paths:
-          - "/v1/chat/completions"
-          - "/v1/completions"
-```
-
-```bash
+The ReAct agent only needs outbound access to the configured LLM endpoint. Apply a restrictive policy by saving it and applying it:
+
+```bash
+cat <<EOF > policy.yaml
+sandbox:
+  network:
+    egress:
+      - host: "vllm-svc.my-ns.svc.cluster.local"
+        port: 8000
+        methods: ["POST"]
+        paths:
+          - "/v1/chat/completions"
+          - "/v1/completions"
+EOF
+
 openshell policy set langgraph-agent --policy policy.yaml --wait

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @agents/langgraph/templates/react_agent/OPENSHELL.md around lines 65 - 81,
Make the policy setup in the ReAct agent documentation copy-pasteable by
replacing the separate YAML and shell blocks with one shell block that writes
the policy via a heredoc to policy.yaml, then runs openshell policy set using
that file. Preserve the existing policy contents and command.


</details>

<!-- cr-comment:v1:553933c9a249f695f615b170 -->

</blockquote></details>

</blockquote></details>

<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @agents/langgraph/templates/react_agent/Containerfile.openshell:

  • Around line 32-51: Switch to USER 1001 before both uv pip install commands in
    the Containerfile, including the auth installation and the subsequent
    tracing-extra installation, so all installed files are owned by the runtime
    user; keep the dependency-copy and pyproject preparation steps ordered so the
    installs still resolve correctly.

In @agents/langgraph/templates/react_agent/OPENSHELL.md:

  • Around line 21-25: Remove the EXIT trap from the interactive shell snippet in
    the OpenShell instructions and add an explicit cleanup command after the podman
    build and push commands, preserving the removal of ./images and ./components.

Nitpick comments:
In @agents/langgraph/templates/react_agent/OPENSHELL.md:

  • Around line 65-81: Make the policy setup in the ReAct agent documentation
    copy-pasteable by replacing the separate YAML and shell blocks with one shell
    block that writes the policy via a heredoc to policy.yaml, then runs openshell
    policy set using that file. Preserve the existing policy contents and command.

</details>

<details>
<summary>🪄 Autofix (Beta)</summary>

Fix all unresolved CodeRabbit comments on this PR:

- [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)
- [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes

</details>

---

<details>
<summary>ℹ️ Review info</summary>

<details>
<summary>⚙️ Run configuration</summary>

**Configuration used**: Organization UI

**Review profile**: CHILL

**Plan**: Enterprise

**Run ID**: `404d7d1b-7c21-452b-8141-d058c1880f57`

</details>

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 6b6bbf92ac79b077fc09c35d12707904cbb99083 and de369f744d6f4179e88c115b5e8269e2f8ef6be0.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `agents/langgraph/templates/react_agent/Containerfile.openshell`
* `agents/langgraph/templates/react_agent/OPENSHELL.md`

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread agents/langgraph/templates/react_agent/Containerfile.openshell Outdated
Comment thread agents/langgraph/templates/react_agent/OPENSHELL.md Outdated
@kami619

kami619 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@rrbanda

Review Findings:

• Medium: agents/langgraph/templates/react_agent/OPENSHELL.md misdescribes -e as provider-backed secret injection. The new guide says -e "injects environment variables via OpenShell providers (never
written to disk)" and the comparison table repeats that mapping, but OpenShell’s current CLI docs distinguish sandbox create -e/--env from provider-backed credentials attached with --provider. That
means the example command is documenting stronger credential-handling semantics than it actually uses, and anyone trying to follow the provider model will be sent down the wrong path. This should
either switch to openshell provider create ... plus openshell sandbox create --provider ..., or be reworded to describe -e as direct env injection.

• Low: agents/langgraph/templates/react_agent/Containerfile.openshell still carries the old trap 'rm -rf ./images ./components' EXIT build snippet in its header comment, even though OPENSHELL.md was
updated to explicit cleanup after the follow-up review. That leaves two conflicting build instructions in the same PR and preserves the exact interactive-shell footgun the markdown guide was trying to
remove.

@kami619
kami619 force-pushed the feature/langgraph-react-openshell-integration branch from bd3f453 to bbcf2ee Compare July 21, 2026 05:18
@kami619

kami619 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@rrbanda please take a look at my previous comment at your convenience.

rrbanda added 2 commits July 22, 2026 15:19
Add Containerfile.openshell and deployment documentation for running
the LangGraph ReAct agent inside an NVIDIA OpenShell sandbox with
policy-enforced network isolation and filesystem constraints.

Follows the official BYOC pattern from NVIDIA/OpenShell. Handles the
components/auth path dependency by installing it separately before the
main package (avoids relative path resolution issues from /sandbox).

Tested on OpenShift 4.18 cluster:
- Image builds successfully via oc start-build (134 packages)
- /health returns {"status":"healthy","agent_initialized":true}
- /images/rh_logo.svg returns 200 (playground assets served)
- /chat/completions works end-to-end with gemini-2.5-flash via
  Llama Stack endpoint
- Move USER 1001 before pip install so packages are owned by the
  runtime user (avoids __pycache__ permission issues)
- Replace trap EXIT with explicit rm -rf in build docs (trap doesn't
  fire in interactive shells until terminal closes)
@kami619
kami619 force-pushed the feature/langgraph-react-openshell-integration branch from bbcf2ee to 7fb56fa Compare July 22, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants