Created
September 4, 2026 08:23
-
-
Save AlbertoBarrago/e3aee322928c8cc856517f8cd9d2cd37 to your computer and use it in GitHub Desktop.
Universal launcher for AI agents running through Ollama.
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
| #!/usr/bin/env bash | |
| set -o pipefail | |
| VERSION="0.1.0" | |
| DEFAULT_MODEL="${AGENT_O_MODEL:-qwen3.5}" | |
| CLAUDE_CONTEXT="${CLAUDE_CODE_MAX_CONTEXT_TOKENS:-1000000}" | |
| SUPPORTED_AGENTS=( | |
| claude | |
| codex | |
| opencode | |
| droid | |
| ) | |
| usage() { | |
| cat <<EOF | |
| agent-o v${VERSION} | |
| Universal launcher for AI agents running through Ollama. | |
| USAGE | |
| agent-o <agent> [model] [-- agent-args...] | |
| agent-o <agent> -m <model> [-- agent-args...] | |
| COMMANDS | |
| list List supported agents | |
| models List local Ollama models | |
| help Show this help | |
| version Show version | |
| AGENTS | |
| claude | |
| codex | |
| opencode | |
| droid | |
| OPTIONS | |
| -m, --model MODEL Select Ollama model | |
| -h, --help Show help | |
| ENVIRONMENT | |
| AGENT_O_MODEL | |
| Default model. | |
| Current: ${DEFAULT_MODEL} | |
| CLAUDE_CODE_MAX_CONTEXT_TOKENS | |
| Claude Code maximum context. | |
| Current: ${CLAUDE_CONTEXT} | |
| EXAMPLES | |
| agent-o claude | |
| agent-o claude qwen3.5 | |
| agent-o claude -m qwen3.5 | |
| agent-o codex qwen3.5 | |
| agent-o opencode qwen3.5 | |
| agent-o claude qwen3.5 -- --dangerously-skip-permissions | |
| AGENT_O_MODEL=qwen3.5 agent-o claude | |
| EOF | |
| } | |
| die() { | |
| echo "agent-o: $*" >&2 | |
| exit 1 | |
| } | |
| command_exists() { | |
| command -v "$1" >/dev/null 2>&1 | |
| } | |
| is_supported_agent() { | |
| local wanted="$1" | |
| local agent | |
| for agent in "${SUPPORTED_AGENTS[@]}"; do | |
| [[ "$agent" == "$wanted" ]] && return 0 | |
| done | |
| return 1 | |
| } | |
| list_agents() { | |
| printf '%s\n' "${SUPPORTED_AGENTS[@]}" | |
| } | |
| list_models() { | |
| command_exists ollama || die "ollama is not installed or not in PATH" | |
| ollama list | |
| } | |
| launch() { | |
| local agent="$1" | |
| local model="$2" | |
| shift 2 | |
| echo "agent : $agent" | |
| echo "model : $model" | |
| echo | |
| case "$agent" in | |
| claude) | |
| CLAUDE_CODE_MAX_CONTEXT_TOKENS="$CLAUDE_CONTEXT" \ | |
| ollama launch claude --model "$model" -- "$@" | |
| ;; | |
| codex) | |
| ollama launch codex --model "$model" -- "$@" | |
| ;; | |
| opencode) | |
| ollama launch opencode --model "$model" -- "$@" | |
| ;; | |
| droid) | |
| ollama launch droid --model "$model" -- "$@" | |
| ;; | |
| *) | |
| die "unsupported agent: $agent" | |
| ;; | |
| esac | |
| } | |
| main() { | |
| command_exists ollama || die "ollama is not installed or not in PATH" | |
| if [[ $# -eq 0 ]]; then | |
| usage | |
| exit 0 | |
| fi | |
| case "$1" in | |
| help|-h|--help) | |
| usage | |
| exit 0 | |
| ;; | |
| version|-v|--version) | |
| echo "agent-o $VERSION" | |
| exit 0 | |
| ;; | |
| list) | |
| list_agents | |
| exit 0 | |
| ;; | |
| models) | |
| list_models | |
| exit 0 | |
| ;; | |
| esac | |
| local agent="$1" | |
| shift | |
| is_supported_agent "$agent" || | |
| die "unsupported agent '$agent'. Run 'agent-o list'." | |
| local model="$DEFAULT_MODEL" | |
| # Explicit model option | |
| if [[ "${1:-}" == "-m" || "${1:-}" == "--model" ]]; then | |
| [[ -n "${2:-}" ]] || die "missing model after $1" | |
| model="$2" | |
| shift 2 | |
| # Or positional model: | |
| # agent-o claude qwen3.5 | |
| elif [[ $# -gt 0 && "$1" != "--" ]]; then | |
| model="$1" | |
| shift | |
| fi | |
| # Remove optional argument separator | |
| if [[ "${1:-}" == "--" ]]; then | |
| shift | |
| fi | |
| launch "$agent" "$model" "$@" | |
| } | |
| main "$@" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chmod +x agent-o
sudo mv agent-o /usr/local/bin/
agent-o help