feat(policies): add Ollama local inference preset#1047
feat(policies): add Ollama local inference preset#1047rktm0604 wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
📝 WalkthroughWalkthroughA new policy preset configuration file is added to enable sandboxed agent egress permissions for accessing a locally running Ollama REST endpoint on port 11434 with GET and POST methods. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@nemoclaw-blueprint/policies/presets/ollama.yaml`:
- Around line 31-32: Update the failing test expectations to account for the new
"ollama" preset: change the assertion that checks presets.length from 9 to 10
(the variable referenced is presets.length) and add "ollama" to the expected
names array used in the test (the array referenced around the expected names
variable or literal in the test that currently lists preset names).
- Around line 38-62: Replace the top-level "egress:" key with
"network_policies:" and indent the existing Ollama rules under that key so the
preset conforms to the required schema (update the YAML in
nemoclaw-blueprint/policies/presets/ollama.yaml: change egress ->
network_policies and move the nested host/ports/methods/binaries/description
under the new key). Then update the tests that assert preset counts and names to
include the new "ollama" preset: adjust the expectation from 9 to 10 for
policies.listPresets() and add "ollama" to the expected names array used in the
name-check assertions (tests that call policies.listPresets() and
policies.loadPreset()).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a167c5ff-d608-4ee7-960e-cb699c0d4687
📒 Files selected for processing (1)
nemoclaw-blueprint/policies/presets/ollama.yaml
| version: "1" | ||
| name: ollama |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Verify the hard-coded test assertions that need updating
echo "=== Current hard-coded preset count check ==="
rg -n "expect\(presets\.length\)\.toBe\(" test/policies.test.js
echo -e "\n=== Current expected preset names ==="
rg -A 12 "const expected = \[" test/policies.test.js | head -n 15Repository: NVIDIA/NemoClaw
Length of output: 428
🏁 Script executed:
#!/bin/bash
# Check if ollama.yaml exists in the presets directory
find . -name "ollama.yaml" -o -name "ollama.yml"
# List all .yaml files in policies/presets to see what will be discovered
echo -e "\n=== All preset files in policies/presets ==="
ls -1 nemoclaw-blueprint/policies/presets/ | grep -E '\.(yaml|yml)$'
# Show the listPresets function to understand auto-discovery
echo -e "\n=== ListPresets function implementation ==="
rg -A 10 "listPresets" test/policies.test.js | head -n 20Repository: NVIDIA/NemoClaw
Length of output: 877
Update test assertions for new preset.
The test file test/policies.test.js has hard-coded assertions that will fail with the new ollama preset:
- Line 12:
expect(presets.length).toBe(9);must be updated to10 - Lines 27-37: Add "ollama" to the expected names array
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@nemoclaw-blueprint/policies/presets/ollama.yaml` around lines 31 - 32, Update
the failing test expectations to account for the new "ollama" preset: change the
assertion that checks presets.length from 9 to 10 (the variable referenced is
presets.length) and add "ollama" to the expected names array used in the test
(the array referenced around the expected names variable or literal in the test
that currently lists preset names).
| egress: | ||
| # Ollama REST API — local inference endpoint | ||
| - host: host-gateway # resolves to the Docker host from inside sandbox | ||
| ports: [11434] | ||
| methods: [GET, POST] | ||
| binaries: [openclaw] | ||
| description: > | ||
| Ollama local inference API. GET /api/tags lists available models. | ||
| POST /api/generate and POST /api/chat run inference. | ||
|
|
||
| # Optional: Ollama model registry (only needed if agent pulls models) | ||
| # Uncomment if you want the agent to pull models autonomously. | ||
| # Recommendation: pull models manually before sandboxing the agent. | ||
| # | ||
| # - host: registry.ollama.ai | ||
| # ports: [443] | ||
| # methods: [GET] | ||
| # binaries: [openclaw] | ||
| # description: Ollama model registry for pulling models inside sandbox. | ||
| # | ||
| # - host: ollama.com | ||
| # ports: [443] | ||
| # methods: [GET] | ||
| # binaries: [openclaw] | ||
| # description: Ollama website and model library. |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check the structure of other preset files to confirm the expected schema
echo "=== Checking for network_policies in existing presets ==="
rg -n "^network_policies:" nemoclaw-blueprint/policies/presets/ --type yaml
echo -e "\n=== Sample structure from discord preset ==="
head -n 50 nemoclaw-blueprint/policies/presets/discord.yaml | rg -A 10 "^network_policies:"
echo -e "\n=== Sample structure from pypi preset ==="
head -n 50 nemoclaw-blueprint/policies/presets/pypi.yaml | rg -A 10 "^network_policies:"Repository: NVIDIA/NemoClaw
Length of output: 1270
🏁 Script executed:
#!/bin/bash
# Check actual ollama.yaml content
echo "=== Actual ollama.yaml content ==="
cat nemoclaw-blueprint/policies/presets/ollama.yaml
echo -e "\n=== Full discord.yaml for structure comparison ==="
cat nemoclaw-blueprint/policies/presets/discord.yaml
echo -e "\n=== Full pypi.yaml for structure comparison ==="
cat nemoclaw-blueprint/policies/presets/pypi.yamlRepository: NVIDIA/NemoClaw
Length of output: 4494
🏁 Script executed:
#!/bin/bash
# Check the test file to see what validations are performed
echo "=== Checking test validations ==="
rg -n "network_policies" nemoclaw-blueprint/test/ --type js -A 5 -B 5
echo -e "\n=== Looking for schema validation or parsing in tests ==="
rg -n "network_policies|preset|egress" nemoclaw-blueprint/test/policies.test.js -A 2 -B 2Repository: NVIDIA/NemoClaw
Length of output: 314
🏁 Script executed:
#!/bin/bash
# Find test files
echo "=== Searching for test files ==="
find . -name "*.test.js" -o -name "*.test.ts" -o -name "*test*" -type f | grep -i test | head -20
echo -e "\n=== Searching for policies test ==="
find . -name "*policies*test*" -o -name "*test*policies*" | head -10
echo -e "\n=== Checking repository structure ==="
ls -la | head -20Repository: NVIDIA/NemoClaw
Length of output: 2158
🏁 Script executed:
#!/bin/bash
# Read the test file to understand validations
echo "=== Content of test/policies.test.js ==="
cat test/policies.test.jsRepository: NVIDIA/NemoClaw
Length of output: 8295
🏁 Script executed:
#!/bin/bash
# Find and examine the policies implementation
echo "=== Finding policies implementation ==="
find . -name "policies.js" -o -name "policies.ts" | grep -v test
echo -e "\n=== Reading policies implementation ==="
cat bin/lib/policies.js 2>/dev/null || cat bin/lib/policies.ts 2>/dev/null || find . -path "*/bin/*" -name "policies*" -exec cat {} \;Repository: NVIDIA/NemoClaw
Length of output: 7053
Critical: Missing network_policies: wrapper and incomplete test compatibility.
The preset structure is missing the required network_policies: top-level key. According to the test suite, every preset must have a network_policies: section. Additionally, the test expects exactly 9 presets with specific names, and "ollama" is not in that list.
Impact:
- Test at
test/policies.test.jsline 113 will fail:
it("every preset has network_policies section", () => {
for (const p of policies.listPresets()) {
const content = policies.loadPreset(p.name);
expect(content.includes("network_policies:")).toBeTruthy();
}
});- Test at line 11 expects exactly 9 presets but ollama.yaml will make it 10
- Test at lines 27-37 expects specific preset names excluding "ollama"
Fix the schema by replacing egress: with network_policies: and indenting all rules accordingly. Additionally, update test/policies.test.js lines 11 and 27-37 to include "ollama" in the expected presets count (10) and names list.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@nemoclaw-blueprint/policies/presets/ollama.yaml` around lines 38 - 62,
Replace the top-level "egress:" key with "network_policies:" and indent the
existing Ollama rules under that key so the preset conforms to the required
schema (update the YAML in nemoclaw-blueprint/policies/presets/ollama.yaml:
change egress -> network_policies and move the nested
host/ports/methods/binaries/description under the new key). Then update the
tests that assert preset counts and names to include the new "ollama" preset:
adjust the expectation from 9 to 10 for policies.listPresets() and add "ollama"
to the expected names array used in the name-check assertions (tests that call
policies.listPresets() and policies.loadPreset()).
Summary
Related Issue
Changes
Type of Change
Testing
npx prek run --all-filespasses (or equivalentlymake check).npm testpasses.make docsbuilds without warnings. (for doc-only changes)Checklist
General
Code Changes
npx prek run --all-filesauto-fixes formatting (ormake formatfor targeted runs).Doc Changes
update-docsagent skill to draft changes while complying with the style guide. For example, prompt your agent with "/update-docscatch up the docs for the new changes I made in this PR."Summary by CodeRabbit