Skip to content

The agent that grows with you

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.ts
index 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 | null
service_tier?: string | null
cwd_explicit?: boolean | null
+ run_budget?: number | null
}
export interface CanonicalSnapshot {
session_id: string
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index 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.py
index 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 - declared
diff --git a/tui_gateway/contracts/canonical_sessions.py b/tui_gateway/contracts/canonical_sessions.py
index 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 = None
service_tier: str | None = None
cwd_explicit: bool | None = None
+ # Wall-clock budget per run in seconds (the classic CLI's `--run-budget`).
+ run_budget: float | None = None
class CanonicalResumeParams(ProfileParams):