fix: strip hermes metadata from tower message passing
Session resume lines, tool traces, and session rename output were leaking into the messages passed between agents. Added grep filters to strip them from ask_hermes/ask_timmy output. Also switched from set -e to avoid exits on non-zero from first-run --continue calls.
This commit is contained in:
@@ -4,13 +4,14 @@
|
||||
# Communication via ~/.tower/timmy-to-hermes.msg and hermes-to-timmy.msg
|
||||
# ───────────────────────────────────────────────────────────────────────
|
||||
|
||||
set -euo pipefail
|
||||
set -uo pipefail
|
||||
|
||||
TOWER_DIR="$HOME/.tower"
|
||||
INBOX="$TOWER_DIR/timmy-to-hermes.msg"
|
||||
OUTBOX="$TOWER_DIR/hermes-to-timmy.msg"
|
||||
LOCK="$TOWER_DIR/hermes.lock"
|
||||
SESSION_NAME="tower-hermes"
|
||||
SESSION_FLAG="$TOWER_DIR/.hermes-session-exists"
|
||||
LOG="$TOWER_DIR/hermes.log"
|
||||
TURN_DELAY=5 # seconds between checking for new messages
|
||||
|
||||
@@ -38,11 +39,22 @@ send() {
|
||||
# ── Get response from Hermes agent ────────────────────────────────────
|
||||
ask_hermes() {
|
||||
local prompt="$1"
|
||||
hermes chat \
|
||||
-q "$prompt" \
|
||||
-Q \
|
||||
--continue "$SESSION_NAME" \
|
||||
2>>"$LOG"
|
||||
local result
|
||||
if [ -f "$SESSION_FLAG" ]; then
|
||||
result=$(hermes chat -q "$prompt" -Q --continue "$SESSION_NAME" 2>>"$LOG") || true
|
||||
else
|
||||
result=$(hermes chat -q "$prompt" -Q 2>>"$LOG") || true
|
||||
# Name the session for future --continue calls
|
||||
local sid
|
||||
sid=$(echo "$result" | grep -o 'session_id: [^ ]*' | cut -d' ' -f2)
|
||||
if [ -n "$sid" ]; then
|
||||
hermes sessions rename "$sid" "$SESSION_NAME" 2>>"$LOG" || true
|
||||
touch "$SESSION_FLAG"
|
||||
log "Created session '$SESSION_NAME' (id: $sid)"
|
||||
fi
|
||||
fi
|
||||
# Strip metadata lines from output
|
||||
echo "$result" | grep -v '^session_id: ' | grep -v '↻ Resumed session' | grep -v "^Session '" | sed '/^\[.*\] Created session/d'
|
||||
}
|
||||
|
||||
# ── Boot message ──────────────────────────────────────────────────────
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
# Communication via ~/.tower/hermes-to-timmy.msg and timmy-to-hermes.msg
|
||||
# ───────────────────────────────────────────────────────────────────────
|
||||
|
||||
set -euo pipefail
|
||||
set -uo pipefail
|
||||
|
||||
TOWER_DIR="$HOME/.tower"
|
||||
INBOX="$TOWER_DIR/hermes-to-timmy.msg"
|
||||
OUTBOX="$TOWER_DIR/timmy-to-hermes.msg"
|
||||
LOCK="$TOWER_DIR/timmy.lock"
|
||||
SESSION_NAME="tower-timmy"
|
||||
SESSION_FLAG="$TOWER_DIR/.timmy-session-exists"
|
||||
LOG="$TOWER_DIR/timmy.log"
|
||||
TURN_DELAY=5 # seconds between checking for new messages
|
||||
|
||||
@@ -41,11 +42,22 @@ send() {
|
||||
# ── Get response from Timmy agent ─────────────────────────────────────
|
||||
ask_timmy() {
|
||||
local prompt="$1"
|
||||
hermes chat \
|
||||
-q "$prompt" \
|
||||
-Q \
|
||||
--continue "$SESSION_NAME" \
|
||||
2>>"$LOG"
|
||||
local result
|
||||
if [ -f "$SESSION_FLAG" ]; then
|
||||
result=$(HERMES_HOME="$HOME/.timmy" hermes chat -q "$prompt" -Q --continue "$SESSION_NAME" 2>>"$LOG") || true
|
||||
else
|
||||
result=$(HERMES_HOME="$HOME/.timmy" hermes chat -q "$prompt" -Q 2>>"$LOG") || true
|
||||
# Name the session for future --continue calls
|
||||
local sid
|
||||
sid=$(echo "$result" | grep -o 'session_id: [^ ]*' | cut -d' ' -f2)
|
||||
if [ -n "$sid" ]; then
|
||||
HERMES_HOME="$HOME/.timmy" hermes sessions rename "$sid" "$SESSION_NAME" 2>>"$LOG" || true
|
||||
touch "$SESSION_FLAG"
|
||||
log "Created session '$SESSION_NAME' (id: $sid)"
|
||||
fi
|
||||
fi
|
||||
# Strip metadata lines from output
|
||||
echo "$result" | grep -v '^session_id: ' | grep -v '↻ Resumed session' | grep -v "^Session '" | sed '/^\[.*\] Created session/d'
|
||||
}
|
||||
|
||||
# ── Boot message ──────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user