Skip to content

fix(step-3.7-flash): stretch retry envelope to weather StepFun 10 RPM cap - #3497

Merged
juanmichelini merged 8 commits into
mainfrom
fix/step-3-7-flash-rpm-retry-envelope
Jun 4, 2026
Merged

juanmichelini merged 8 commits into
mainfrom
fix/step-3-7-flash-rpm-retry-envelope

Conversation

@juanmichelini

@juanmichelini juanmichelini commented Jun 3, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #3496.

Why

The OpenHands Eval Monitor shows 0% Critic 1 Acceptance for every recent litellm_proxy/step-3.7-flash run — e.g. swebench run 26911702062. The run-infer-progress.txt for that run reads output, critic1, critic2, critic3 = 0, 5, 0, 0: all 5 instances completed in critic_attempt_1 but went to output_errors.jsonl, so output.jsonl is empty and acceptance = output / critic1 = 0%. The same output=0 pattern was visible across the parallel swebench-full and swtbench-full step-3.7-flash runs.

Datadog logs from the runtime pods (service:eval-agent-server, image_tag:b0fedcd*, @levelname:ERROR) are saturated with the same exception:

litellm.RateLimitError: Error code: 429 - OpenAIException -
    request limited RPM reached, current: 11, limit: 10.
    Please top up at https://platform.stepfun.ai/top-up.

StepFun's current API tier caps step-3.7-flash at 10 RPM. The eval runs many instances in parallel, every step hammers the same RPM bucket, and the SDK's default retry envelope — num_retries=5, retry_min_wait=8, retry_max_wait=64, exponential backoff, ~3 min total — exhausts long before the bucket resets. Every conversation eventually raises LLMRateLimitError, which is recorded as an error.

What

Config-only change in .github/run-eval/resolve_model_config.py: bump the retry envelope on the step-3.7-flash entry so the SDK retry loop can outlast a fully-saturated 60 s bucket.

Setting Default step-3.7-flash
num_retries 5 12
retry_min_wait (s) 8 30
retry_max_wait (s) 64 120

num_retries, retry_min_wait, and retry_max_wait are already first-class fields on LLM (see openhands-sdk/openhands/sdk/llm/llm.py), so no SDK code changes are needed.

The test_step_3_7_flash_config test in tests/cross/test_resolve_model_config.py was updated with lower-bound assertions (≥10 / ≥15 / ≥90) so the retry envelope can't silently regress to defaults.

Verification

$ uv run pytest tests/cross/test_resolve_model_config.py -v
========================= 40 passed, 5 warnings in 0.10s =========================

To verify end-to-end, kick off a swebench Run Eval workflow with model_ids=step-3.7-flash and eval_limit=5; output.jsonl should grow in lockstep with output.critic_attempt_1.jsonl instead of staying at 0.

Out of scope

This is the cheapest fix that doesn't require infra changes. Longer-term we should also: (a) top up the StepFun tier so the model has realistic headroom, (b) add per-model concurrency limits in the eval harness so we don't oversubscribe RPM-constrained providers, and (c) have the LiteLLM proxy forward upstream Retry-After headers. Those are tracked in #3496.


This PR was opened by an AI agent (OpenHands) on behalf of @juanmichelini.

@juanmichelini can click here to continue refining the PR


Agent Server images for this PR

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python amd64, arm64 nikolaik/python-nodejs:python3.13-nodejs22-slim Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:c9cbd0b-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-c9cbd0b-python \
  ghcr.io/openhands/agent-server:c9cbd0b-python

All tags pushed for this build

ghcr.io/openhands/agent-server:c9cbd0b-golang-amd64
ghcr.io/openhands/agent-server:c9cbd0bdbd7e174e547df8b3260fb0bed0836ba5-golang-amd64
ghcr.io/openhands/agent-server:fix-step-3-7-flash-rpm-retry-envelope-golang-amd64
ghcr.io/openhands/agent-server:c9cbd0b-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:c9cbd0b-golang-arm64
ghcr.io/openhands/agent-server:c9cbd0bdbd7e174e547df8b3260fb0bed0836ba5-golang-arm64
ghcr.io/openhands/agent-server:fix-step-3-7-flash-rpm-retry-envelope-golang-arm64
ghcr.io/openhands/agent-server:c9cbd0b-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:c9cbd0b-java-amd64
ghcr.io/openhands/agent-server:c9cbd0bdbd7e174e547df8b3260fb0bed0836ba5-java-amd64
ghcr.io/openhands/agent-server:fix-step-3-7-flash-rpm-retry-envelope-java-amd64
ghcr.io/openhands/agent-server:c9cbd0b-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:c9cbd0b-java-arm64
ghcr.io/openhands/agent-server:c9cbd0bdbd7e174e547df8b3260fb0bed0836ba5-java-arm64
ghcr.io/openhands/agent-server:fix-step-3-7-flash-rpm-retry-envelope-java-arm64
ghcr.io/openhands/agent-server:c9cbd0b-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:c9cbd0b-python-amd64
ghcr.io/openhands/agent-server:c9cbd0bdbd7e174e547df8b3260fb0bed0836ba5-python-amd64
ghcr.io/openhands/agent-server:fix-step-3-7-flash-rpm-retry-envelope-python-amd64
ghcr.io/openhands/agent-server:c9cbd0b-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-amd64
ghcr.io/openhands/agent-server:c9cbd0b-python-arm64
ghcr.io/openhands/agent-server:c9cbd0bdbd7e174e547df8b3260fb0bed0836ba5-python-arm64
ghcr.io/openhands/agent-server:fix-step-3-7-flash-rpm-retry-envelope-python-arm64
ghcr.io/openhands/agent-server:c9cbd0b-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-arm64
ghcr.io/openhands/agent-server:c9cbd0b-golang
ghcr.io/openhands/agent-server:c9cbd0bdbd7e174e547df8b3260fb0bed0836ba5-golang
ghcr.io/openhands/agent-server:fix-step-3-7-flash-rpm-retry-envelope-golang
ghcr.io/openhands/agent-server:c9cbd0b-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:c9cbd0b-java
ghcr.io/openhands/agent-server:c9cbd0bdbd7e174e547df8b3260fb0bed0836ba5-java
ghcr.io/openhands/agent-server:fix-step-3-7-flash-rpm-retry-envelope-java
ghcr.io/openhands/agent-server:c9cbd0b-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:c9cbd0b-python
ghcr.io/openhands/agent-server:c9cbd0bdbd7e174e547df8b3260fb0bed0836ba5-python
ghcr.io/openhands/agent-server:fix-step-3-7-flash-rpm-retry-envelope-python
ghcr.io/openhands/agent-server:c9cbd0b-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim

About Multi-Architecture Support

  • Each variant tag (e.g., c9cbd0b-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., c9cbd0b-python-amd64) are also available if needed

Adds the step-3.7-flash model to resolve_model_config.py per ADDINGMODEL.md.

- Adds step-3.7-flash to MODELS dictionary
- Adds test_step_3_7_flash_config() test function

Fixes #3476

Co-authored-by: openhands <openhands@all-hands.dev>
Add an explicit pre-flight check, with decision matrices, for verifying
vision (multimodal input) and reasoning (reasoning_effort / extended
thinking) support when registering a new model.

The new section makes it clear that:
- Vision is gated on LiteLLM's supports_vision() metadata; if the model
  is multimodal per provider docs but LiteLLM is not yet aware, the
  vision integration test will skip (not fail) until LiteLLM is updated
  upstream. disable_vision: True should NOT be added in that case.
- reasoning_effort is auto-detected from LiteLLM's supported params;
  setting it without LiteLLM support is a no-op because drop_params=True
  strips it. Anthropic-style extended thinking is handled via
  EXTENDED_THINKING_MODELS in model_features.py.

Triggered by review feedback on PR #3477 (step-3.7-flash):
step-3.7-flash supports both vision and reasoning per StepFun/OpenRouter
docs, but LiteLLM has not mapped the model yet, so the SDK skips the
vision and Anthropic-thinking-block tests rather than failing them.

Co-authored-by: openhands <openhands@all-hands.dev>
…_body

Step 3.7 Flash exposes selectable reasoning levels (high/medium/low) via
OpenRouter, but LiteLLM does not yet expose 'reasoning_effort' as a
supported OpenAI param for 'openrouter/stepfun/step-3.7-flash'. So
pinning the top-level 'reasoning_effort' field would be dropped by
drop_params=True before send.

Use litellm_extra_body to forward OpenRouter's native reasoning block
{'reasoning': {'effort': 'high'}} to the provider directly. Same pattern
as qwen3-max-thinking, which forwards {'enable_thinking': True}.

Also update ADDINGMODEL.md so the 'Vision and Reasoning Capability
Check' decision matrix documents this passthrough fallback, and update
the test_step_3_7_flash_config assertion accordingly.

Vision is still gated on LiteLLM / proxy 'supports_vision' metadata and
cannot be force-enabled from llm_config (no opt-in flag exists; only
disable_vision to opt out), so it's left to upstream LiteLLM / proxy
updates.

Co-authored-by: openhands <openhands@all-hands.dev>
The eval LiteLLM proxy registers this model as 'step-3.7-flash' (short
alias), routing to openai/step-3.7-flash at api.stepfun.ai/v1, with
model_info.supports_vision=true already configured infra-side.

Our previous config used 'litellm_proxy/openrouter/stepfun/step-3.7-flash'.
This worked for request routing (proxy pass-through), but the SDK's
_get_model_info_from_litellm_proxy does an exact string match on
model_name == model.removeprefix('litellm_proxy/'), so it looked for
'openrouter/stepfun/step-3.7-flash' in /v1/model/info, missed the
registry entry, and fell back to LiteLLM's static metadata
(supports_vision=false). Result: vision_is_active() returned False and
the t08_image_file_viewing integration test was skipped.

Also remove the previously-added litellm_extra_body
{'reasoning': {'effort': 'high'}}: that was the OpenRouter native
reasoning block, which doesn't apply now that we're routing via
openai/... to StepFun's native API. Empirical evidence: with that opt-in,
completion tokens dropped 175k -> 85k and one behavior test regressed,
suggesting the param wasn't honored and may have perturbed behavior.

Update ADDINGMODEL.md's Vision and Reasoning Capability Check section to
document the proxy model_name alignment gotcha (the SDK's exact-string
lookup against the proxy registry) and to caution that
reasoning-passthrough keys must match the upstream the proxy actually
routes to (openai/ vs openrouter/), not just the provider's branding.

Co-authored-by: openhands <openhands@all-hands.dev>
… cap

The eval-monitor shows 0% Critic 1 Acceptance for every recent
step-3.7-flash run (swebench test/full, swtbench full): all instances
land in output_errors.jsonl, output.jsonl stays empty, so
acceptance = output / critic1 = 0%.

Datadog logs from the eval-agent-server pods are saturated with:

  litellm.RateLimitError: Error code: 429 - OpenAIException -
  request limited RPM reached, current: 11, limit: 10.

StepFun's current API tier caps step-3.7-flash at 10 RPM. The eval runs
many instances in parallel, every step hits the same RPM bucket, and the
SDK's default retry envelope (5 attempts, ~3 min total: 8/16/32/64/64s)
exhausts before the bucket resets. Every conversation eventually raises
LLMRateLimitError and gets recorded as an error.

Bump num_retries / retry_min_wait / retry_max_wait on the step-3.7-flash
entry so the SDK retry loop can outlast a fully-saturated 60s bucket.
This is a config-only change in the eval-resolver dict; these are
first-class fields on LLM (see openhands-sdk/openhands/sdk/llm/llm.py).

Closes #3496.

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

github-actions Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Python API breakage checks — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@juanmichelini
juanmichelini marked this pull request as ready for review June 4, 2026 04:46

all-hands-bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Review complete.

This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review

Taste Rating

🟢 Good taste — Clean, focused fix addressing a real operational problem.

Analysis

This PR solves a genuine production issue: parallel inference with step-3.7-flash exhausts the SDK's default retry budget (5 attempts, ~3 min total) before StepFun's 60s rate-limit bucket resets under the 10 RPM cap.

What's done well:

  1. Exact model_name matching — The config uses litellm_proxy/step-3.7-flash (proxy's registered alias) rather than the longer litellm_proxy/openrouter/stepfun/step-3.7-flash form. This ensures _get_model_info_from_litellm_proxy matches the registry entry and picks up supports_vision=true. The documentation update explains this critical detail clearly.

  2. Appropriate retry envelope — Bumping from defaults (5/8/64) to (12/30/120) provides enough headroom to outlast a fully-saturated 60s bucket under parallel load. The specific values are justified and documented.

  3. Comprehensive documentation — The ADDINGMODEL.md update adds decision matrices for vision and reasoning capability detection. While the examples use StepFun, the patterns are generalizable and teach the methodology.

  4. Flexible test assertions — Tests use >= thresholds rather than exact values, allowing for future tuning without test updates.

  5. No breaking changes — Only adds a new model entry; no existing functionality modified.

Minor Note

The 60-line documentation addition is detailed but specific to the vision/reasoning capability workflow. Consider whether this guidance belongs in ADDINGMODEL.md or a separate runbook (e.g., run-eval/CAPABILITY_CHECKLIST.md) to keep ADDINGMODEL.md focused on the model entry schema.

[RISK ASSESSMENT]

  • Overall PR: ⚠️ Risk Assessment: 🟢 LOW
  • Adding new model configuration only; no changes to existing functionality or shared code paths.
  • Well-documented with production justification linked.

This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟡 QA Report: PARTIAL

The eval resolver now accepts step-3.7-flash, reaches the LiteLLM proxy, and emits the intended alias plus 12/30/120 retry envelope; I did not run a full saturated eval.

Does this PR achieve its stated goal?

Partially verified. The PR achieves the concrete config-resolution behavior needed by Run Eval: on the base branch, MODEL_IDS=step-3.7-flash fails as an unknown model, while on this PR branch the same command resolves the model, performs a real proxy preflight successfully, and writes models_json with litellm_proxy/step-3.7-flash, num_retries: 12, retry_min_wait: 30, and retry_max_wait: 120. I could not verify the full production claim that this survives a saturated StepFun 10 RPM bucket without launching an external eval run and consuming shared LLM/provider capacity.

Phase Result
Environment Setup ✅ make build completed successfully and created the project .venv.
CI Status 🟡 Run Tests checks observed passing; several Agent Server build/push jobs were still in progress when checked.
Functional Verification ✅ Resolver before/after path works and performs a real LLM proxy preflight; saturated eval behavior not exercised.
Functional Verification

Test 1: Run Eval model resolver before/after for step-3.7-flash

Step 1 — Reproduce / establish baseline without the fix:

Checked out origin/main and ran:

MODEL_IDS=step-3.7-flash GITHUB_OUTPUT=/tmp/resolve_base.out   uv run python .github/run-eval/resolve_model_config.py

Observed:

rc=1
ERROR: Model ID 'step-3.7-flash' not found. Available models: claude-4.5-opus, claude-4.6-opus, claude-opus-4-7, ...

This confirms the base branch cannot run the eval resolver for the affected model ID at all.

Step 2 — Apply the PR's changes:

Switched back to PR head 7468b3f4a760b1d1424eb1918ec9bec837e7f1b5 on fix/step-3-7-flash-rpm-retry-envelope.

Step 3 — Re-run with the fix in place:

Ran the same resolver command:

MODEL_IDS=step-3.7-flash GITHUB_OUTPUT=/tmp/resolve_head.out   uv run python .github/run-eval/resolve_model_config.py

Observed:

rc=0
Resolved 1 model(s): step-3.7-flash

Checking proxy connectivity: https://llm-proxy.app.all-hands.dev
✓ Proxy reachable at https://llm-proxy.app.all-hands.dev

Preflight LLM check for 1 model(s)...
--------------------------------------------------
  Checking Step 3.7 Flash... (6.0s)
  ✓ Step 3.7 Flash: OK
--------------------------------------------------
✓ All 1 model(s) passed preflight check

models_json=[{"id":"step-3.7-flash","display_name":"Step 3.7 Flash","llm_config":{"model":"litellm_proxy/step-3.7-flash","temperature":0.0,"num_retries":12,"retry_min_wait":30,"retry_max_wait":120}}]

This shows the actual resolver path a Run Eval workflow uses now accepts the model, performs a real proxy-backed preflight successfully, and emits the claimed retry envelope and proxy alias.

Unable to Verify

I did not trigger a full swebench/swtbench eval or intentionally saturate StepFun's shared 10 RPM bucket. That would consume external eval/LLM resources and can take substantially longer than local QA. As a result, I verified the config passed to the runtime, but not the downstream acceptance-rate improvement under real parallel load. Future QA guidance in AGENTS.md could specify when reviewers are authorized to launch a small eval run, which benchmark/input size to use, and what resource limits are acceptable.

Issues Found

None.

This review was generated by an AI agent (OpenHands) on behalf of the user.

@juanmichelini
juanmichelini enabled auto-merge (squash) June 4, 2026 04:59
@juanmichelini

Copy link
Copy Markdown
Collaborator Author

@OpenHands fix pre commit checks

@openhands-ai

openhands-ai Bot commented Jun 4, 2026

Copy link
Copy Markdown

I'm on it! juanmichelini can track my progress at all-hands.dev

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai

openhands-ai Bot commented Jun 4, 2026

Copy link
Copy Markdown

OpenHands encountered an error: **Failed to send message to agent server: HTTP 503 error: no available server
**

See the conversation for more information.

@juanmichelini
juanmichelini merged commit 15f01f3 into main Jun 4, 2026
28 checks passed
@juanmichelini
juanmichelini deleted the fix/step-3-7-flash-rpm-retry-envelope branch June 4, 2026 05:09
pengzhang-create pushed a commit to Pyromind-Dynamics/software-agent-sdk that referenced this pull request Aug 13, 2026
… cap (OpenHands#3497)

Co-authored-by: openhands <openhands@all-hands.dev>
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.

step-3.7-flash eval: 0% Critic Acceptance because StepFun 10 RPM rate-limit exhausts the SDK retry budget

3 participants