The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): declare `run_budget` on the canonical session.create contract
Tekniume230f5ad5683
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.tsindex 30305cc0c06..ac97e39ddd7 100644--- a/apps/shared/src/gateway-contract.generated.ts+++ b/apps/shared/src/gateway-contract.generated.ts@@ -4794,6 +4794,7 @@ export interface CanonicalCreateParams {follow_profile_config?: boolean | nullservice_tier?: string | nullcwd_explicit?: boolean | null+ run_budget?: number | null}export interface CanonicalSnapshot {session_id: stringdiff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.jsonindex cb94932200b..7da7543297c 100644--- a/apps/shared/src/gateway-contract.openrpc.json+++ b/apps/shared/src/gateway-contract.openrpc.json@@ -8791,6 +8791,18 @@],"default": null,"title": "Cwd Explicit"+ },+ "run_budget": {+ "anyOf": [+ {+ "type": "number"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Run Budget"}},"title": "CanonicalCreateParams",diff --git a/tests/gateway/test_session_policy.py b/tests/gateway/test_session_policy.pyindex 6b316fc9a95..a43f2c74468 100644--- a/tests/gateway/test_session_policy.py+++ b/tests/gateway/test_session_policy.py@@ -360,3 +360,13 @@ def test_run_budget_is_a_frozen_launch_option(tmp_path):for bad in (0, -5, True, 'soon'):with pytest.raises(RuntimeStoreError, match='invalid_params'):build_policy(dict(cwd=str(tmp_path), run_budget=bad), cfg)+++def test_run_budget_passes_the_session_create_contract():+ """The canonical dispatcher refuses undeclared session.create keys before the policy sees them."""+ from tui_gateway.contracts.registry import CANONICAL_METHODS, canonical_param_problems+ from gateway.session_policy import CREATE_FIELDS+ contract = CANONICAL_METHODS['session.create']+ assert canonical_param_problems(contract, {'request_id': 'r', 'source': 'cli', 'run_budget': 120.0}) == []+ declared = set(contract.params.model_fields)+ assert CREATE_FIELDS <= declared | {'request_id'}, CREATE_FIELDS - declareddiff --git a/tui_gateway/contracts/canonical_sessions.py b/tui_gateway/contracts/canonical_sessions.pyindex 015203d4d03..75df11c6924 100644--- a/tui_gateway/contracts/canonical_sessions.py+++ b/tui_gateway/contracts/canonical_sessions.py@@ -39,6 +39,8 @@ class CanonicalCreateParams(ProfileParams):follow_profile_config: bool | None = Noneservice_tier: str | None = Nonecwd_explicit: bool | None = None+ # Wall-clock budget per run in seconds (the classic CLI's `--run-budget`).+ run_budget: float | None = Noneclass CanonicalResumeParams(ProfileParams):