Skip to content

Long hardware tasks run to completion - #62

Merged
wangxingjun778 merged 16 commits into
mainfrom
feat/vla_adapt
Dec 1, 2026
Merged

wangxingjun778 merged 16 commits into
mainfrom
feat/vla_adapt

Conversation

@wangxingjun778

Copy link
Copy Markdown
Member

Long hardware tasks run to completion

  • Execution counts as progress. Tool results may declare task_progress: {key}; stall detection and context governance count an unseen key as new work, so an execution task (skill runs, writes, app actions) no longer reads as stalled. Consent outcomes (refusal / approval required) are no longer counted as tool failures.
  • The hard cap became a stricter gate, not a stop. Past agent_iter_hard_cap a turn still executing new actions each round extends in agent_iter_extension_step increments, bounded by IterationConfig.backstop (never beyond 2× the cap). TurnCapGuard applies the same gate to the tool-call cap.
  • Honest limit messages. The soft-limit nudge is delivered once per turn; the step-limit answer now says which cap fired (round cap, not the context window) and tells the user how to continue.
  • code_search off the event loop under one deadline, honoring .gitignore and skipping oversized files — a slow search is now just a slow tool call instead of a frozen daemon.

Resilient TUI ↔ leapd turn sessions

  • Turn detach / re-attach. A lost read window or dropped socket no longer cancels a turn that may be moving an arm. leapd keeps it running for daemon.turn_detach_grace_s (default 120 s, 0 = old behavior).
  • /attach [request_id] resumes an interrupted turn; the TUI auto-reconnects and re-attaches from the last rendered event. A live turn streams on, an ended one replays from the ledger, an unknown turn is refused (never re-run), and a duplicate request id keeps the live pump. Daemon-side cancellation records status: cancelled.
  • Distinct failure classes (DaemonUnreachable vs DaemonReadTimeout) so a prompt is re-sent only when it provably never reached leapd.
  • Loop-lag watchdog now names the RPC and the session behind a stall.

Hardware recipes as composite tools

  • The relocation recipe is published as a composite tool whose children (hw_skill_run, hw_skill_list, model_query_batch) run through a caller-bound child invoker, bound only while the composite runs — children keep validation, ledger, approval, permits and freshness checks.
  • Workcell limits (speed, max_steps) are read from hw_skill_list; a published limit wins over defaults, and adjacent logical phases are packed into the fewest runs while each phase is verified from its own steps.
  • Composites declare their child budget in x_leapflow["timeout_s"]; per-child timeouts still apply.
  • Cancellation leaves evidence: the stop is awaited within its bound, and what the halted actuators left behind travels into cancellation notes, the ledger, history and the final notice. Cancelled tool records are persisted instead of leaving an unanswered call.

Consent bound to the session that granted it

  • Session-scoped consent is keyed to the granting session across the approval orchestrator, write governor, and the board observation surface (hardware.frame, hardware.read, preview streams share one session_id).
  • An action that names no session cannot mint a grant covering every later session; stale consent writes after revocation are refused. LeapBoard stores browser consent under one per-run sitting id.
  • Runs report approval.prompted, so recipes and reports count user attention honestly.

Specialist services and media capacity

  • One shared media_capacity_error: a zero-capacity modality refuses with the substitute to use instead of a bare count, before any byte leaves the host. model_query, export_evidence and perceive.clip check capacity before attaching clips.

Calibration

  • Stationary-board bridge: systematic and random error terms are separated, and a numerical pass carries the bound its held-out pairs actually had. Planar-pose ambiguity is judged by how far the solver's alternative lies from the chosen pose (5°), not by the reprojection gap alone; the alternative is retained in the detection, and per-camera detection summaries explain exclusions without raw frames.
  • Bridge policy refusals now name the missing step and the exact digest/session to declare.
  • Docs cover the motion-free route for a fixed camera: calib.bridge → calib.promote → calib.attest, plus a rewritten LeapCalib quickstart.

Monitor notices

  • Durable per-incident max_notices budget (default 3): a condition that never recovers stops paging and stays on the board; recovery resets the budget. capped_count is surfaced in the TUI and LeapBoard (all locales).

Context governance and session continuity

  • Convergence notices fire once per signal and name the actual signal instead of "governance is converging"; rounds alone no longer count as a stall, and the checkpoint notice tells the model to continue rather than stop at partial progress.
  • The exact tools a session has already called are carried into disclosure state, so the next turn starts from known tools.

Configuration and tests

  • New settings: daemon.turn_detach_grace_s, monitor.delivery.max_notices (env: LEAPFLOW_DAEMON_TURN_DETACH_GRACE_S, LEAPFLOW_DAEMON_STREAM_PATIENCE_S).
  • New tests/test_tool_invoker.py; expanded coverage for turn cancel/release, daemon RPC attach, agent execution budget, monitor delivery, relocation recipe and tool result tiers. Journey cassette stores were rebuilt; the network/ASR transcription tool was removed.

Bind reusable consent to declarations and destinations, unify owned-evidence approval, expose scoped permissions and revocation, and prevent stale consent writes after revocation.
…e contracts

- llm/services: typed task admission (contracts), immutable per-caller
  telemetry records, and provider/runtime/codec wiring for them
- hardware: passive bounded clip skill behind an owner port (new builtin
  entry point), conservative grasp installation preparation, hardware-owned
  query contracts, and frames/readiness/snapshot evidence updates
- engine: streaming usage telemetry, result budget, session factory and
  learning bridge updates
- tools: model service/tools telemetry and fixture alignment
- tests: media replay harness, refreshed journey cassettes and expanded
  coverage for contracts, telemetry, clips and dispatch
- docs: plugin lifecycle and third-party plugin development refresh
…s compact raw readings, off-loop focus polling
… stationary-board bridge

Relocation recipe
- Publish the hardware relocation recipe as a composite tool whose children
  (hw_skill_run, hw_skill_list, decision) run through the dispatch's
  caller-bound child invoker, bound only while the composite tool runs.
- Read the workcell's published limits (speed, max_steps, transits) from
  hw_skill_list and fall back to conservative defaults; a published limit wins.
- Pack adjacent logical phases into the fewest runs within max_steps and
  verify each phase from its own steps; a halt keeps earlier verified runs.

Tool dispatch
- Expose the frame catalog and a child invoker on the execution context; a
  composite tool's declared child is callable for its one dispatch even when
  its schema was not disclosed, but never outside the frame catalog.
- Settle an in-flight tool record so a later identical call reads a verdict
  instead of waiting on a future that never resolves.
- Register composite hardware recipes only once a fleet is configured.

Stationary-board bridge
- Split the bridge budget into systematic terms (robot_fk, wrist_mount,
  board_scale_flatness, intrinsics), summed in full, and random terms
  (pnp_depth, timing, repeatability), used only as floors for the scatter the
  residuals already measure. A numerical pass now carries the bound its
  held-out pairs actually had, not the declared prior alone.
- Judge planar-pose ambiguity by how far the solver's alternative lies from the
  chosen pose (5 deg), not by the reprojection gap alone; retain the
  alternative in the detection.
- Record per-camera detection summaries so an exclusion is understandable
  without raw frames.

Docs
- Describe the motion-free route for a fixed camera whose board must stay
  stationary: calib.bridge, calib.promote, calib.attest.

Tests: relocation recipe, tool invoker (with recorded cassettes), and
LeapCalib bridge unit and integration tests.
…d-turn notices, rebuilt journey cassettes

Specialist media path:
- llm/services/codec.py, tools/model_tools.py: one shared media_capacity_error; a
  zero-capacity modality now refuses with the substitute to use instead of a bare
  count, so a text/image-only specialist stays usable and the primary LLM is told
  the truth before anything leaves the host
- model_query / export_evidence / perceive.clip card: check model_describe media
  capacity before attaching clips; measurements go in decision.state
- d3 declared as 4 images / 1 video in the host profile (deployed, not in repo)

Also carries the concurrent working-tree changes: session_id-bound observation
consent in daemon/service.py, security/orchestrator.py and daemon/client.py;
cancelled-turn notices persisted to history; per-session tool continuity in
tool_dispatch_engine; hardware recipe/skill tool timeout metadata; write governor
and relocation recipe updates; tests and journey cassette stores rebuilt.
…hard-cap extension, turn detach and re-attach

Why: a grasp ablation on the Piper workcell stopped after ~30 tool calls although
every step succeeded. Three harness limits ended the turn, not the task.

Engine budget (P1-4, P1-5)
- Tool results may declare `task_progress` (result_progress_key); governance and
  the stall marker count declared progress as evidence, consent outcomes are not
  failures, and only a true stall opens long-exploration.
- Past `agent_iter_hard_cap` the cap is a stricter gate, not a stop: a turn still
  executing new actions every round extends in `agent_iter_extension_step` steps,
  never beyond twice the cap (IterationConfig.backstop). `TurnCapGuard` applies
  the same strict gate to the tool-call cap.
- `hw_context_snapshot` declares its progress key from device state only; live
  sensor readings no longer read as progress forever.
- `code_search` runs off the event loop with a deadline; skill `max_steps` 16 -> 64.

leapd (P1-6, P1-7)
- The loop-lag watchdog names the RPC and the session behind a stall.
- `_TurnPump` owns the `engine.chat` generator: a TUI read timeout or dropped
  socket detaches the turn instead of cancelling it, for
  `daemon.turn_detach_grace_s` (default 120 s, 0 = old behaviour). Output is
  logged so `engine.attach` resumes a live turn or replays an ended one from the
  ledger; an unknown turn is refused, never re-run. A duplicate request id keeps
  the live turn's pump; daemon-side cancellation records `status: cancelled`.
- DaemonUnreachable marks a request that provably never reached leapd.

TUI
- A lost chat stream reconnects and re-attaches automatically from the last
  rendered event; `/attach` resumes an interrupted turn manually. A prompt is
  re-sent only when it could not be handed to leapd at all.

Tests: tests/test_turn_cancel_release.py (detach, grace expiry, grace 0,
duplicate id, attach refusal), tests/test_daemon_rpc.py, tests/test_adaptive_depth.py.
…y resets it, capped_count surfaced in TUI and LeapBoard
@wangxingjun778
wangxingjun778 merged commit 770c479 into main Dec 1, 2026
1 of 2 checks passed
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