Hermes Agent - Ollama Server Check
06/12/2026, Fri
Categories:
#Shell
Check for Ollama Server before hermes --tui Starts
Since Hermes doesn't warn you if you don't have an active local end point when you are set up to use a local model in the --tui mode, you would need a way to remind yourself if the ollama service is running before use.
One can certainly make the ollama server run on system start up, but this might excessive when you don't plan on using ollama for hermes all the time.
A technique to solve the issue of forgetting to start up the ollama server is to wrap the hermes command and peform the checks on it before hermes can execute.
hermes() {
local requires_ollama=false
# Check if --tui, --cli, or -c is in the arguments
for arg in "$@"; do
if [[ "$arg" == "--tui" ]] || [[ "$arg" == "--cli" ]] || [[ "$arg" == "-c" ]]; then
requires_ollama=true
break
fi
done
# No arguments were passed means ollama is still required
# because hermes defaults to using the --tui
if [[ $# -eq 0 ]]; then
set -- --tui
requires_ollama=true
fi
# Only check/wait for Ollama if using TUI, CLI mode, or short -c option
if [[ "$requires_ollama" == "true" ]]; then
local max_wait=3
local waited=0
# Check if Ollama by checking the server url
while ! curl -s http://localhost:11434/api/tags > /dev/null 2>&1; do
if [[ $waited -ge $max_wait ]]; then
echo "ERROR: Ollama not responding after $max_wait seconds" >&2
echo "Please start ollama with: ollama serve" >&2
return 1
fi
# Note: Fish 'set_color' is replaced here with plain text.
# For yellow text in Bash, you can use \e[33m as shown below (optional):
# echo -ne "\e[33mWaiting for ollama... ($waited/$max_wait)\e[0m\n"
echo "Waiting for ollama... ($waited/$max_wait)"
sleep 1
((waited++))
done
# Ollama is ready
if [[ $waited -gt 0 ]]; then
# Note: Fish 'set_color green' removed. Optional color code below:
# echo -e "\e[32mOllama is ready!\e[0m"
echo "Ollama is ready!"
fi
fi
# Call the actual 'hermes' binary with all arguments
command hermes "$@"
}
Here is a fish shell version of the bash script.
function hermes
# Check if --tui, --cli, or -c is in the arguments
set requires_ollama false
for arg in $argv
if test "$arg" = "--tui" -o "$arg" = "--cli" -o "$arg" = "-c"
set requires_ollama true
break
end
end
# No arguments were passed means ollama is still requred
# because hermes defaults to using the --tui
if test (count $argv) -eq 0
set argv --tui
set requires_ollama true
end
# Only check/wait for Ollama if using TUI, CLI mode, or short -c option
if test "$requires_ollama" = true
# Wait for ollama with specified timeout
set max_wait 3
set waited 0
# Check if Ollama by checking the server url
while not curl -s http://localhost:11434/api/tags > /dev/null 2>&1
if test $waited -ge $max_wait
echo "ERROR: Ollama not responding after $max_wait seconds" >&2
echo "Please start ollama with: ollama serve" >&2
return 1
end
echo "Waiting for ollama... ($waited/$max_wait)" | set_color yellow
sleep 1
math $waited + 1 | read waited
end
# Ollama is ready
if test $waited -gt 0
echo "Ollama is ready!" | set_color green
end
end
# Call the actual 'hermes' binary with all arguments
command hermes $argv
end