Skip to content

[Bug]: scheduler.exec() fails with "requires a request object" in v0.4.0-58 #12

@rokku-c

Description

@rokku-c

Summary

Description

scheduler.exec() fails in loader/scheduler scripts with the error:

Error: scheduler.exec requires a request object

This happens on version sdk-v0.4.0-58-gc371a82.

Steps to Reproduce

  1. Deploy an agent with a scheduler script that uses scheduler.exec():
name: test

agents:
  test-agent:
    provider: claude
    model: claude-sonnet-4-6
    image: some-guest-image:latest
    driver:
      docker: {}
    scheduler:
      enabled: true
      script: |
        scheduler.on("test.event", async function(p) {
          var r = scheduler.exec(
            "echo hello",
            { agent: "test-agent", sessionPolicy: "fresh" }
          );
          return r;
        });
  1. Apply via agent-compose up or Web UI
  2. Trigger — either:
    • Web UI: click "立即运行" on the automation task
    • API: RunAgent with schedulerId
  3. Run fails immediately

What Works

  • scheduler.log() — logging works normally
  • scheduler.interval() / scheduler.on() — callbacks are registered correctly
  • scheduler.emit() — event emission works
  • Web UI correctly identifies trigger rules after script validation

What Fails

  • scheduler.exec() inside any scheduler callback: .on(), .interval(), main()

The same pattern works in other versions (was seen working in newer SDKs).

Error Details

From the Web UI run detail:

Error: scheduler.exec requires a request object

From daemon logs:

error=agent execution failed: message is required

Call stack:

Error: scheduler.exec requires a request object
  at proxyHandler (native)
  at call (native)
  at QJS_FunctionProxy (<proxy_factory>:1:179)
  at <anonymous> (loader.js:9:5)

Steps to reproduce

  1. Start agent-compose v0.4.0-58 daemon
  2. Deploy any project with a scheduler script that calls scheduler.exec():
    • agent-compose up -f test.yml (see YAML below)
  3. In Web UI, go to 自动化任务 → click "立即运行"
  4. Observe run fails immediately

name: test

agents:
test-agent:
provider: claude
model: claude-sonnet-4-6
image: agent-compose-guest:latest
driver:
docker: {}
scheduler:
enabled: true
script: |
scheduler.on("test.event", async function(p) {
return scheduler.exec(
"echo hello",
{ agent: "test-agent", sessionPolicy: "fresh" }
);
});

Expected behavior:

scheduler.exec() should create a new session and execute the specified command, then return the result to the caller.
Same behavior as agent-compose exec CLI.

Expected behavior

scheduler.exec() should create a new session and execute the specified command, then return the result to the caller.
Same behavior as agent-compose exec CLI.

Actual behavior

Run fails immediately. In Web UI run detail:
Error: scheduler.exec requires a request object
In daemon logs:
3. In Web UI, go to 自动化任务 → click "立即运行"
4. Observe run fails immediately

name: test

agents:
test-agent:
provider: claude
model: claude-sonnet-4-6
image: agent-compose-guest:latest
driver:
docker: {}
scheduler:
enabled: true
script: |
scheduler.on("test.event", async function(p) {
return scheduler.exec(
"echo hello",
{ agent: "test-agent", sessionPolicy: "fresh" }
);
});

Version or commit

No response

Runtime driver

None

Logs


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions