Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/claude_agent_sdk/_internal/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,14 @@ def run_end_ceiling_ms(options_env: Mapping[str, str]) -> int:
if raw is None:
return DEFAULT_RUN_END_CEILING_MS
try:
value = int(raw)
# int() rejects CLI-compatible spellings such as "1e6"; float()
# accepts those and still parses plain integers / whitespace.
as_float = float(str(raw).strip())
except (TypeError, ValueError):
return DEFAULT_RUN_END_CEILING_MS
value = int(as_float)
if value != as_float:
return DEFAULT_RUN_END_CEILING_MS
return value if value >= 0 else DEFAULT_RUN_END_CEILING_MS


Expand Down
6 changes: 6 additions & 0 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,9 @@ class TestRunEndCeilingFromEnv:
({"CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS": "soon"}, None, 600_000),
({"CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS": "-1"}, None, 600_000),
({"CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS": ""}, "1234", 600_000),
({"CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS": "1e6"}, None, 1_000_000),
({"CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS": "1e2"}, None, 100),
({"CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS": "1.5"}, None, 600_000),
],
ids=[
"default",
Expand All @@ -1367,6 +1370,9 @@ class TestRunEndCeilingFromEnv:
"not_a_number",
"negative",
"empty_option_wins",
"scientific_1e6",
"scientific_1e2",
"fractional_rejected",
],
)
def test_parse(self, monkeypatch, options_env, ambient, expected):
Expand Down