Skip to content
Closed
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
23 changes: 23 additions & 0 deletions tests/tools/test_cronjob_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,26 @@ def test_update_can_clear_skills(self):
assert updated["success"] is True
assert updated["job"]["skills"] == []
assert updated["job"]["skill"] is None

def test_create_with_string_repeat_is_coerced_to_int(self):
"""LLMs may pass repeat as a string despite the schema declaring integer."""
result = json.loads(
cronjob(
action="create",
prompt="Limited task",
schedule="every 1h",
repeat="3",
)
)
assert result["success"] is True
assert result["repeat"] == "3 times"

def test_update_with_string_repeat_is_coerced_to_int(self):
created = json.loads(
cronjob(action="create", prompt="Check", schedule="every 1h")
)
updated = json.loads(
cronjob(action="update", job_id=created["job_id"], repeat="5")
)
assert updated["success"] is True
assert updated["job"]["repeat"] == "5 times"
7 changes: 7 additions & 0 deletions tools/cronjob_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ def cronjob(
del task_id # unused but kept for handler signature compatibility

try:
# Coerce repeat to int — LLMs may pass it as a string despite the
# schema declaring "type": "integer", which would crash the <= 0
# comparisons downstream (TypeError: '<=' not supported between
# instances of 'str' and 'int').
if repeat is not None:
repeat = int(repeat)

normalized = (action or "").strip().lower()

if normalized == "create":
Expand Down
Loading