Skip to content

Agent workflow: bed-frame objects, durable print records, ELN outbox, A1 agent mode - #8

Merged
cyrilcaoyang merged 5 commits into
mainfrom
cursor/agent-workflow-64b8
Nov 2, 2026
Merged

cyrilcaoyang merged 5 commits into
mainfrom
cursor/agent-workflow-64b8

Conversation

@cyrilcaoyang

@cyrilcaoyang cyrilcaoyang commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Makes the gateway usable end to end by agents while keeping records durable and the human path unchanged.

Object positions (bed frame only). GET /submissions/{id}/objects returns each sliced object's centre, bounds, rotation (when known), plate index and source, in the printer's bed coordinates (mm, front-left origin, +X right, +Y back). Sources, best first: Bambu Studio's Metadata/plate_N.json bounding boxes, the extruding moves inside G-code object labels (Bambu's start printing object, unique label id), and 3MF build transforms (plate 1 only). Each object also has a labelled-extrusion gcode_bounds cross-check. Robot calibration storage and the arm-frame transform are removed: the arm agent owns them.

Durable print records. Terminal jobs and artifacts are kept by default (no sweep unless submissions.retain_terminal_days is set; cancel keeps the artifact unless submissions.cancel_deletes_artifact). Each terminal job gets a schema-versioned result bundle (results/<id>.json, atomic write, never pruned). It holds the job history, verdict and facts, the plate-check evidence with snapshot SHA-256, dispatch timestamps, bed-frame objects, bed-temperature readiness at finish, gateway version and the artifact's SHA-256.

Optional ELN ingest through the central server only (OT-2 pattern). On-disk outbox states: local_only, pending, delivered, filing, filed, held. A worker POSTs to the central ingest with a bearer token, polls GET {url}/{device_id}/{id}, retries with backoff, and resumes after a restart. /status reports the counts.

Events. Event ids persist across restarts, with a gateway.restarted marker. There are events for every terminal state (rejected, cancelled, restart-recovered failures included) and a job.cooled event. Each event carries state, updated_at, schema version and gateway id; job.finished adds object positions, printer_id and bed-temperature readiness. Emission, outbox and bundle failures never affect dispatch or monitoring.

Agent mode, Bambu A1 only (approved by Yang 2026-11-02). An admin-controlled switch, off by default. Only an edge-verified admin can flip it; every flip is audited with who, when and why, and its state is shown in status. With the switch on, agents may submit, approve and start on the A1 using plate_check_method: agent_camera: a fresh claimed snapshot, with the agent's identity and rationale recorded and the frame archived by SHA-256. Agents are refused everywhere else, and on the A1 when the switch is off. H2D camera snapshots are refused explicitly (501).

New and changed endpoints

Method Path Notes
GET /submissions/{id}/objects bed-frame positions
GET /submissions/{id}/pickup-targets bed-frame objects, bed temp, cooled readiness (no arm frame)
GET /submissions/{id}/artifact exact file, ETag = SHA-256, 304 support
GET /submissions/{id}/result result bundle
POST/GET /submissions/{id}/eln-ingest file a terminal job later / read its outbox entry
GET /results/outbox outbox counts and entries
GET /events persistent ids, more event types
GET/POST /printers/{id}/agent-mode read / flip (verified admin only)
GET /submissions adds updated_after, order=newest, offset
POST /submissions, /submissions/{id}/approve optional eln_project
— /printers/{id}/robot-calibration removed

Config and deployment

  • submissions.retain_terminal_days (default now null), submissions.cancel_deletes_artifact (false)
  • results.*: gateway_id, ingest_url, poll, retry and timeout settings
  • agent_workflow.pickup_safe_bed_c, agent_workflow.cooldown_watch_timeout_s
  • dispatch.agent_mode_admin_roles ([admin]), dispatch.agent_roles ([agent]), dispatch.agent_snapshot_max_age_s (120)
  • printers[].agent_mode_eligible (accepted on a Bambu A1 only)
  • Env: BAMBU_RESULTS_URL, BAMBU_RESULTS_TOKEN; BAMBU_EDGE_SHARED_SECRET is needed for admin flips

Needed on the agents server: set agent_mode_eligible: true on bambu_a1_01 and switch it on via the endpoint as an admin; make sure the edge forwards the admin and agent roles in X-Auth-Role. For ELN filing, the central dashboard needs a print-results ingest route plus GET {url}/{device_id}/{id} filing status, and the gateway needs BAMBU_RESULTS_URL and BAMBU_RESULTS_TOKEN. Optionally point agent_workflow.event_webhook_urls at /api/ingest/events.

Verification

  • uv run ruff check .
  • uv run pytest -q: 292 passed (stable across 3 runs)
Open in Web Open in Cursor 

cursoragent and others added 5 commits November 2, 2026 01:46
Co-authored-by: Yang Cao <cyrilcaoyang@gmail.com>
Co-authored-by: Yang Cao <cyrilcaoyang@gmail.com>
Co-authored-by: Yang Cao <cyrilcaoyang@gmail.com>
- Keep terminal jobs and artifacts by default; cancel keeps the artifact
  unless submissions.cancel_deletes_artifact is set.
- Write a schema-versioned result bundle per submission atomically at its
  terminal state, served by GET /submissions/{id}/result; stream the exact
  artifact with its sha256 as ETag from GET /submissions/{id}/artifact.
- Add an on-disk outbox and worker that POST bundles to the central ingest
  with a bearer token, follow filing status, back off, and resume after a
  restart; jobs stay local_only without a project or configured ingest.
- Persist event ids across restarts with a gateway.restarted marker, add
  events for every terminal state and job.cooled, and carry state,
  updated_at, schema version and gateway id in each event.
- Drop robot calibration and the arm-frame transform: object positions are
  reported in bed coordinates only, preferring the slicer's plate_N.json.
- Add admin-controlled agent mode for the Bambu A1 only, with an audited
  switch and the agent_camera plate check; refuse H2D camera snapshots.

Co-authored-by: Yang Cao <cyrilcaoyang@gmail.com>
Record the 2026-11-02 approvals (A1-only agent mode with an audited admin
switch and agent_camera; calibration owned by the arm agent) in AGENTS.md and
AGENT_RULES.md, and update the README, API reference, example config and
.env.example with the agent workflow, the new endpoints and the deployment
env vars.

Co-authored-by: Yang Cao <cyrilcaoyang@gmail.com>
@cursor cursor Bot changed the title Add agent workflow and robot handoff APIs Agent workflow: bed-frame objects, durable print records, ELN outbox, A1 agent mode Nov 2, 2026
@cyrilcaoyang
cyrilcaoyang merged commit 9a3dd18 into main Nov 2, 2026
1 check 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.

2 participants