Skip to content

harbor: let pi ask for more than 16384 output tokens - #1781

Merged
burtenshaw merged 4 commits into
openenv:mainfrom
younesbelkada:harbor/pi-max-tokens
Dec 1, 2026
Merged

burtenshaw merged 4 commits into
openenv:mainfrom
younesbelkada:harbor/pi-max-tokens

Conversation

@younesbelkada

@younesbelkada younesbelkada commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

InterceptPi writes a models.json that names the model and nothing else. For a model pi's catalog doesn't know, pi then caps every call at its own default of 16384 output tokens, whatever the deployment's --max-output-tokens is. models.json now sets maxTokens, so the capture proxy's cap is the one that applies.

Type of Change

  • Bug fix

What happened without it

pi on Terminal-Bench (base model with thinking on, proxy cap above 16384): 17 of 89 rollouts ended on a turn of almost exactly 16384 tokens, cut off mid-reasoning, and all 17 failed.

Changes

  • install_fixes.py: build_models_json(..., max_tokens=PI_MAX_TOKENS) writes "maxTokens" on the model (PI_MAX_TOKENS = 32768). InterceptPi takes an optional max_tokens in intercept_config to change it.
  • No change where the cap is lower: the capture proxy clamps every request to --max-output-tokens (clamp_output_tokens). With the default cap of 8192, requests are clamped to 8192 as before.

Test Plan

tests/envs/test_harbor_pi_max_tokens.py: the default models.json has maxTokens, and InterceptPi.setup writes the default or the configured max_tokens.

PYTHONPATH=src:envs uv run pytest tests/envs/test_harbor_pi_max_tokens.py tests/envs/test_harbor_seams.py tests/envs/test_harbor_install_fixes.py

40 passed. ruff format --check, ruff check and usort check are clean.

Used in production as a runtime patch (maxTokens: 32768) for pi GRPO training and Terminal-Bench evals.

RFC Status

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

🤖 Generated with Claude Code


Note

Low Risk
Scoped Harbor/pi config wiring with tests; no auth or shared proxy logic changes beyond requesting a higher output token ceiling when allowed.

Overview
Fixes pi (Terminal-Bench / Harbor) cutting thinking rollouts at 16384 output tokens when the model isn’t in pi’s catalog. build_models_json now writes maxTokens on the custom provider model (default PI_MAX_TOKENS = 32768), and InterceptPi.setup honors an optional max_tokens in intercept_config.

Behavior elsewhere is unchanged: the capture proxy still clamps to --max-output-tokens, so the effective limit remains the lower of pi’s request and the deployment cap.

Adds tests/envs/test_harbor_pi_max_tokens.py for default and configured limits in the written models.json.

Reviewed by Cursor Bugbot for commit d325556. Bugbot is set up for automated code reviews on this repo. Configure here.

InterceptPi's models.json named the model and nothing else, so pi capped every
call at its own default of 16384 output tokens, below a deployment's
--max-output-tokens. A thinking model's turn then stopped mid-reasoning.

models.json now sets maxTokens (32768, or intercept_config["max_tokens"]). The
capture proxy still clamps every request to its own cap, so nothing changes
where that cap is lower.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

The docs for this pull request are available at https://openenv.github.io/OpenEnv/pr-preview/pr-1781/ (commit d325556). The preview may take a minute to update and is removed when the pull request closes.

burtenshaw and others added 3 commits December 1, 2026 12:16
…igher

Above PI_MAX_TOKENS (or with no cap) pi still asks for PI_MAX_TOKENS, so the
proxy's cap is not what applies there; the lower of the two is.

Co-authored-by: Cursor <cursoragent@cursor.com>
@burtenshaw
burtenshaw merged commit 257210c into openenv:main Dec 1, 2026
17 checks passed
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.

2 participants