Autonomous Agent
A ReAct-loop agent that plans and executes multi-step code review tasks autonomously.
ReAct loop
The agent follows a Reason โ Act โ Observe cycle. It reads your task, selects a tool, observes the output, and iterates until the task is complete or max_iterations is reached.
CLI REPL (default)
$ merlin agent๐ค Merlin AI Code Review Agent โ type your task and press Enter ("exit" to quit)> review the PR, run a security scan, and approve if no critical issuesReasoning: I need to review, then scan, then decide on approval...โ Calling tool: reviewโ Calling tool: securityโ Calling tool: rag_searchโ Calling tool: approveDone. No critical issues found โ PR approved.
Single-shot mode (CI-friendly)
Pass a task via --task to run non-interactively and exit when complete.
$ merlin agent --task "run /security and post a summary"$ merlin agent --task "describe the PR and generate labels"
Slack integration
Run Merlin AI Code Review as a Slack bot. Mention @merlin in any channel to trigger a task.
# Start the webhook listener$ merlin agent --channel slack --port 8090
Required env vars for Slack
Set SLACK_BOT_TOKEN (xoxb-...) before starting. In the Slack App settings, configure the Events API URL to http://your-host:8090/slack/events and subscribe to the message.channels bot event.
Discord integration
Merlin AI Code Review polls for new messages and replies when mentioned or addressed by name.
$ merlin agent --channel discord
Required env vars for Discord
Set DISCORD_BOT_TOKEN and DISCORD_CHANNEL_ID. The bot reads the channel every 3 seconds and replies when you mention @Merlin or start a message with merlin.
Available tools
The agent has access to all 20 slash commands plus these additional tools:
| Tool | Description |
|---|---|
rag_search | Query the RAG index for relevant code snippets or past comments |
post_comment | Post custom Markdown to the PR/MR |
get_pr_info | Get PR metadata: title, author, branches, labels, diff stats |
| All slash commands | /review, /security, /describe, etc. |
Conversation memory
The agent keeps a configurable ring-buffer of messages in memory. Optionally persist it across restarts with a JSONL file.
[agent]max_iterations = 10max_memory_messages = 50memory_file = ".merlin-memory.jsonl" # persist across restartsdefault_channel = "cli"port = 8090