Skip to content

Commit 23db497

Browse files
maidang-xingshiliu-yang
authored andcommitted
Refactor logging in agent loop, improve memory handling in cron service, and update job reminder message format
1 parent 7971ea2 commit 23db497

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

agent/agent_loop.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,6 @@ OPERATE_RET agent_loop_init_evt_cb(void *data)
605605
ai_mcp_server_set_tool_exec_hook(__on_tool_executed, NULL);
606606

607607
PR_DEBUG("Agent loop initialized");
608-
PR_INFO("Device Free heap %d", tal_system_get_free_heap_size());
609-
PR_INFO("Agent loop stack size %d", DUCKY_CLAW_AGENT_STACK);
610608

611609
THREAD_CFG_T thrd_param = {0};
612610
thrd_param.stackDepth = DUCKY_CLAW_AGENT_STACK;

cron_service/cron_service.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ static void cron_process_due_jobs(void)
330330
PR_WARN("Cron overdue: '%s' (%s) missed by %llds", job->name, job->id,
331331
(long long)late_secs);
332332
char *msg = (char *)claw_malloc(512);
333+
if (!msg) {
334+
PR_ERR("cron: malloc failed for overdue msg");
335+
job->enabled = false;
336+
changed = true;
337+
continue;
338+
}
333339
snprintf(msg, 512,
334340
"[Task Overdue] Task '%s' (id=%s) was scheduled at epoch %lld "
335341
"but missed its trigger window by %llds. "
@@ -342,15 +348,10 @@ static void cron_process_due_jobs(void)
342348
im_msg_t im = {0};
343349
strncpy(im.channel, "cron", sizeof(im.channel) - 1);
344350
im.content = msg;
345-
if (im.content) {
346-
(void)message_bus_push_inbound(&im);
347-
} else {
348-
PR_ERR("cron: malloc failed for overdue msg");
349-
}
351+
(void)message_bus_push_inbound(&im);
350352
/* Disable so it is not reported again on the next check */
351353
job->enabled = false;
352354
changed = true;
353-
claw_free(msg);
354355
continue;
355356
}
356357
}

tools/tool_cron.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ OPERATE_RET tool_cron_register(void)
551551
"- name (string): Descriptive name for the job.\n"
552552
"- schedule_type (string): 'every' for recurring or 'at' for one-shot.\n"
553553
"- message (string): Message content to send when the job fires.\n"
554-
"The message content is a reminder to the user to complete the task of naming, using a reminder tone."
554+
" Write it as a friendly reminder that prompts the user about the scheduled task.\n"
555555
"- interval_s (int): Interval in seconds (required for 'every' type).\n"
556556
"For 'at' type, use this workflow:\n"
557557
" 1. If the request is relative (e.g. 'in 5 minutes'), call get_current_time first.\n"

0 commit comments

Comments
 (0)