# How to Set Up Reddit with rdt-cli on Server Environments Using Agent Reach

> Set up Reddit on servers with rdt-cli using Agent Reach. Learn to install rdt-cli via pipx and configure your reddit_session cookie for headless environments.

- Repository: [Pnant/Agent-Reach](https://github.com/Panniantong/Agent-Reach)
- Tags: how-to-guide
- Published: 2026-08-04

---

**Use `rdt-cli` as the backend, install the pinned git version via pipx, and provide a manually exported `reddit_session` cookie in `~/.config/rdt-cli/credential.json` since headless servers cannot run Chrome.**

Agent Reach does not include its own Reddit client—it routes calls to upstream tools. For **headless server environments**, `rdt-cli` is the only viable backend because `OpenCLI` requires a live Chrome session that unavailable without a GUI. This guide walks through installing, configuring, and verifying Reddit access on servers using the Panniantong/Agent-Reach implementation.

---

## Why rdt-cli Is Required for Servers

Agent Reach probes multiple backends through `RedditChannel.check()` in [`agent_reach/channels/reddit.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/channels/reddit.py)【90†L90-L135】. The method evaluates available options in order:

- **`OpenCLI`** — reuses an existing Chrome session (requires GUI, fails on servers)【30†L30-L34】.
- **`rdt-cli`** — uses a saved cookie file, works anywhere.

The official Reddit JSON endpoints return **403 Forbidden**, and the public API now requires manual approval that is difficult to obtain【2†L2-L9】. `rdt-cli` bypasses these restrictions by authenticating via browser cookies.

---

## Step 1: Install the Pinned rdt-cli Version

The PyPI release of `rdt-cli` lags behind the required commit. Agent Reach defines the exact compatible version in `_RDT_GIT_SOURCE` at line 27-29 of [`reddit.py`](https://github.com/Panniantong/Agent-Reach/blob/main/reddit.py)【27†L27-L29】:

```bash
pipx install 'git+https://github.com/public-clis/rdt-cli.git@5e4fb3720d5c174e976cd425ccc3b879d52cac66'

```

**Do not install from PyPI**—the git commit ensures compatibility with Agent Reach's credential handling logic.

---

## Step 2: Provide the reddit_session Cookie

### Headless Servers: Manual Cookie Export

Without a browser on the server, you must obtain the cookie elsewhere and copy it. The `_rdt_login_hint()` function in [`reddit.py`](https://github.com/Panniantong/Agent-Reach/blob/main/reddit.py)【38†L38-L50】 directs users to:

1. Install the **Cookie-Editor** browser extension on a machine with Reddit access.
2. Navigate to `reddit.com` and log in.
3. Click Cookie-Editor → Export → **Header String**.
4. Copy the value after `reddit_session=`.

Create the credential file manually:

```bash
mkdir -p ~/.config/rdt-cli

```

```bash
cat > ~/.config/rdt-cli/credential.json <<'EOF'
{
  "cookies": {
    "reddit_session": "<PASTE_YOUR_COOKIE_HERE>"
  },
  "source": "manual",
  "username": "<YOUR_REDDIT_USERNAME>",
  "modhash": null,
  "saved_at": 1704067200,
  "last_verified_at": null
}
EOF

```

Replace the timestamp with the current Unix time via `$(date +%s)`.

### GUI-Enabled Servers: Automated Login

If your server has a desktop environment, run:

```bash
rdt login

```

This pulls the cookie directly from Chrome's local session.

---

## Step 3: Configure Proxy (If Required)

Reddit is blocked in some regions. Agent Reach supports persistent proxy configuration through its config system【65†L65-L72】:

```bash
agent-reach configure proxy http://user:pass@proxy.example.com:3128

```

The proxy URL is stored and automatically injected into `HTTP_PROXY`/`HTTPS_PROXY` for all `rdt` subprocess calls.

---

## Step 4: Verify Installation

Run the doctor command to validate the setup:

```bash
agent-reach doctor --channels reddit

```

The output should show:

- **Backend**: `rdt-cli` (active)
- **Status**: warn (credentials present but unverified) or ok
- **Hint**: refresh notice if cookie is older than 7 days

The TTL logic in `_check_rdt()`【25†L25-L33】 flags cookies exceeding 7 days as stale.

---

## Running Reddit Commands

Once configured, invoke Reddit operations directly via `rdt` or through Agent Reach:

```bash

# Direct upstream tool

rdt search "python asyncio"
rdt read abcdef123

# Via Agent Reach routing

agent-reach reddit search "python asyncio"

```

Both approaches execute identical underlying calls.

---

## Summary

- **No embedded client**: Agent Reach routes to external tools, selecting `rdt-cli` for headless environments.
- **Pinned version required**: Install from the specific git commit in `_RDT_GIT_SOURCE`, not PyPI.
- **Cookie-based auth**: Servers need manually exported `reddit_session` cookies; GUI servers can use `rdt login`.
- **Proxy support**: Configure via `agent-reach configure proxy` for region-blocked access.
- **Health check**: Use `agent-reach doctor --channels reddit` to verify backend and credential freshness.

---

## Frequently Asked Questions

### How does Agent Reach choose between rdt-cli and OpenCLI?

`RedditChannel.check()` probes each backend in order of preference. If `rdt` exists on `PATH` and `~/.config/rdt-cli/credential.json` contains a valid `reddit_session` cookie, it selects `rdt-cli`. Otherwise, it attempts `OpenCLI`, which requires Chrome【90†L90-L135】.

### What happens if my reddit_session cookie expires?

The doctor warns when cookies exceed 7 days old based on `saved_at` timestamp comparison. You must re-export a fresh cookie from a browser using Cookie-Editor and update [`credential.json`](https://github.com/Panniantong/Agent-Reach/blob/main/credential.json)【25†L25-L33】.

### Can I use environment variables instead of the credential file?

No. `rdt-cli` exclusively reads `~/.config/rdt-cli/credential.json`. The file format with `cookies.reddit_session`, `source`, `username`, and timestamp fields is mandatory as implemented in the channel validation logic【38†L38-L50】.

### Why does Agent Reach pin a specific git commit for rdt-cli?

The PyPI release lacks required features for the Reddit channel's credential handling. The `_RDT_GIT_SOURCE` constant locks to commit `5e4fb3720d5c174e976cd425ccc3b879d52cac66` to ensure API compatibility【27†L27-L29】.