Skip to content

Add tuned-config retrial levers: respect-requested-model, static cluster pin, tool_result tier ceiling - #902

Open
EllAchE wants to merge 1 commit into
workweave:mainfrom
EllAchE:tuned-config-retrial-levers
Open

Add tuned-config retrial levers: respect-requested-model, static cluster pin, tool_result tier ceiling#902
EllAchE wants to merge 1 commit into
workweave:mainfrom
EllAchE:tuned-config-retrial-levers

Conversation

@EllAchE

@EllAchE EllAchE commented Aug 12, 2026

Copy link
Copy Markdown

Summary

Bundles three independent, default-off env-flag-gated features built for the weave-router-tuned-config-retrial evaluation — a re-trial of the router against real agent traffic to see whether tuning these levers changes a prior DROP verdict.

  • ROUTER_RESPECT_REQUESTED_MODEL — serve a client's own requested model verbatim when it's on the operator's honor list, bypassing planner/scorer.
  • ROUTER_STATIC_CLUSTER_PIN — pin a request's nearest cluster directly to a configured model, skipping blendScoresV2, to measure pinning against the scorer's own latency overhead.
  • ROUTER_TOOL_RESULT_TIER_CEILING — exclude every model above the turn's requested-model tier, applied only to ToolResult turns before the scorer runs, leaving MainLoop free to upshift.

Each flag defaults to false/off and is independently toggleable; none change default routing behavior on their own. Documented in docs/CONFIGURATION.md.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./... (full repo, clean)
  • New table-driven tests for honoredRequestedModel, applyToolResultTierCeiling, and staticClusterPinFor

…ter pin, tool_result tier ceiling

Bundles three independent, default-off env-flag-gated features built for the
weave-router-tuned-config-retrial evaluation (S-133259) — a re-trial of the
router against real agent traffic to see whether tuning these levers changes
the prior DROP verdict:

- ROUTER_RESPECT_REQUESTED_MODEL: serve a client's own requested model
  verbatim when it's on the operator's honor list, bypassing planner/scorer.
- ROUTER_STATIC_CLUSTER_PIN: pin a request's nearest cluster directly to a
  configured model, skipping blendScoresV2, to measure pinning against the
  scorer's own latency overhead.
- ROUTER_TOOL_RESULT_TIER_CEILING: exclude every model above the turn's
  requested-model tier, applied only to ToolResult turns before the scorer
  runs, leaving MainLoop free to upshift.

Each flag defaults to false/off and is independently toggleable; none change
default routing behavior on their own.
@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown

PR author is not in the allowed authors list.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 54d7f3a. Configure here.

res.HardPinned = true
res.PinTier = reasonRequestedModelRespected
return res, nil
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Force-model loses to honor path

High Severity

honoredRequestedModel returns before session-pin lookup, so a live ReasonUserForceModel pin is never consulted when the client's RequestedModel is on the honor list. Explicit /force-model and x-weave-force-model choices are silently overridden for that turn.

Fix in Cursor Fix in Web

Triggered by learned rule: Force-model and user-facing model commands must resolve via catalog, not assume default provider

Reviewed by Cursor Bugbot for commit 54d7f3a. Configure here.

Comment thread internal/proxy/service.go
}
}
return out
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tier ceiling undone by fit-check

High Severity

applyToolResultTierCeiling only augments ExcludedModels, but the session-pin fit-check treats non-policy entries there as liftable context-overflow exclusions. An above-ceiling sticky pin that still fits the window is pruned back into eligibility and reused, defeating the documented ceiling.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by learned rule: Context window pre-filter must be wired in both proxy surfaces using FullTokenEstimate

Reviewed by Cursor Bugbot for commit 54d7f3a. Configure here.

Comment thread internal/proxy/service.go
"excluded_count", len(excluded)-before,
)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ceiling missing on OpenAI path

Medium Severity

applyToolResultTierCeiling is applied only in ProxyMessages before building ExcludedModels. ProxyOpenAIChatCompletion still builds its exclusion set from context-overflow and Gemini filters alone, so ToolResult turns on that surface ignore ROUTER_TOOL_RESULT_TIER_CEILING.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by learned rule: Context window pre-filter must be wired in both proxy surfaces using FullTokenEstimate

Reviewed by Cursor Bugbot for commit 54d7f3a. Configure here.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Thank you so much for this — the three levers here are genuinely useful for routing experiments, and the design instinct behind them (default-off, documented, one env var per lever) is exactly right. I've rewritten the change to match some internal conventions and rebased it onto current main in #916, which credits you as co-author.

Please don't read this as anything you did wrong. Most of what follows comes from conventions that live in our AGENTS.md files and from main moving underneath your branch — none of it is discoverable from the outside, and the fact that it needed a rewrite rather than a rejection says the substance was sound.

Main things applied, in case they're useful next time:

  • Cross-surface placement. The tier ceiling was applied in ProxyMessages, so only the Anthropic path got it. internal/proxy/AGENTS.md puts per-turn orchestration in the turn loop, so it now lives in runTurnLoop right after classification and Messages, OpenAI and Gemini share it.
  • Fail open, and don't let the fit-check undo it. Added a survivor guard so the ceiling is a no-op when no at-or-below-tier model remains, and taught the sticky-pin context-window fit-check not to lift ceiling exclusions (it evicts the pin instead). Without that, an above-ceiling pin could slip back in.
  • Precedence. An explicit user force-model pin now wins over the honor list; previously the honor path ran first and could shadow /force-model.
  • Fail fast on config. Per cmd/AGENTS.md, the composition root validates configuration at startup rather than degrading silently, so malformed ROUTER_STATIC_CLUSTER_PIN entries abort startup, while valid pins naming models absent from the catalog warn and skip.
  • Rebase drift. Your branch's fork point predates "Show routing badge only when the served model changes" (#910), so the diff reintroduced the hard-pin routing marker that PR had removed. Rebasing on main first surfaces this kind of thing early.
  • Dropped the unrelated Anthropic upstream base URL change to keep the PR single-purpose.

Really appreciate the contribution — hope you'll send more.

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