Skip to content

feat(mcp): wait option for compile, upload and task status - #25

Merged
mixelpixx merged 1 commit into
mainfrom
feat-task-wait
Jul 27, 2026
Merged

feat(mcp): wait option for compile, upload and task status#25
mixelpixx merged 1 commit into
mainfrom
feat-task-wait

Conversation

@mixelpixx

Copy link
Copy Markdown
Owner

First of the v0.6.0 agent-experience series (plan: five pain points from the ESP32-S3 hardware session).

The problem

Compile/upload return a taskId and force the agent into a polling loop via arduino_task_status — the single biggest orchestration overhead in the toolset. One hardware session rewrote the same polling loop 10+ times.

The fix

arduino_compile and arduino_upload accept wait: true + timeout_seconds (default 60, clamp 5–600). arduino_task_status gains the same params to block on in-flight tasks.

A timeout is not an error. It returns {taskId, status, progress, progressMessage, timed_out: true, hint}, so a long first build is simply re-waited:

compile {wait:true, timeout_seconds:60}   →  timed_out at 42%
task_status {task_id, wait:true}          →  completed, sizes

Internals: runners' completion promises (previously discarded via setImmediate) are kept in a taskPromises map; waitForTask races completion vs timer. Tasks gain createdAt/startedAt/finishedAt. Fully backward compatible — no-wait calls behave as before.

Verified on hardware (ESP32-S3, COM6)

  • 5s-timeout compile → timed_out: true at progress 12 with re-wait hint
  • task_status {wait:true} → blocked to completed with section sizes
  • Warm compile wait:true → one-shot completed
  • Full upload wait:true → one-shot compile+flash+verify, board running the sketch

🤖 Generated with Claude Code
EOF

Every compile and upload previously forced the caller into a polling loop:
the tool returned a taskId immediately and the agent had to call
arduino_task_status repeatedly - the single biggest source of orchestration
overhead when driving the tools (a real hardware session rewrote the same
polling loop more than ten times).

arduino_compile and arduino_upload now accept wait:true plus
timeout_seconds (default 60, clamped 5-600). The dispatch keeps each
runner's completion promise (they were fired through setImmediate and
discarded), and waitForTask races it against the timeout:

- finished: the full terminal result in one call
- timeout: {taskId, status, progress, progressMessage, timed_out: true}
  with a hint - deliberately NOT an error, so a long first build simply
  gets re-waited via arduino_task_status {wait:true}, which now blocks on
  in-flight tasks the same way.

Tasks also gain createdAt/startedAt/finishedAt timestamps, and pruneTasks
clears the promise map and treats 'cancelled' as evictable.

Verified on the ESP32-S3: 5s-timeout compile returned timed_out at
progress 12 with the hint; re-wait completed with sizes; warm compile and
a full upload each finished in a single wait:true call.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mixelpixx
mixelpixx merged commit 3b026d9 into main Jul 27, 2026
@mixelpixx
mixelpixx deleted the feat-task-wait branch July 27, 2026 19:08
@mixelpixx mixelpixx mentioned this pull request Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant