Skip to content

Clean routed experts response path#1433

Draft
S1ro1 wants to merge 1 commit into
mainfrom
fix/r3-v3-routed-experts-prod-cleanup-main
Draft

Clean routed experts response path#1433
S1ro1 wants to merge 1 commit into
mainfrom
fix/r3-v3-routed-experts-prod-cleanup-main

Conversation

@S1ro1
Copy link
Copy Markdown
Contributor

@S1ro1 S1ro1 commented May 21, 2026

Summary

  • route renderer generation through the PrimeRL generate endpoint without decoding routed_experts
  • keep routed_experts as the compact opaque payload until prime-rl consumes it
  • remove the prior docs/test churn from the routed-experts diff

Verification

  • uv run --no-sync python -m compileall -q deps/verifiers/verifiers/clients/renderer_client.py deps/verifiers/verifiers/clients/openai_chat_completions_client.py deps/verifiers/verifiers/clients/openai_completions_client.py deps/verifiers/verifiers/utils/client_utils.py deps/verifiers/verifiers/utils/response_utils.py deps/verifiers/verifiers/types.py
  • uv run --no-sync ruff check deps/verifiers/verifiers/clients/renderer_client.py deps/verifiers/verifiers/clients/openai_chat_completions_client.py deps/verifiers/verifiers/clients/openai_completions_client.py deps/verifiers/verifiers/utils/client_utils.py deps/verifiers/verifiers/utils/response_utils.py deps/verifiers/verifiers/types.py

Note

Normalize routed experts data in response parsing across client types

  • Adds parse_routed_experts in response_utils.py to validate and normalize raw routed_experts dicts into a consistent RoutedExpertsPayload structure with typed data and integer shape fields.
  • Applies parse_routed_experts in from_native_response for OpenAIChatCompletionsClient, OpenAICompletionsClient, and RendererClient so ResponseTokens.routed_experts always holds a parsed structure instead of raw model_extra values.
  • Adds _generate_with_renderer to RendererClient as a new end-to-end generation path that handles renderer pool checkout, stop tokens, endpoint posting, and response parsing including routed_experts and tool calls.
  • Tightens RoutedExpertsPayload.data from Any to str | bytes | bytearray | memoryview and enables arbitrary_types_allowed on CustomBaseModel.
📊 Macroscope summarized 28b092a. 5 files reviewed, 2 issues evaluated, 0 issues filtered, 1 comment posted

🗂️ Filtered Issues

ToolCall(
id=tc.id or f"call_{i}",
name=tc.name or "",
id=f"call_{i}",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium clients/renderer_client.py:741

The tool call ID assignment in from_native_response unconditionally overwrites the original id with f"call_{i}", discarding any ID provided by the model. If downstream code matches tool results to calls using the original ID, this breaks correlation.

-                    id=f\"call_{i}\",\n+                    id=tc.get(\"id\") or f\"call_{i}\",
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file verifiers/clients/renderer_client.py around line 741:

The tool call ID assignment in `from_native_response` unconditionally overwrites the original `id` with `f"call_{i}"`, discarding any ID provided by the model. If downstream code matches tool results to calls using the original ID, this breaks correlation.

Evidence trail:
renderers/base.py lines 496-502 (ParsedToolCall dataclass with `id` field), renderers/parsing.py lines 1111-1119 (Kimi K2 sets `id=raw_id or None`), verifiers/clients/renderer_client.py line 531 (`"tool_calls": parsed.tool_calls`), verifiers/clients/renderer_client.py lines 739-750 (`id=f"call_{i}"` unconditionally overwrites), verifiers/envs/tool_env.py lines 152-163 (downstream uses `tool_call.id` for correlation)

@S1ro1
Copy link
Copy Markdown
Contributor Author

S1ro1 commented May 21, 2026

Closing this cleanup PR. The renderer-side fix is in renderers PR #54, so verifiers should stay on the normal renderers.client.generate path; prime-rl now pins renderers to that merged commit instead.

@S1ro1 S1ro1 closed this May 21, 2026
@S1ro1
Copy link
Copy Markdown
Contributor Author

S1ro1 commented May 21, 2026

Reopening while we validate the renderers-only path against the routed-experts run. Do not merge or close yet.

@S1ro1 S1ro1 reopened this May 21, 2026
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