Skip to content

feat(OMN-13161): drop hardcoded delegate max_tokens constant; resolve from routing contract - #1990

Merged
jonahgabriel merged 1 commit into
devfrom
jonah/omn-13161-max-tokens-cli
Jun 15, 2026
Merged

jonahgabriel merged 1 commit into
devfrom
jonah/omn-13161-max-tokens-cli

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented Jun 15, 2026 •

Copy link
Copy Markdown
Collaborator

OMN-13161 — drop hardcoded delegate max_tokens constant (CLI side)

Ticket: OMN-13161 — "Delegation max_tokens belongs in the routing contract (per-backend, overlay-overridable) — not a CLI constant".
Companion PR (omnimarket, routing-authority resolution + per-backend bifrost_delegation.yaml max_tokens + node contract): OmniNode-ai/omnimarket#1230

This PR implements ticket item 4 (the cli_delegate.py CLI side) plus the
parallel skill_mapping.yaml delegate entry that carried the same hardcoded
default.

Problem

onex delegate injected a hardcoded DEFAULT_MAX_TOKENS = 2048 into the
dispatch payload, and the declarative onex skill delegate route carried a
hardcoded default: 2048 in skill_mapping.yaml. The token budget is
configuration and belongs on the selected backend in the routing contract
(per-backend, overlay-overridable), resolved by the delegate node after
backend selection — not as a CLI constant. The 2048 cap truncated long outputs
(a LinkedList suite was cut off) far below the local model's 128k window.

Change

  • src/omnibase_infra/cli/cli_delegate.py
    • Removed DEFAULT_MAX_TOKENS = 2048 (and its __all__ entry).
    • --max-tokens default → None (no show_default); help text updated to
      "optional explicit override; omit to let the delegate node resolve
      per-backend from its routing contract".
    • _write_payload now omits the max_tokens key entirely when it is
      None, so the node resolves the budget per-backend (relies on the
      omnimarket fix(ci): re-trigger auto-merge after review and checks complete [OMN-7786] #1230 resolution seam). Signatures widened to int | None.
    • Docstring/comments updated to drop the "historical delegate-shim default"
      reference; documented the omit-on-None behavior.
  • src/omnibase_infra/cli/skill_mapping.yaml
    • Delegate max-tokens arg loses default: 2048. Per ModelSkillArgSpec, a
      None default means the field is omitted from the payload so the node
      supplies its own — same per-backend resolution path.
  • Tests updated for the new None-default / omitted-key behavior; the explicit
    --max-tokens override path still asserts the key is present in the payload.

--max-tokens remains an optional explicit override: when passed, the value is
included in the payload exactly as before.

Verification (run in the worktree off origin/dev)

$ uv run ruff format src/ tests/ && uv run ruff check --fix src/ tests/
4112 files left unchanged
All checks passed!

$ uv run mypy src/omnibase_infra/ --strict
Success: no issues found in 2441 source files

$ uv run pytest tests/unit/cli/test_cli_delegate.py tests/unit/cli/test_cli_skill.py \
    tests/unit/validation/test_validator_defaults.py::TestUnionCountRegressionGuard -q
42 passed in 3.67s

$ uv run pytest tests/unit -n auto -q
20489 passed, 15 skipped  (after fix)
# 2 pre-existing/env-only failures NOT introduced by this PR:
#  - test_validation/test_validator_defaults union-count guard: fixed in this PR
#    (typed payload dict as dict[str, object] instead of an inline str | int union).
#  - tests/unit/verification/test_cli.py::TestCLIMain::test_registration_only:
#    fails identically on origin/dev baseline; it asserts exit 1/2 when no runtime
#    DB is configured, but this dev machine reaches the .201 LAN Postgres so the
#    check succeeds (exit 0). Environment-only; passes in CI. Untouched by this PR.

$ pre-commit run --files <changed files>
All hooks Passed (no failures)

The full tests/ run (serial) exceeds the local 10-minute harness window; the
unit suite was run in parallel (-n auto) and is green except for the
documented env-only verification-CLI test. CI is the authority for the full
green gate.

dod_evidence (OMN-13161)

DoD per the ticket: zero hardcoded max_tokens constants in the CLI; --max-tokens
default None (omitted = routing authority decides); optional explicit override
only; no env var introduced. This PR satisfies the CLI-side DoD items:

  • DEFAULT_MAX_TOKENS = 2048 removed from cli_delegate.py (grep-verified: no
    remaining DEFAULT_MAX_TOKENS reference in cli_delegate.py).
  • --max-tokens default is now None; the key is omitted from the dispatch
    payload when no override is supplied (unit-test asserted, both routes).
  • skill_mapping.yaml delegate max-tokens default: 2048 removed.
  • No env var introduced for the limit.

The per-backend resolution seam (bifrost_delegation.yaml max_tokens +
node_delegate_skill_orchestrator dispatch resolution) is the companion omnimarket
PR #1230 (ticket items 1-3, 5). This CLI PR relies on that seam: when the CLI
omits max_tokens, the node resolves it per-backend.

Receipt Gate / Evidence-Source

This PR pairs with the OCC evidence record for OMN-13161, authored once the
companion omnimarket PR #1230 is green (the standard cross-repo OCC pairing for
this ticket family — cf. OMN-13159 / OCC#2647 which bound omnimarket #1228 +
omnibase_infra #1989). The Evidence-Source: OCC#<num> line will be added when
the OCC evidence PR is minted. Not faking an OCC number here.


Evidence-Ticket: OMN-13161
Evidence-Source: OCC#2651

… from routing contract

Remove DEFAULT_MAX_TOKENS = 2048 from cli_delegate.py and the hardcoded
default: 2048 from the delegate entry in skill_mapping.yaml. Both CLI
routes (onex delegate and onex skill delegate) now omit max_tokens from
the dispatch payload when --max-tokens is not passed, so the delegate
node resolves the response budget per-backend from its routing contract.

--max-tokens remains an optional explicit override: when supplied, the
value is included in the payload as before.

- cli_delegate.py: --max-tokens default None; _write_payload omits the
  key when None; signatures widened to int | None; docstrings/comments
  updated to drop the 'historical delegate-shim default' reference.
- skill_mapping.yaml: delegate max-tokens arg loses 'default: 2048' so
  the field is omitted (per ModelSkillArgSpec: None default => field
  omitted, node supplies its own).
- tests updated for the new None-default / omitted-key behavior; explicit
  override path still asserts max_tokens present in the payload.
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jonahgabriel, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 2 hours, 5 minutes, and 38 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 516027e0-f1aa-4749-ba1e-4114dc011170

📥 Commits

Reviewing files that changed from the base of the PR and between adaf9ce and 9169012.

📒 Files selected for processing (4)
  • src/omnibase_infra/cli/cli_delegate.py
  • src/omnibase_infra/cli/skill_mapping.yaml
  • tests/unit/cli/test_cli_delegate.py
  • tests/unit/cli/test_cli_skill.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonah/omn-13161-max-tokens-cli

Comment @coderabbitai help to get the list of available commands and usage tips.

@jonahgabriel
jonahgabriel added this pull request to the merge queue Jun 15, 2026
Merged via the queue into dev with commit 5605681 Jun 15, 2026
92 of 96 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/omn-13161-max-tokens-cli branch June 15, 2026 23:20
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