agentscope-ai / agentscope-ai/QwenPaw

[Feature] Cron: Support direct script/shell execution task type

Aperta
#4,963 3 commenti 0 reazioni 1 assegnatario Rivendicata da @lalaliat Vedi su GitHub
enhancement
Lingua principale
Python
Stelle
34.9k
Fork
3.1k
Merge medio
1g 15h
PR unite (30g)
225

Descrizione

## Background

Currently cron tasks only support two types:
- `text`: Sends fixed content to channel
- `agent`: Sends a prompt to AI, AI processes and replies

There is no way to **directly execute a script/shell command** without going through the AI agent.

## Problem

Many scheduled tasks are pure script executions that do not need AI reasoning:
- Database backup (`bash backup.sh`)
- Data sync (`python3 sync_data.py`)
- Pet feeder stats (`python3 pet_feeder_daily.py`)
- Email report generation (`python3 email_report.py`)

Using `agent` type for these tasks has several issues:

### 1. Reliability
The agent may not actually execute the script. A pet feeder task reported `last_status: success` but never wrote data to the database. The agent received the message but did not run the `execute_shell_command` tool.

### 2. Speed
Each task goes through LLM inference (loading context + generating response), adding 30-60 seconds of unnecessary latency.

### 3. Token Cost
Even with `share_session: false`, each execution still consumes output tokens. With 10+ daily tasks, this adds up.

## Proposed Solution

Add a `script` task type:

```json
{
"task_type": "script",
"script": {
"command": "python3 /app/scripts/backup.py",
"timeout": 300,
"cwd": "/app/working"
}
}
```

CLI:
```bash
qwenpaw cron create --type script --command "python3 /app/scripts/backup.py"
```

### Behavior
- Execute command directly via subprocess
- Capture stdout/stderr
- Optionally send output to channel
- Report exit code as status
- No LLM inference needed

## Use Cases

- Database backups
- Data synchronization
- Report generation
- Memory/note sync
- Log cleanup

All tasks where output is deterministic and does not require AI reasoning.

---
*Re-submitted: original #4950 was auto-closed by bot due to >10 open issues.*

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.