Skip to content

Commit b89933f

Browse files
author
ClaudioDrews
committed
fix: resolve 6 installation bugs in setup.sh and docker-compose
- Bug 1: QDRANT_API_KEY unbound variable (default to empty) - Bug 2: Qdrant v1.17+ auth with empty key (conditional config) - Bug 3: Redis crash with empty requirepass (conditional config) - Bug 4: grep pattern now covers OPENROUTER_DS_API_KEY - Bug 5: worker container healthcheck added - Bug 7: execution-agent protocol installed during setup
1 parent 7de2265 commit b89933f

3 files changed

Lines changed: 59 additions & 16 deletions

File tree

docker/docker-compose.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ services:
1010
command: >
1111
sh -c '
1212
mkdir -p /usr/local/etc/redis &&
13-
echo "requirepass $${REDIS_PASSWORD}" > /usr/local/etc/redis/redis.conf &&
13+
: > /usr/local/etc/redis/redis.conf &&
14+
if [ -n "$${REDIS_PASSWORD}" ]; then
15+
echo "requirepass $${REDIS_PASSWORD}" >> /usr/local/etc/redis/redis.conf;
16+
fi &&
1417
echo "bind 0.0.0.0" >> /usr/local/etc/redis/redis.conf &&
1518
echo "appendonly yes" >> /usr/local/etc/redis/redis.conf &&
1619
echo "maxmemory 512mb" >> /usr/local/etc/redis/redis.conf &&
@@ -24,7 +27,7 @@ services:
2427
volumes:
2528
- redis_data:/data
2629
healthcheck:
27-
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
30+
test: ["CMD-SHELL", "redis-cli ${REDIS_PASSWORD:+-a $REDIS_PASSWORD} ping"]
2831
interval: 5s
2932
timeout: 3s
3033
retries: 5
@@ -62,7 +65,7 @@ services:
6265
REDIS_PASSWORD: ${REDIS_PASSWORD}
6366
QDRANT_HOST: qdrant
6467
QDRANT_PORT: "6333"
65-
QDRANT_API_KEY: ${QDRANT_API_KEY}
68+
QDRANT_API_KEY: ${QDRANT_API_KEY:-}
6669
OPENROUTER_API_KEY: ${OPENROUTER_API_KEY}
6770
EMBEDDING_DIMS: "${EMBEDDING_DIMS:-4096}"
6871
COLLECTION_NAME: "${COLLECTION_NAME:-knowledge_base}"
@@ -74,6 +77,15 @@ services:
7477
- ${MEMORY_OS_WIKI_PATH:-./wiki}:/wiki:ro
7578
- ${MEMORY_OS_HERMES_HOME:-./hermes}:/hermes:rw
7679
- ${MEMORY_OS_FABRIC_DIR:-./fabric}:/fabric:rw
80+
healthcheck:
81+
# Verifies the worker can reach Redis with auth — if this passes the ARQ
82+
# event loop is operational. Overrides the Dockerfile HEALTHCHECK which
83+
# does not include REDIS_PASSWORD.
84+
test: ["CMD-SHELL", "python -c \"import os,redis; r=redis.Redis(host='redis',port=6379,password=os.environ.get('REDIS_PASSWORD') or None,socket_connect_timeout=3); r.ping()\""]
85+
interval: 30s
86+
timeout: 10s
87+
retries: 3
88+
start_period: 30s
7789

7890
volumes:
7991
redis_data:

modifications/execution-agent-protocol.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,19 @@ In the left column, "relevante" could describe any block in any session — it c
3030
- If no injected entry addresses the request: state explicitly: "No injected context covers [X]. Proceeding with tool verification."
3131
- If injected context conflicts with request assumptions: **injected context wins** (Ground Truth rule). Adjust your approach.
3232

33-
### Step 4 — Then act
33+
### Step 4 — Gate: plane, present, wait
3434

35-
Only after completing Steps 1-3 may you make your first tool call. This sequence must be visible in your response.
35+
- If your response requires **more than one tool call**, you MUST present a plan first.
36+
- Show the plan. Do NOT execute any tool calls in the same turn.
37+
- Wait for explicit user authorization before proceeding.
38+
- If the user asks questions about the plan → answer them, but **do not execute anything**.
39+
- Only when the user says "ok", "execute", "vá", "prossiga", or equivalent → then execute.
40+
- **No exceptions for triviality.** Even actions that seem obvious require authorization.
41+
- This gate applies even when injected memory provides clear answers — the user may have new context.
42+
43+
### Step 5 — Then act
44+
45+
Only after completing Steps 1-4, and only after user authorization, may you make your first tool call. This sequence must be visible in your response.
3646

3747
### Why this exists
3848

setup.sh

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
# ──────────────────────────────────────────────────────────────────────────────
2626
set -euo pipefail
2727

28+
# ── Safe defaults for optional env vars ──────────────────────────────────────
29+
# Must come before any reference to these names. set -u would abort with
30+
# \"unbound variable\" if they were never exported by the caller.
31+
QDRANT_API_KEY="${QDRANT_API_KEY:-}"
32+
REDIS_PASSWORD="${REDIS_PASSWORD:-}"
33+
2834
# ── Colors ────────────────────────────────────────────────────────────────────
2935
RED='\033[0;31m'
3036
GREEN='\033[0;32m'
@@ -212,7 +218,7 @@ cd "${DOCKER_DIR}"
212218
# Detect API key from Hermes .env
213219
OPENROUTER_KEY=""
214220
if [ -f "${ENV_FILE}" ]; then
215-
OPENROUTER_KEY=$(grep -oP 'OPENROUTER_API_KEY=\K.*' "${ENV_FILE}" 2>/dev/null | head -1 || true)
221+
OPENROUTER_KEY=$(grep -oP '(?:OPENROUTER.*API_KEY|LLM_API_KEY)=\K.*' "${ENV_FILE}" 2>/dev/null | head -1 || true)
216222
fi
217223

218224
if [ -z "${OPENROUTER_KEY}" ]; then
@@ -334,23 +340,38 @@ ok "Environment variables added to Hermes .env"
334340
# ──────────────────────────────────────────────────────────────────────────────
335341
banner "Phase 9: Rulebook"
336342

343+
SOUL_FILE="${HERMES_HOME}/SOUL.md"
337344
RULEBOOK="${HERMES_HOME}/rulebook.md"
345+
PROTOCOL_FILE="${REPO_DIR}/modifications/execution-agent-protocol.md"
346+
MARKER="Mandatory Pre-Action Protocol"
338347

339-
if [ -f "${RULEBOOK}" ]; then
340-
if grep -q "Mandatory Pre-Action Protocol" "${RULEBOOK}" 2>/dev/null; then
341-
ok "Rulebook amendments already applied"
342-
else
343-
PROTOCOL_FILE="${REPO_DIR}/modifications/execution-agent-protocol.md"
344-
if [ -f "${PROTOCOL_FILE}" ]; then
348+
if [ ! -f "${PROTOCOL_FILE}" ]; then
349+
warn "execution-agent-protocol.md not found — skipping modifications"
350+
else
351+
# Try SOUL.md first — behavioral tests show 3/6 compliance when protocol
352+
# is in SOUL.md vs 0/6 when it is only in rulebook.md.
353+
if [ -f "${SOUL_FILE}" ]; then
354+
if grep -q "${MARKER}" "${SOUL_FILE}" 2>/dev/null; then
355+
ok "Mandatory Pre-Action Protocol already in SOUL.md"
356+
else
357+
echo "" >> "${SOUL_FILE}"
358+
echo "<!-- Memory OS additions — do not duplicate -->" >> "${SOUL_FILE}"
359+
cat "${PROTOCOL_FILE}" >> "${SOUL_FILE}"
360+
ok "Mandatory Pre-Action Protocol appended to SOUL.md"
361+
fi
362+
elif [ -f "${RULEBOOK}" ]; then
363+
if grep -q "${MARKER}" "${RULEBOOK}" 2>/dev/null; then
364+
ok "Rulebook amendments already applied"
365+
else
345366
echo "" >> "${RULEBOOK}"
346367
cat "${PROTOCOL_FILE}" >> "${RULEBOOK}"
347368
ok "Mandatory Pre-Action Protocol appended to rulebook"
348-
else
349-
warn "execution-agent-protocol.md not found — skipping"
350369
fi
370+
else
371+
warn "Neither SOUL.md nor rulebook.md found"
372+
info "To install the protocol manually:"
373+
info " cat ${PROTOCOL_FILE} >> ${HERMES_HOME}/SOUL.md"
351374
fi
352-
else
353-
warn "${RULEBOOK} not found — skipping modifications"
354375
fi
355376

356377
# ──────────────────────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)