Skip to content

fix: accept full LLM endpoint base URLs (fold #1189) - #1238

Draft
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/1189-llm-endpoint-base-url
Draft

cursor[bot] wants to merge 3 commits into
mainfrom
cursor/1189-llm-endpoint-base-url

Conversation

@cursor

@cursor cursor Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary

On-repo fold of #1189 for the 0.6.0 cut. Accepts full base URLs in OpenAIClient / collect --llm-endpoint, validates endpoint URLs/ports (rejects credentials and query strings), and strips ANSI from CLI error matching under GITHUB_ACTIONS.

Same three commits as #1189, rebased onto current main (c32c3174). Fork #1189 was refreshed onto main (34220c4d) but fork Actions never start without Approve-and-run (this token gets 403), so this on-repo PR is how we get exact-head CI and merge into the release candidate.

Ben: merge into release. Prior APPROVEs: automation @ eccef788/8f516fc6, burtenshaw @ e421de47.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • New environment
  • Refactoring

Breaking (documented): implicit port 8000 is removed for bare hosts; callers should use http://localhost:8000 or --llm-port 8000.

Alignment Checklist

  • I have read .claude/docs/PRINCIPLES.md and this PR aligns with our principles
  • I have checked .claude/docs/INVARIANTS.md and no invariants are violated
  • Focused tests green locally (tests/core/test_llm_client.py + tests/test_cli/test_collect.py = 105 passed)

RFC Status

  • Not required (bug fix, docs, minor refactoring)

Test Plan

  • Exact-head CI on this PR
  • PYTHONPATH=src:envs pytest tests/core/test_llm_client.py tests/test_cli/test_collect.py
  • After merge: refresh Release OpenEnv 0.6.0 #1211 onto the new main tip and re-verify TestPyPI

Claude Code Review

N/A — mechanical rebase of already-reviewed #1189 for release fold.

Open in Web View Automation 

`--llm-endpoint` is documented as a URL, but OpenAIClient built its base
URL as f"{endpoint}:{port}/v1", so a URL that already named a port failed
with "Invalid port: '8000:8000'" and a URL with a path (LiteLLM proxy,
reverse-proxied vLLM, a gateway prefix) could not be expressed at all.

Parse endpoint as a URL: append /v1 only when the URL has no path, append
`port` only when the URL names none, reject a conflicting explicit port,
and raise a clear ValueError for malformed endpoints. The CLI reports
those as usage errors before writing to --output-dir, and --llm-port now
defaults to unset so full URLs without a port are left alone. The
("http://localhost", 8000) form is unchanged.

Document `openenv collect` in the CLI reference and show the self-hosted
teacher form in the SFT warmup tutorial and harness README.

Closes #1188
Address review on #1189:

- Require an http(s) scheme and a host. `ftp://host` and `http:///v1`
  used to pass validation and only fail later inside the SDK.
- Range-check the port (1-65535) whether it comes from the URL or from
  `port`/--llm-port, so both paths agree on what a valid port is.
- Reject credentials in the URL and never echo them: the endpoint is
  printed, written to metadata.json and rendered into the dataset card.
- Reject query strings and fragments. The OpenAI SDK appends the request
  path to the raw base URL, so `/v1?api-version=1` was requested as path
  `/v1` with query `api-version=1/chat/completions`. The tests that
  claimed this form worked are replaced by one that captures the URL the
  SDK actually requests through a mock transport.
- Print the resolved LLM endpoint when `openenv collect` starts and say
  in --help that --llm-port has no default, so the move away from the
  implicit 8000 is visible rather than looking like a dead server.
Typer renders usage errors in colour when GITHUB_ACTIONS or FORCE_COLOR is
set, so on CI the escape codes split "--llm-endpoint" and the error text
the new invalid-endpoint tests look for, and all six cases failed. Strip
ANSI codes before flattening the error panel.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Superseded: sibling already merged the same fold as #1237 → main 81379bd3, and refreshed #1211 to ee33f7ae. This PR is a duplicate of that work — please close when you have a click (403 for this token).

View PR

Open in Web View Automation 

Sent by Cursor Automation: Release

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Duplicate of already-merged #1237 → main 81379bd3. Please close; #1211 already refreshed and TestPyPI 0.6.0.dev121 verified.

View PR

Open in Web View Automation 

Sent by Cursor Automation: Release

This branch has not been deployed

No deployments
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.

1 participant