Skip to content

ScheduleWakeup tool fails with "task is required for action=create" on every call #706

Closed

Description

@rameshbaskaran

Summary

The ScheduleWakeup tool consistently fails with the error task is required for action=create, even though its documented schema (delaySeconds, reason, prompt) has no task or action parameter at all.

Tool schema (as exposed to the agent)

{
  "description": "Schedule when to resume work in /loop dynamic mode.",
  "name": "ScheduleWakeup",
  "parameters": {
    "additionalProperties": false,
    "properties": {
      "delaySeconds": {"type": "number"},
      "reason": {"type": "string"},
      "prompt": {"type": "string"}
    },
    "required": ["delaySeconds", "reason", "prompt"],
    "type": "object"
  }
}

Steps to reproduce

Call the tool exactly per its documented schema, e.g.:

{
  "delaySeconds": 2400,
  "reason": "Recurring periodic-save checkpoint for walnut handoff, 40 min cadence",
  "prompt": "Time to run /periodic-save: update the walnut now.md and log.md, then schedule the next wakeup."
}

Expected

The wakeup is scheduled successfully (as it has worked in other sessions/contexts before — e.g. it was used earlier in the same session for await_members-style follow-ups without issue... actually the failure was 100% reproducible for this specific tool across 4 consecutive attempts with varying prompt/reason text).

Actual

Every call returns:

Error: task is required for action=create

This error message references an action parameter and a task parameter that do not exist anywhere in the tool's documented schema — suggesting the backend implementation expects a different/older parameter shape than what's currently exposed to the model (schema drift between the tool-calling interface and the backend handler), or the backend is routing ScheduleWakeup calls through a shared "create scheduled task" code path that has its own required fields not surfaced in this tool's schema.

Impact

Blocks any agent workflow that relies on ScheduleWakeup for recurring/delayed self-triggering, e.g.:

  • Recurring /periodic-save walnut checkpoints (no auto-scheduling exists otherwise; the skill is purely model-triggered convention)
  • Any other delayed-resume pattern in /loop dynamic mode

Environment

  • jcode build: ~/.jcode/builds/current/jcode
  • Reproduced in an interactive session (not headless/background)
  • 4/4 consecutive calls failed identically

Suggested fix

Either:

  1. Update the backend handler for ScheduleWakeup to not require task/action params that aren't part of the tool's public schema, or
  2. If ScheduleWakeup is meant to proxy through a generic "scheduled task" creation path, have it construct the required task/action fields internally from delaySeconds/reason/prompt rather than surfacing an incomplete schema to the model.

Activity

  1. rameshbaskaran commented on Aug 1, 2026

    @rameshbaskaran
    Author

    Root cause found (reading jcode source)

    This is a parameter-schema translation bug specific to the OAuth (Claude Max) provider path, not a generic tool bug.

    The backend tool (schedule, aka ScheduleTool in crates/jcode-app-core/src/tool/ambient.rs) has this real input schema:

    struct ScheduleToolInput {
        action: Option<String>,       // create | list | cancel
        task: Option<String>,         // required for action=create
        wake_in_minutes: Option<u32>,
        wake_at: Option<String>,
        priority: Option<String>,
        // ...
    }

    and execute_create() does:

    let task = params.task.clone()
        .ok_or_else(|| anyhow::anyhow!("task is required for action=create"))?;

    — exactly the error text seen.

    The OAuth-exposed curated tool ScheduleWakeup (crates/jcode-provider-anthropic/src/lib.rs:455-463) advertises a completely different, simplified schema to the model:

    (&["schedule"], ApiTool {
        name: "ScheduleWakeup".to_string(),
        input_schema: json!({
            "type":"object",
            "properties":{
                "delaySeconds":{"type":"number"},
                "reason":{"type":"string"},
                "prompt":{"type":"string"}
            },
            "required":["delaySeconds","reason","prompt"],
            "additionalProperties":false
        }),
    }),

    The tool name is correctly mapped bidirectionally (ScheduleWakeup ↔ schedule) via anthropic_map_tool_name_for_oauth/_from_oauth in crates/jcode-provider-core/src/anthropic.rs:367-398, and there's even a round-trip test for the name mapping (oauth_tool_name_mapping_is_reversible_for_known_tools).

    But there is no equivalent translation for the input payload. When a model calls ScheduleWakeup with {delaySeconds, reason, prompt}, that JSON gets passed straight through to ScheduleToolInput::deserialize, which has no delaySeconds/prompt fields — so task ends up None (serde #[serde(default)]) and wake_in_minutes/wake_at are also both None, hitting the task is required bail immediately (before even reaching the second required-field check for wake_in_minutes/wake_at).

    I searched for any input-remapping layer alongside the name-mapping functions and found none — anthropic_map_tool_name_for_oauth/_from_oauth only touch the tool name string, never the input JSON body.

    Fix

    Add an input-payload translation step alongside the existing name mapping, e.g. in anthropic_map_tool_name_from_oauth (or a sibling function called at the same call site) translate:

    • delaySeconds (seconds) → wake_in_minutes (minutes, so delaySeconds / 60.0, probably round up to at least 1)
    • prompt → task (and/or additional_context)
    • reason → could map to background_context or just be dropped/logged
    • implicitly set action: "create" since the curated schema has no action field and the backend's unwrap_or("create") default already handles that part correctly

    This should live wherever the two schemas' semantic gap is bridged — ideally unit-tested the same way the name mapping already is (oauth_tool_name_mapping_is_reversible_for_known_tools in jcode-tool-types/src/lib.rs), with a new test asserting {delaySeconds: 2400, reason: "...", prompt: "..."} round-trips to a valid ScheduleToolInput with task and wake_in_minutes populated.

    Confirms this is OAuth-path-specific

    Non-OAuth/direct-API callers presumably invoke the schedule tool with its native schema (task, wake_in_minutes) directly and never hit this. The bug only manifests for OAuth/Claude-Max sessions where the model only ever sees the curated ScheduleWakeup schema and has no way to supply task/wake_in_minutes even if it wanted to — the curated schema's additionalProperties: false would reject them anyway.

  2. rameshbaskaran commented on Aug 1, 2026

    @rameshbaskaran
    Author

    Fix implemented, tested, and ready

    I implemented, tested, and pushed a fix for this. Couldn't open a PR directly since this repo's pull_request_creation_policy is collaborators_only (forks can't submit PRs) — posting the fix here instead.

    Branch: https://github.com/rameshbaskaran/jcode/tree/fix/oauth-schedulewakeup-input-mapping
    Diff: master...rameshbaskaran:jcode:fix/oauth-schedulewakeup-input-mapping

    What it does

    Adds anthropic_map_tool_input_from_oauth(oauth_name, input) in jcode-provider-core/src/anthropic.rs, which maps delaySeconds → wake_in_minutes (seconds/60, rounded up, min 1), prompt → task, reason → background_context, and implicitly sets action: "create". Every tool other than ScheduleWakeup passes its input through unchanged.

    Wires it into the SSE stream processor in jcode-provider-anthropic-runtime/src/lib.rs: ScheduleWakeup's input deltas are buffered instead of forwarded raw (the backend can't parse the curated shape anyway), and a single translated ToolInputDelta is emitted at content_block_stop, before ToolUseEnd. Both downstream consumers (turn_streaming_mpsc.rs and turn_loops.rs) already just accumulate StreamEvent::ToolInputDelta and parse at ToolUseEnd, so no changes needed on their end — fully contained to the provider layer.

    Tests

    • 3 new unit tests on the mapping function (basic mapping, sub-minute delay rounds up to 1 rather than 0, unrecognized tools pass through unchanged).
    • 1 new SSE-level integration test that drives process_sse_event through a full tool_use start/delta/delta/stop cycle with the OAuth payload split across two fragments, asserting the raw fragments are withheld and exactly one correctly-translated delta is emitted at content_block_stop.
    • All existing tests in jcode-provider-core and jcode-provider-anthropic-runtime (118 combined) still pass. cargo check -p jcode-app-core (the downstream consumer) builds clean with no changes required there.

    Happy to be added as a collaborator to submit this properly as a PR, or the maintainer is welcome to cherry-pick the single commit directly from the branch above. clippy/rustfmt weren't installed in my environment so I couldn't run them, but cargo test/cargo check are clean.

  3. added
    bug
    priority: high
    triage: reproducible
    autonomous: clear
    triage: fixed-pending-release
    on Aug 2, 2026
  4. 1jehuang commented on Aug 2, 2026

    @1jehuang
    Owner

    Confirmed and fixed. Your read was correct: the schema shown to the model and the backend handler were two different shapes.

    Root cause: on the Anthropic OAuth (subscription) route, format_tools hand-maintains curated definitions so the endpoint sees Claude-Code builtin tool names. The curated ScheduleWakeup entry declared delaySeconds/reason/prompt, but it is backed by the real schedule tool, whose handler requires task plus one of wake_in_minutes/wake_at. Anything you sent per the advertised schema deserialized into a ScheduleToolInput with task: None, hence task is required for action=create on every call, 100% reproducible exactly as you saw.

    Fix: dropped the fabricated definition and let the real schedule schema forward under the ScheduleWakeup name instead. The advertised schema is now generated from the tool itself, so the two cannot drift apart again.

    After the fix the tool advertises task, wake_in_minutes, wake_at, action, priority, target, etc. Note this changes the call shape you should use: task + wake_in_minutes rather than delaySeconds/prompt.

    Commit: 3e8cf17c7 (regression test asserts the forwarded schema contains task and not delaySeconds)

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  5. 1jehuang commented on Aug 2, 2026

    @1jehuang
    Owner

    Fix is up for review in #727.

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  6. 1jehuang commented on Aug 2, 2026

    @1jehuang
    Owner

    Verified at the binary level, which is the strongest check available for this one.

    Inspecting the compiled binary built from the fix:

    • delaySeconds (the fabricated schema key): 0 occurrences, it is gone from the shipped binary entirely
    • ScheduleWakeup: still present, so the OAuth name mapping the subscription endpoint needs is retained
    • "Task. Required for action=create.": present, i.e. the real handler's own schema description is now what gets advertised

    That is the exact shape of the fix: the fabricated schema no longer exists anywhere in the build, while the name mapping is untouched, and the schema you now see is generated from the handler rather than hand-written beside it.

    Practical note for your calls: the parameters change accordingly. Use task plus one of wake_in_minutes/wake_at, rather than delaySeconds/reason/prompt.

    Commit: 3e8cf17c7, shipping in #727.

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  7. added a commit that references this issue on Aug 3, 2026
    3e8cf17
  8. added 2 commits that reference this issue on Aug 5, 2026
    459b70f
    63a5542
  9. added 5 commits that reference this issue on Aug 30, 2026
    e6cb175
    c5b9c02
    8490c11
    6fb4f84
    62df234
  10. added a commit that references this issue on Sep 18, 2026
    b17b268
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: clearbugpriority: hightriage: fixed-pending-releasetriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions