Skip to content

fix: resolve sandbox name from registry in Telegram bridge#96

Closed
WuKongAI-CMU wants to merge 3 commits intoNVIDIA:mainfrom
WuKongAI-CMU:fix/telegram-sandbox-name
Closed

fix: resolve sandbox name from registry in Telegram bridge#96
WuKongAI-CMU wants to merge 3 commits intoNVIDIA:mainfrom
WuKongAI-CMU:fix/telegram-sandbox-name

Conversation

@WuKongAI-CMU
Copy link
Copy Markdown
Contributor

@WuKongAI-CMU WuKongAI-CMU commented Mar 17, 2026

Summary

  • Telegram bridge defaulted to sandbox name "nemoclaw" while onboard creates "my-assistant" by default, which leads to "sandbox not found" failures
  • Resolve the sandbox name from the NemoClaw registry first, with SANDBOX_NAME still supported as an explicit override
  • Keep the fallback aligned with the onboarding default ("my-assistant")
  • Preserve the newer resolveOpenshell() path handling from current main
  • Add a regression test that locks the sandbox-name resolution behavior in scripts/telegram-bridge.js

Fixes #93

Root cause

The Telegram bridge assumed a default sandbox name of nemoclaw, but the onboarding flow creates my-assistant unless the user picks another name. On a default install, the bridge would therefore target the wrong sandbox.

Test plan

  • node --test test/telegram-bridge-sandbox-name.test.js
  • npm test

Summary by CodeRabbit

  • New Features

    • Sandbox selection now prefers an explicit environment setting, falls back to a configured registry default, and finally uses a built-in fallback—improving reliability while keeping SSH target and startup banner text unchanged.
  • Tests

    • Added tests that verify the resolution order (env → registry → fallback) and behavior when the registry is unavailable to ensure consistent startup naming.

@jasonplumb
Copy link
Copy Markdown

Once merged in, do we have to recreate our sandbox again?

@maximgeerinck
Copy link
Copy Markdown

Once merged in, do we have to recreate our sandbox again?

merged it in manually, restarted with nemoclaw stop and nemoclaw start and it worked!

@jasonplumb
Copy link
Copy Markdown

Thanks @maximgeerinck. Hopefully the PR will be merged into NVIDIA:main as I suspect nearly all users are facing the issue

@stevef1uk
Copy link
Copy Markdown

Yes! Replacing my telegram-bridge.ts with this: and stopping & restarting NemoClaw worked for me. Location: /lib/node_modules/nemoclaw/scripts

Thanks @WuKongAI-CMU

@WuKongAI-CMU WuKongAI-CMU force-pushed the fix/telegram-sandbox-name branch from d7bc761 to 9d093dc Compare March 19, 2026 12:46
@WuKongAI-CMU
Copy link
Copy Markdown
Contributor Author

Rebased this branch onto the current main and force-pushed to clear the stale merge state.

I also added a regression test for the sandbox-name resolution behavior in scripts/telegram-bridge.js and reran:

  • node --test test/telegram-bridge-sandbox-name.test.js
  • npm test

Community validation on this PR is still pointing the same way: multiple users reported that replacing scripts/telegram-bridge.js with this patch and restarting NemoClaw fixed the Telegram bridge for them without recreating the sandbox.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 19, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 213c6bd0-6ffe-456d-a7bb-b546e66180cb

📥 Commits

Reviewing files that changed from the base of the PR and between f5c4a95 and c67c71f.

📒 Files selected for processing (2)
  • scripts/telegram-bridge.js
  • test/telegram-bridge-sandbox-name.test.js
✅ Files skipped from review due to trivial changes (1)
  • test/telegram-bridge-sandbox-name.test.js

📝 Walkthrough

Walkthrough

Replace hardcoded sandbox derivation in scripts/telegram-bridge.js with a local resolveSandboxName() that returns process.env.SANDBOX_NAME if set, otherwise attempts require("../bin/lib/registry").getDefault(), and falls back to "my-assistant". Add unit tests covering env, registry, and fallback paths.

Changes

Cohort / File(s) Summary
Sandbox Name Resolution
scripts/telegram-bridge.js
Add resolveSandboxName(); resolve SANDBOX by: env SANDBOX_NAMEregistry.getDefault() (via require("../bin/lib/registry")) → "my-assistant" fallback. Existing validateName(SANDBOX, "SANDBOX_NAME") and downstream usage (SSH target/banner) unchanged.
Resolution Logic Tests
test/telegram-bridge-sandbox-name.test.js
New test file that extracts resolveSandboxName() from the script and evaluates it with stubbed process.env and a stubbed/mocked require to assert env precedence, registry-default usage, and fallback behavior.

Sequence Diagram(s)

sequenceDiagram
  participant Script as scripts/telegram-bridge.js
  participant Env as process.env
  participant Registry as ../bin/lib/registry

  Script->>Env: check SANDBOX_NAME
  alt SANDBOX_NAME set
    Env-->>Script: return SANDBOX_NAME
  else SANDBOX_NAME unset
    Script->>Registry: require() and call getDefault()
    alt registry returns default
      Registry-->>Script: return registryDefault
    else registry missing or throws
      Script-->>Script: use "my-assistant" fallback
    end
  end
  Script-->>Script: set SANDBOX and continue (SSH target/banner usage)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I sniffed the env and peeked at the shelf,

If registry slept, I named it myself.
Env first, then registry, then a final cheer—
I settled sweetly on "my-assistant" here. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: resolving the sandbox name from the registry in the Telegram bridge, which directly addresses the core fix for the linked issue.
Linked Issues check ✅ Passed All code changes directly address issue #93's objectives: the sandbox name resolution now queries the registry first, retains SANDBOX_NAME as override, defaults to 'my-assistant' matching onboarding, and includes regression tests validating the fix.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fix sandbox name resolution in the Telegram bridge; no unrelated modifications or refactoring are present outside the stated objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/telegram-bridge.js (1)

15-15: ⚠️ Potential issue | 🟡 Minor

Documentation inconsistency: comment still references old default.

The comment states (default: nemoclaw) but the new default fallback is "my-assistant". This should be updated to avoid confusion.

📝 Proposed fix
-*   SANDBOX_NAME        — sandbox name (default: nemoclaw)
+*   SANDBOX_NAME        — sandbox name (default: from registry, or "my-assistant")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/telegram-bridge.js` at line 15, Update the inline documentation for
SANDBOX_NAME to reflect the new default value ("my-assistant") so the comment
matches the actual fallback; locate the comment mentioning SANDBOX_NAME in
scripts/telegram-bridge.js and change the text "(default: nemoclaw)" to
"(default: my-assistant)".
🧹 Nitpick comments (1)
test/telegram-bridge-sandbox-name.test.js (1)

12-33: Source-based assertions are brittle but acceptable for regression testing.

These tests will break if code formatting changes (e.g., switching to single quotes, adding whitespace). Consider this a tradeoff: the tests catch reintroduction of the bug but require maintenance if the code is reformatted.

For more robust coverage, you could add a unit test that actually invokes resolveSandboxName() with mocked process.env and registry module. However, the current approach is sufficient as a regression guard.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/telegram-bridge-sandbox-name.test.js` around lines 12 - 33, The current
source-string-based tests are brittle; add a more robust unit test that directly
exercises the resolveSandboxName function by mocking process.env.SANDBOX_NAME
and the registry module to assert three behaviors: when process.env.SANDBOX_NAME
is set resolveSandboxName returns that value, when env is unset but
registry.getDefault() returns a value resolveSandboxName returns the registry
value, and when both are absent resolveSandboxName returns "my-assistant";
locate the function named resolveSandboxName and the symbols
process.env.SANDBOX_NAME and registry.getDefault to implement these mocks and
assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@scripts/telegram-bridge.js`:
- Line 15: Update the inline documentation for SANDBOX_NAME to reflect the new
default value ("my-assistant") so the comment matches the actual fallback;
locate the comment mentioning SANDBOX_NAME in scripts/telegram-bridge.js and
change the text "(default: nemoclaw)" to "(default: my-assistant)".

---

Nitpick comments:
In `@test/telegram-bridge-sandbox-name.test.js`:
- Around line 12-33: The current source-string-based tests are brittle; add a
more robust unit test that directly exercises the resolveSandboxName function by
mocking process.env.SANDBOX_NAME and the registry module to assert three
behaviors: when process.env.SANDBOX_NAME is set resolveSandboxName returns that
value, when env is unset but registry.getDefault() returns a value
resolveSandboxName returns the registry value, and when both are absent
resolveSandboxName returns "my-assistant"; locate the function named
resolveSandboxName and the symbols process.env.SANDBOX_NAME and
registry.getDefault to implement these mocks and assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f17361fd-72f7-4a03-9047-3f2fb33575df

📥 Commits

Reviewing files that changed from the base of the PR and between 3ba517d and 9d093dc.

📒 Files selected for processing (2)
  • scripts/telegram-bridge.js
  • test/telegram-bridge-sandbox-name.test.js

@wscurran wscurran added bug Something isn't working Integration: Telegram Use this label to identify Telegram bot integration issues with NemoClaw. labels Mar 19, 2026
@WuKongAI-CMU WuKongAI-CMU force-pushed the fix/telegram-sandbox-name branch from c5cfbf1 to f5c4a95 Compare March 22, 2026 23:42
@WuKongAI-CMU
Copy link
Copy Markdown
Contributor Author

Rebased onto latest main. Resolved the conflict with the upstream validateName addition — the rebased version keeps resolveSandboxName() for registry-aware resolution and also runs validateName() on the result.

Also updated the doc comment to reflect the actual default (from registry, or "my-assistant" instead of nemoclaw) per CodeRabbit's earlier suggestion.

Community validation still holds — multiple users confirmed this patch fixes Telegram bridge "sandbox not found" errors.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/telegram-bridge-sandbox-name.test.js (1)

11-11: Regex extraction is fragile and style-dependent.

The pattern [\s\S]*?\n\} relies on the function's closing brace being at column 0 (no indentation). If the source file is reformatted (e.g., wrapped in a module, changed indentation), this regex will silently capture an incomplete function body, causing misleading test failures.

Consider exporting resolveSandboxName for direct testing, or using a more robust extraction approach (e.g., matching balanced braces or an AST parser like acorn).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/telegram-bridge-sandbox-name.test.js` at line 11, The test's regex that
builds RESOLVE_SANDBOX_NAME_SOURCE from SCRIPT using /function
resolveSandboxName\(\) \{[\s\S]*?\n\}/ is fragile; update the code to either
export resolveSandboxName from the module and import it directly in the test
(preferred) or replace the brittle extraction with a robust parser approach
(e.g., use an AST parser like acorn to locate the FunctionDeclaration named
"resolveSandboxName" or implement a balanced-brace extractor that starts at
"function resolveSandboxName()" and reads until the matching closing brace) so
the test reliably obtains the full function body regardless of formatting
changes to SCRIPT.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/telegram-bridge-sandbox-name.test.js`:
- Line 11: The test's regex that builds RESOLVE_SANDBOX_NAME_SOURCE from SCRIPT
using /function resolveSandboxName\(\) \{[\s\S]*?\n\}/ is fragile; update the
code to either export resolveSandboxName from the module and import it directly
in the test (preferred) or replace the brittle extraction with a robust parser
approach (e.g., use an AST parser like acorn to locate the FunctionDeclaration
named "resolveSandboxName" or implement a balanced-brace extractor that starts
at "function resolveSandboxName()" and reads until the matching closing brace)
so the test reliably obtains the full function body regardless of formatting
changes to SCRIPT.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 616fa3d6-5a42-4cc2-a550-7b00c493d9d1

📥 Commits

Reviewing files that changed from the base of the PR and between c5cfbf1 and f5c4a95.

📒 Files selected for processing (2)
  • scripts/telegram-bridge.js
  • test/telegram-bridge-sandbox-name.test.js
✅ Files skipped from review due to trivial changes (1)
  • scripts/telegram-bridge.js

@Mingkulee
Copy link
Copy Markdown

Thanks for your advise。

@WuKongAI-CMU
Copy link
Copy Markdown
Contributor Author

Addressed the remaining test fragility nit in b453c17.

The sandbox-resolution regression test now uses a small balanced-brace extractor instead of the style-dependent regex, so it keeps exercising the real resolveSandboxName() source without depending on exact formatting.

Verification: node --test test/telegram-bridge-sandbox-name.test.js

The Telegram bridge hardcoded the sandbox name default to "nemoclaw"
while the onboard wizard defaults to "my-assistant", causing "sandbox
not found" errors when the bridge tries to connect.

Now resolves the sandbox name via:
1. SANDBOX_NAME env var (explicit override)
2. Default sandbox from the NemoClaw registry
3. Fallback to "my-assistant" (matches onboard default)

Also quotes the sandbox name in the ssh-config shell command.

Fixes NVIDIA#93

Signed-off-by: peteryuqin <peter.yuqin@gmail.com>
@WuKongAI-CMU WuKongAI-CMU force-pushed the fix/telegram-sandbox-name branch from b453c17 to c67c71f Compare March 25, 2026 19:03
@WuKongAI-CMU
Copy link
Copy Markdown
Contributor Author

Latest branch state is already rebased and the remaining CodeRabbit nit was addressed in b453c17. Triggering a fresh pass so the review state reflects the current branch.

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

@WuKongAI-CMU Sure! Kicking off a fresh review pass to reflect the current branch state, including the balanced-brace extractor fix from b453c17 and the rebased validateName conflict resolution.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@WuKongAI-CMU
Copy link
Copy Markdown
Contributor Author

Closing this to free a contributor slot for a fresher issue; can reopen later if needed.

mafueee pushed a commit to mafueee/NemoClaw that referenced this pull request Mar 28, 2026
…DIA#97)

* refactor(policy): consolidate duplicated YAML struct hierarchies into navigator-policy

Closes NVIDIA#96

Merge the Deserialize-only input structs and Serialize-only output structs
into a single set of types in navigator-policy that derive both Serialize
and Deserialize. This eliminates the duplicate PolicyYaml hierarchy in
navigator-cli and fixes three round-trip issues:

- filesystem_policy vs filesystem field name mismatch
- allowed_ips silently dropped on proto-to-YAML conversion
- network policy name field silently dropped on proto-to-YAML conversion

Also adds api_patterns support to the inference YAML schema and switches
network_policies from HashMap to BTreeMap for deterministic output ordering.

* fix(e2e): update non-CONNECT test assertion from 405 to 403

Align test_l4_non_connect_method_rejected with the proxy behavior
change in c06117e which intentionally returns 403 for non-CONNECT
requests.

---------

Co-authored-by: John Myers <johntmyers@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Integration: Telegram Use this label to identify Telegram bot integration issues with NemoClaw.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Telegram agent exits with code 255: "sandbox not found" after successful onboarding

6 participants