Repository navigation
fix(agent_sandbox): Ovis listens on all interfaces when herdr starts it - #343
Merged
Merged
Conversation
The start command wrote HOST=0.0.0.0 to ~/.config/ovis/env. herdr starts Ovis with HERDR_PLUGIN_CONFIG_DIR set to its own config directory for the plugin, and Ovis reads `env` from there. That directory was empty, so Ovis defaulted to HOST=127.0.0.1 and the ovis-relay sidecar got an empty reply. Ovis 0.5.9 reads ~/.config/ovis/env only when started from a shell and the herdr directory has no `env`. Write the file where `herdr plugin config-dir devswha.ovis` says, which needs no running server, with the literal path as the fallback. Without OVIS_TOKEN the file is still left without HOST, so Ovis stays on loopback. On the host a hand-started socat still held 127.0.0.1:17317 ahead of the relay's port forward. `agent.sh ovis` missed it because it matched the command line `socat TCP-LISTEN:<port>`, and Homebrew's binary is `socat1`. Find it by its listening socket instead (lsof, pgrep as the fallback), stop it, and restart the relay so its forward takes the port. `agent.sh ovis status` names such a process. The failure message points at the right settings file and says how to restart Ovis without ending herdr sessions. The README gives the host address, 127.0.0.1:17317. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
arniwesth
approved these changes
Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After #342 Ovis still could not be reached from the Mac or the phone, for two reasons.
HOST=0.0.0.0to~/.config/ovis/env. herdr starts Ovis withHERDR_PLUGIN_CONFIG_DIRset to herdr's own configdirectory for the plugin, and Ovis reads its settings from there. That directory was empty, so Ovis
defaulted to
127.0.0.1, and theovis-relaysidecar from fix(agent_sandbox): publish Ovis through an ovis-relay sidecar #342 got an empty reply.127.0.0.1:17317ahead of the relay's port forward.
agent.sh ovisis meant to stop that process, but it missed it.This PR writes the settings where Ovis reads them, makes
agent.sh ovisfind and stop the old relay, andsays in the README which address to use on the host.
Changes
agent_sandbox/docker-compose.yml: theagentservice's start command writesenvinto$(herdr plugin config-dir devswha.ovis), falling back to the literal~/.config/herdr/plugins/config/devswha.ovis.herdr plugin config-dirneeds no running server, and the command runs before herdr starts.[[startup]]entry passes the directory inHERDR_PLUGIN_CONFIG_DIR. Anovis startfrom a shell, which is whatagent.sh ovisruns, asksherdr plugin config-dirand uses the directory once it holds anenvfile.OVIS_TOKEN, the file is created with noHOSTline, and Ovis stays onloopback.
agent_sandbox/agent.sh:ovis_stray_socat: finds a socat by the socket it listens on (lsof … -sTCP:LISTEN -t, thenps -o comm=), withpgrep -if "socat.*listen:<port>"as the fallback on a host without lsof. The oldcheck was
pgrep -f "socat TCP-LISTEN:<port>". It misses Homebrew's binary, which is namedsocat1,and any command line with options or a lowercase address before the listen address.
agent.sh ovisstops such a process, then runscompose restart ovis-relayso the relay's portforward takes the freed port. Only the relay restarts; the agent and its herdr sessions keep running.
agent.sh ovis statusnames a socat that holds the port.that keeps herdr sessions running:
agent.sh run ovis stop && agent.sh ovis.agent_sandbox/README.md: on the host, openhttp://127.0.0.1:17317. It also says why the containerIP and port 7317 are the wrong address, and what happens to a hand-started relay.
Governing docs
None directly. This corrects #340 and #342 in
.devcontainer/agent_sandbox/and keeps their fail-closedrule: Ovis leaves loopback only when
OVIS_TOKENis set.Predicted outcome
0.0.0.0:7317with no hand step./proc/net/tcpshows00000000:1C95listening.curl http://ovis-relay:7317/api/healthreturns 200.agent.sh ovisstops it. Thencurl http://127.0.0.1:17317/api/healthon the host returns 200.
OVIS_TOKEN, Ovis stays on127.0.0.1.Test evidence
Run in the
agent_confinedcontainer, plus host commands the operator ran on the Mac and pasted back.HOST=127.0.0.1andHERDR_PLUGIN_CONFIG_DIRset to~/.config/herdr/plugins/config/devswha.ovis, an empty directory.~/.config/ovis/envheldHOST=0.0.0.0./proc/net/tcpshowed it listening on0100007F:1C95(127.0.0.1:7317).curl http://ovis-relay:7317/api/healthgot an empty reply.envand.envfromHERDR_PLUGIN_CONFIG_DIR, and only fromherdr plugin config-diror~/.config/oviswhen that variable is unset. The plugin'sstarttakesHOSTfrom what it read, defaulting to127.0.0.1, and passes it to the server it spawns.envfile to herdr's directory, then restarted Ovis with herdr's own plugin actions(
herdr plugin action invoke stop|start --plugin devswha.ovis).HOST=0.0.0.0and00000000:1C95, withovis statusshowingconfig: …/devswha.ovis/env./returned 200text/htmland/api/healthreturned 200./api/sessionswithno token returned 401.
curl http://127.0.0.1:17317/api/healthgaveEmpty reply from server.curl http://<container IP>:7317/api/healthreturned 200.lsof -nP -iTCP:17317 -sTCP:LISTENshowedsocat1 … TCP 127.0.0.1:17317 (LISTEN), whiledocker psshowedovis-relaywith127.0.0.1:17317->7317/tcp.docker restarton the relay andagent.sh ovis, Ovis works on the Macand on the phone (operator's report).
$$unescaped, and rununder a scratch
HOME:…/herdr/plugins/config/devswha.ovis/env, mode 600, holdsHOST=0.0.0.0andPORT=7317.PATH: the fallback path.ovis_stray_socat: tested with a copy ofpython3namedsocat1, listening on a spare port, withthe command line
socat1 … -d tcp-listen:<port>,fork …, which the old pattern does not match. Thefunction returned that PID, and returned nothing for Ovis's port 7317. This exercised the
pgrepfallback, because the container has no
lsof.bash -n agent.shpasses.lsofpath on macOS. The flags are the samelsof -nP -iTCP:17317 -sTCP:LISTENthe operator ran,plus
-t.compose restart ovis-relayafter a socat is stopped. The operator randocker restarton the relayby hand.
container.
shellcheck: not installed here.🤖 Generated with Claude Code