Skip to content

feat(budget): define model budget contract#924

Closed
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/model-budget-contract
Closed

feat(budget): define model budget contract#924
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/model-budget-contract

Conversation

@luoye520ww

Copy link
Copy Markdown
Collaborator

Problem

Kun already enforces a thread cost limit, but there is no shared contract for turn, thread, provider, agent, and workflow budgets. Different integrations could otherwise implement warning and denial semantics inconsistently.

Scope

Adds a pure model-budget contract and evaluator for the five budget scopes. It validates finite positive limits, bounded warning ratios, non-negative usage, rejects unknown fields, and returns deterministic allow/warn/deny decisions with remaining budget.

Non-goals

This PR does not change existing thread persistence, UI, model routing, provider queues, or automatic model switching. Those integrations remain separate follow-up PRs.

Tests

  • npm.cmd --prefix kun test -- tests/model-budget.test.ts (8 passed)
  • npm.cmd run typecheck
  • npm.cmd --prefix kun run typecheck
  • npm.cmd run lint
  • npm.cmd run build
  • git diff --check

Review

Completed functional, concurrency/lifecycle, data integrity, security, compatibility, and scope review. No package smoke is claimed because this PR is a pure contract module.

Issue

Part of #885

@luoye520ww

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated provider/network safeguards PR #948, which passed Typecheck, Linux, macOS, and Windows packaged checks. Closing this duplicate to keep the review surface focused.

@luoye520ww luoye520ww closed this Jul 14, 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