fix(telegram): filter gateway startup logs from Telegram replies#883
fix(telegram): filter gateway startup logs from Telegram replies#883codeyogi911 wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe Telegram bridge's Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 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.
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)
126-136:⚠️ Potential issue | 🟠 MajorOver-broad filters can remove legitimate agent content
Line 130 and Line 135 are too generic for the stated goal. They can drop valid answers (e.g., when the model discusses “privilege separation” or emits lines beginning with
[gateway]). Match the specific startup line instead of broad substrings/prefixes.Suggested narrowing
const responseLines = lines.filter( (l) => !l.startsWith("Setting up NemoClaw") && !l.startsWith("[plugins]") && - !l.startsWith("[gateway]") && + !/^\[gateway\]\s+Running as non-root \(uid=\d+\)\s+[—-]\s+privilege separation disabled$/.test(l) && !l.startsWith("(node:") && !l.includes("NemoClaw ready") && !l.includes("NemoClaw registered") && !l.includes("openclaw agent") && - !l.includes("privilege separation") && !l.includes("┌─") && !l.includes("│ ") && !l.includes("└─") && l.trim() !== "", );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/telegram-bridge.js` around lines 126 - 136, The filter applied in responseLines (lines.filter using l.startsWith and l.includes) is too broad and may remove valid agent output; update the predicate in the lines.filter inside scripts/telegram-bridge.js to match only the exact startup/log lines you want to exclude (use exact equality or anchored regexes) instead of generic substrings — specifically tighten checks that use l.startsWith("Setting up NemoClaw"), l.startsWith("[gateway]"), and l.includes("privilege separation") by matching the full startup text or a precise regex anchored to line start (keep using the same responseLines and lines.filter symbols and the l variable) so legitimate content is not dropped.
🤖 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`:
- Around line 126-136: The filter applied in responseLines (lines.filter using
l.startsWith and l.includes) is too broad and may remove valid agent output;
update the predicate in the lines.filter inside scripts/telegram-bridge.js to
match only the exact startup/log lines you want to exclude (use exact equality
or anchored regexes) instead of generic substrings — specifically tighten checks
that use l.startsWith("Setting up NemoClaw"), l.startsWith("[gateway]"), and
l.includes("privilege separation") by matching the full startup text or a
precise regex anchored to line start (keep using the same responseLines and
lines.filter symbols and the l variable) so legitimate content is not dropped.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5fbc5336-4e5d-4a66-ba98-e3eac61fb43f
📒 Files selected for processing (1)
scripts/telegram-bridge.js
b87306c to
b12ca67
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/telegram-bridge.js`:
- Line 135: The current filter unconditionally excludes any line containing
l.includes("privilege separation"), which can remove valid agent responses;
change the predicate so the exclusion is applied only when the line is gateway
startup noise—e.g., replace the unconditional check with a scoped check that
matches both the gateway prefix and the phrase (use a combined condition like
/\[gateway\].*privilege separation/.test(l) or l.includes('[gateway]') &&
l.includes('privilege separation')) so only gateway startup lines are dropped;
update the filter where l.includes("privilege separation") is used to use this
scoped condition (refer to the filter callback containing l.includes("privilege
separation")).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f6681beb-0743-48b9-bb19-f3b764d71994
📒 Files selected for processing (2)
scripts/telegram-bridge.jstest/runner.test.js
scripts/telegram-bridge.js
Outdated
| !l.includes("NemoClaw ready") && | ||
| !l.includes("NemoClaw registered") && | ||
| !l.includes("openclaw agent") && | ||
| !l.includes("privilege separation") && |
There was a problem hiding this comment.
Narrow the privilege separation exclusion to avoid stripping valid user-facing answers.
At Line 135, filtering any line containing "privilege separation" can remove legitimate agent output (e.g., security explanations). The [gateway] prefix filter at Line 130 already handles the reported startup-noise case.
Proposed fix
- !l.includes("privilege separation") &&🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@scripts/telegram-bridge.js` at line 135, The current filter unconditionally
excludes any line containing l.includes("privilege separation"), which can
remove valid agent responses; change the predicate so the exclusion is applied
only when the line is gateway startup noise—e.g., replace the unconditional
check with a scoped check that matches both the gateway prefix and the phrase
(use a combined condition like /\[gateway\].*privilege separation/.test(l) or
l.includes('[gateway]') && l.includes('privilege separation')) so only gateway
startup lines are dropped; update the filter where l.includes("privilege
separation") is used to use this scoped condition (refer to the filter callback
containing l.includes("privilege separation")).
The non-root privilege separation log line from nemoclaw-start leaked into every Telegram reply because the response filter did not cover `[gateway]`-prefixed lines. Add a filter for `[gateway]`-prefixed lines to strip these internal startup messages before sending the agent response back to the user. Made-with: Cursor
b12ca67 to
1185c4b
Compare
Summary
[gateway] Running as non-root (uid=998) — privilege separation disabledlog line fromnemoclaw-startwas leaking into every Telegram reply because the response filter intelegram-bridge.jsdid not cover[gateway]-prefixed lines.!l.startsWith("[gateway]")and!l.includes("privilege separation")to strip these internal startup messages before sending the agent response back to the user.Test plan
gateway Running as non-root (uid=998) — privilege separation disabledMade with Cursor
Summary by CodeRabbit
Bug Fixes
Tests