Skip to content

[WIP] Fix Ollama port for default models to check from env before using 11434 - #519

Merged
Nicola Franco (franconicola) merged 1 commit into
mainfrom
claude/check-ollama-port-env
Jul 26, 2026
Merged

[WIP] Fix Ollama port for default models to check from env before using 11434#519
Nicola Franco (franconicola) merged 1 commit into
mainfrom
claude/check-ollama-port-env

Conversation

@Claude

@Claude Claude AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.


This section details on the original issue you should resolve

<issue_title>Ollama port for default models must be checked from env before using 11434</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @claude[agent] in this section)

Comment thread hackagent/config.py Fixed
Comment thread hackagent/config.py Fixed
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.74468% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
hackagent/attacks/techniques/pair/attack.py 50.00% 1 Missing ⚠️
hackagent/cli/commands/examples.py 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@franconicola

Copy link
Copy Markdown
Member

@claude[agent] fix the CI Checks / Commit Messages and the suggestions from co-pilot

…11434

Check OLLAMA_BASE_URL, OLLAMA_API_BASE and OLLAMA_HOST before falling back
to http://localhost:11434, and reuse the resolved value for the local model,
embedder, classifier and attack defaults.

Co-authored-by: franconicola <51865029+franconicola@users.noreply.github.com>
@Claude
Claude AI force-pushed the claude/check-ollama-port-env branch from 7e0ce66 to 33d3989 Compare July 26, 2026 13:03
@franconicola
Nicola Franco (franconicola) temporarily deployed to claude/check-ollama-port-env - Docs PR #519 July 26, 2026 13:03 — with Render Destroyed
@Claude

Claude AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

@claude[agent] fix the CI Checks / Commit Messages and the suggestions from co-pilot

Done in 33d3989. Squashed the branch into a single commitizen/gitmoji-compliant commit (🐛 fix(config): ...) — the Commit Messages check now passes. Also addressed the code-quality comments by exporting the embedder defaults (DEFAULT_EMBEDDER_ENDPOINT, DEFAULT_EMBEDDER_OPENAI_ENDPOINT and siblings) in hackagent/config.py's __all__ rather than deleting the constants, since they're part of the module's public defaults surface.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.openai.com
    • Triggering command: /home/REDACTED/work/hackagent/hackagent/.venv/bin/pytest pytest tests/unit -q --deselect tests/unit/datasets/test_dataset_integrity.py (dns block)
  • gitlab.com
    • Triggering command: /home/REDACTED/work/hackagent/hackagent/.venv/bin/pytest pytest tests/unit -q --deselect tests/unit/datasets/test_dataset_integrity.py (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@franconicola
Nicola Franco (franconicola) marked this pull request as ready for review July 26, 2026 13:24
Copilot AI review requested due to automatic review settings July 26, 2026 13:24

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@franconicola
Nicola Franco (franconicola) merged commit 082396e into main Jul 26, 2026
25 checks passed
@franconicola
Nicola Franco (franconicola) deleted the claude/check-ollama-port-env branch July 26, 2026 13:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #483 by centralizing Ollama endpoint resolution so default model endpoints respect environment variables (instead of always defaulting to http://localhost:11434), and updates callers + docs accordingly.

Changes:

  • Add resolve_ollama_base_url() to compute the Ollama base URL from env (OLLAMA_BASE_URL, OLLAMA_API_BASE, OLLAMA_HOST) with normalization.
  • Replace hardcoded http://localhost:11434 defaults across router/CLI/attack configs with resolved defaults/constants.
  • Add unit tests and documentation for non-default Ollama ports.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/test_config.py Adds unit tests covering env var precedence and normalization for Ollama base URL resolution.
hackagent/router/tracking/category_classifier.py Uses the centralized default category-classifier endpoint constant instead of hardcoding localhost:11434.
hackagent/router/_chat_registration.py Routes Ollama endpoint normalization through resolve_ollama_base_url() for consistent env-aware defaults.
hackagent/config.py Introduces env-aware Ollama base URL resolution and updates default endpoints to be derived from it.
hackagent/cli/commands/scan.py Makes provider endpoint selection fall back to the centralized Ollama base URL resolver.
hackagent/cli/commands/examples.py Uses resolve_ollama_base_url() for example/preflight/default endpoints instead of hardcoded localhost.
hackagent/attacks/techniques/pair/attack.py Replaces attacker/judge default endpoints with DEFAULT_LOCAL_MODEL_ENDPOINT.
hackagent/attacks/techniques/indirect_prompt_injection/config.py Uses DEFAULT_EMBEDDER_OPENAI_ENDPOINT for embedder endpoint defaults.
hackagent/attacks/techniques/indirect_prompt_injection/attack.py Uses DEFAULT_EMBEDDER_OPENAI_ENDPOINT as the fallback embedder endpoint.
hackagent/attacks/techniques/advprefix/config.py Replaces hardcoded generator/judge endpoints with DEFAULT_LOCAL_MODEL_ENDPOINT.
docs/docs/agents/ollama.mdx Documents env vars and behavior for non-default Ollama ports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hackagent/config.py
Comment on lines +52 to +55
# Only append the default port for a bare http host (no port, not IPv6).
# https values are left alone so they keep the implicit 443.
if scheme == "http" and ":" not in authority and not authority.endswith("]"):
authority = f"{authority}:{DEFAULT_OLLAMA_PORT}"
Comment on lines +233 to +234
A value without a scheme defaults to `http://`, and a value without a port
falls back to `11434`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ollama port for default models must be checked from env before using 11434

3 participants