feat: add first-class local (terminal) channel to gateway - #4474
Conversation
Greptile SummaryThe PR completes token-free gateway support for the
Confidence Score: 3/5The tokenless startup fix is correct, but the outstanding terminal-reader shutdown and reconnect failures should be resolved before merging. A blocked stdin read remains uninterruptible during shutdown, and reconnecting can start a second reader while the abandoned reader can still consume terminal input. Files Needing Attention: src/praisonai-bot/praisonai_bot/bots/local.py
|
| Filename | Overview |
|---|---|
| src/praisonai-bot/praisonai_bot/gateway/server.py | Consistently recognizes local as token-free across configuration validation, initial startup, and single-channel reload. |
Reviews (3): Last reviewed commit: "fix: recognize local channel as tokenles..." | Re-trigger Greptile
| def __init__( | ||
| self, | ||
| token: str = "", | ||
| agent: Optional["Agent"] = None, |
|
@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Review changes in this PR. Python SDK: praisonaiagents, praisonai. TypeScript SDK: src/praisonai-ts/. Do NOT modify src/praisonai-rust. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding. Phase 1: Review per AGENTS.md
Phase 2: FIX Valid Issues Phase 3: Final Verdict |
|
Claude finished @MervinPraison's task —— View job Final Architecture Review — PR #4474 (local terminal channel) ✅Phase 1 — Architecture (AGENTS.md): PASS.
Phase 2 — Fixed the two valid Greptile P1 issues:
Independent checks: verified the canonical schema ( Files modified:
Skipped: nothing actionable. (Pre-existing, unrelated failures in Tests: Verdict: ✅ Approve — both blocking P1 issues resolved, no regressions. Ready to merge.Job run · branch |
| thread = threading.Thread( | ||
| target=_worker, name="local-stdin", daemon=True | ||
| ) | ||
| thread.start() |
There was a problem hiding this comment.
Reconnect loses terminal input
When the local channel is reconnected or hot-reloaded while readline() is blocked, cancellation abandons the existing daemon reader and starts another reader on the same sys.stdin. The abandoned reader can consume and discard the operator's next line through its cancelled future, causing the active terminal channel to miss input or appear hung.
Knowledge Base Used:
|
@claude this PR has merge conflicts with |
|
Claude finished @MervinPraison's task —— View job Rebase & Conflict Resolution — PR #4474 ✅
Rebased cleanly onto Key contextA sibling PR (#4463) for the same issue #4455 already merged a more mature local-channel implementation into Conflicts resolved
Net diff vs
|
…hang - Add "local" to the three gateway tokenless gates (config validation, start_channels, _start_single_channel) so a token-free terminal channel starts instead of being skipped and marked degraded (Greptile P1 #1). - Run the blocking stdin readline on a dedicated daemon thread so a pending TTY read at shutdown can never join-block interpreter exit; cancellation resolves the awaiting coroutine promptly (Greptile P1 #2). - Add regression tests: cancelled-read clean exit, daemon reader guard. Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
3a3caa8 to
8b21ff8
Compare
|
@coderabbitai review |
|
/review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe gateway now treats ChangesLocal channel support
Estimated code review effort: 2 (Simple) | ~5 minutes Merge Risk: ⚪ Minimal · up to The change adds token-free local terminal channel support without identified correctness, security, availability, or deployment risk. No actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Linked Issues checkExplanation The changes support issue ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if |
|
Merged by Claude PR merge gate ( |
Fixes #4455
Summary
Adds a first-class
local(terminal) channel so you can converse with a running gateway agent from your own shell — no remote bot, no tokens, no webhook.It is a real channel (not a separate process): it joins the same
BotSessionManager, identity resolver, delivery router and cross-channel mirror as every remote channel, so a conversation begun in the terminal continues seamlessly on Telegram (anddeliver="local"/deliver="local:local"resolves like any other target).Architecture (WRAPPER-only)
praisonai-bot): a concreteBasePlatformAdaptertransport (the TTY loop / stdin handling belongs beside the other channel implementations) + one registry entry.BasePlatformAdapter/PlatformCapabilities/BotSessionManageruntouched.Changes
bots/local.py(new) —LocalBot: stdin read loop run off the event loop (concurrent channels keep running), stdout writer,/status /new /help /stop, TTY-honest capabilities (supports_edit=False,needs_rate_limit=False,accepts_webhooks=False,markdown_dialect="plain"),supervised_inbound=False(EOF is a clean exit, not a reconnectable drop), always-okprobe(), and aLocalDescriptorfor config/onboarding/prompt.bots/_registry.py—locallazy loader in_BUILTIN_PLATFORMS.bots/__init__.py— lazyLocalBotexport.tests/unit/bots/test_local_channel.py(new) — registry wiring, capabilities, token-free/unsupervised, stdin→agent→stdout turn loop + clean EOF exit, and outboundsend_messageto stdout.Tests
test_local_channel.py— 7 passedGenerated with Claude Code
Summary by CodeRabbit