Refine OpenClaw adapter: method mapping, command extraction, and approval gating#25
Conversation
|
CodeAnt AI is reviewing your PR. |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change refactors the OpenClaw gateway adapter to centralize tool-to-RPC method mapping, extract command previews intelligently, and conditionally apply approval logic only for execution operations, replacing unconditional approval with smart filtering. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
|
|
Overall Grade Focus Area: Complexity |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Python | Feb 27, 2026 12:14p.m. | Review ↗ |
Nitpicks 🔍
|
|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d1aeea0c1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for key in ("command", "cmd", "shell", "input"): | ||
| value = tool_call.get(key) | ||
| if isinstance(value, str) and value.strip(): | ||
| return value |
There was a problem hiding this comment.
Prefer payload command over
input for risk approval
For exec calls that include both a descriptive input string and the real shell command under payload.command, _extract_command_preview returns input first, so high-risk checks can miss dangerous commands (e.g. rm -rf ...) and incorrectly auto-approve execution. This regression is specific to mixed-shape payloads and weakens the approval gate compared with scanning the full tool-call JSON.
Useful? React with 👍 / 👎.
| call_type = neurorift_tool_call.get("type", "") | ||
| return TOOL_METHOD_MAP.get(call_type, "process") |
There was a problem hiding this comment.
Handle non-string tool types before method lookup
_map_method now does TOOL_METHOD_MAP.get(call_type, "process"), which raises TypeError when type is a dict/list (possible with variant or malformed websocket payloads). The previous equality-chain safely fell back to process; this change can now crash _build_rpc_frame and terminate the adapter loop on a single bad event.
Useful? React with 👍 / 👎.
User description
Motivation
read/write/processcalls.Description
TOOL_METHOD_MAPwith aliases (e.g.terminal,file_read,file_write,workflow_state) and used it in_map_methodso tool types map robustly to OpenClaw RPCs._extract_command_previewto pull actual command text from common keys (command,cmd,shell,inputor nestedpayload) for accurate risk detection.execRPCs only by running theExecutionApprovalForwardercheck only when the mapped method isexec.integrations/openclaw/openclaw_gateway_adapter.pyand preserve existing behavior for non-exec operations.Testing
python3 -m py_compile integrations/openclaw/openclaw_gateway_adapter.pywhich completed successfully.Codex Task
CodeAnt-AI Description
Map tool calls correctly, extract real commands, and gate approvals only for executions
What Changed
Impact
✅ Fewer false approval blocks for non-execution operations✅ Clearer execution risk detection and approval decisions✅ More accurate rejection messages when executions are denied💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit
Release Notes
Bug Fixes
Refactor