Skip to content

Per-virtual-model repetition_limit override field #69

Description

@weselben

Derived from: #60, #63

Work:

  • Add repetition_limit to the virtual-model config schema in internal/virtualmodels/.
  • Unset = inherit the global default. Set > 0 = opt-in for that model.
  • Wire through gateway.InferenceConfig.StreamRepetitionLimit so the guard sees the per-request value.
  • Add a Models-view form field next to the existing slowdown setting.

Done when: a virtual model with repetition_limit: 4 triggers on a 4-repeat loop; a sibling with no value falls back to the global default.

Activity

  1. weselben commented on Sep 1, 2026

    @weselben
    OwnerAuthor

    Scope update from #73: this task now ships two virtual-model fields, not one.

    • repetition_limit — tri-state *int (unset inherit / 0 explicit off / N on), schema pattern: RawResilienceConfig pointer style.
    • repetition_max_pattern — int, unset = inherit global (default 8), accepted range 1–64.
      Both render in the Models view next to slowdown. Validation rejects limit < 0 and pattern outside 1–64.
  2. weselben commented on Sep 1, 2026

    @weselben
    OwnerAuthor

    Repo-conformant notes:

    • Add RepetitionLimit *int and RepetitionMaxPattern *int to the virtual-model config struct in internal/virtualmodels/. Pointer type matches RawResilienceConfig (config/resilience.go) for the unset/inherit semantics.
    • Validation in internal/virtualmodels/validation.go (existing pattern): reject RepetitionLimit < 0; reject RepetitionMaxPattern outside 1..64; accept nil = inherit.
    • Wire through the orchestrator: gateway.InferenceConfig.StreamRepetitionLimit and StreamRepetitionMaxPattern (new fields). StreamChatCompletion and StreamResponses resolve the effective value per request: per-model field > virtual-model field > workflow field > global default > guard off.
    • Models-view form: two number inputs next to slowdown in the existing virtual-model form renderer. Same labels, same disabled-state handling.

    Tests: extend internal/virtualmodels/config_overlay_test.go and internal/gateway/request_model_resolution_test.go with the new fields. Pattern: table-driven, assert resolution order. Repo norm: no testify.

    Minimal-diff: one struct + two fields, one validator, two wiring sites, two form inputs.

  3. weselben commented on Sep 2, 2026

    @weselben
    OwnerAuthor

    Resolved on feat/stream-repetition-canceller (commits c98d41f, 7567c64).

    What changed:

    • internal/virtualmodels: RepetitionLimit and RepetitionMaxPattern added to types, config, validation, Mongo/SQL stores, and the admin handler form (next to slowdown).
    • config/virtualmodels.go + test: schema support for the two fields.
    • internal/virtualmodels/repetition.go: ResolveRepetitionLimit honors alias redirect -> policy -> inherit, with each field independently nullable so an explicit 0 disables the guard.
    • internal/core/request_model_resolution.go: added RepetitionLimit / RepetitionMaxPattern to RequestModelResolution.
    • internal/gateway: request_model_resolution.go resolves the override, inference_execute.go resolveEffectiveRepetition merges it (nil inherits orchestrator defaults), and StreamResult carries the final pair to WrapDeliveryStream.
    • Tests: internal/virtualmodels/repetition_test.go, internal/gateway/inference_execute_repetition_test.go, internal/gateway/request_model_resolution_test.go.

    Evidence: go test ./internal/virtualmodels/... ./internal/gateway/... green; a virtual model with repetition_limit: 4 triggers on a 4-repeat loop; no value falls back to the global default.

    🤖 Written by Kimi Code (AI agent) from the stream-repetition-canceller worktree.

  4. added a commit that references this issue on Sep 3, 2026
    d92dcdc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions