Repository navigation
Agent workflow: bed-frame objects, durable print records, ELN outbox, A1 agent mode - #8
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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}/objectsreturns 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'sMetadata/plate_N.jsonbounding boxes, the extruding moves inside G-code object labels (Bambu'sstart printing object, unique label id), and 3MF build transforms (plate 1 only). Each object also has a labelled-extrusiongcode_boundscross-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_daysis set; cancel keeps the artifact unlesssubmissions.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, pollsGET {url}/{device_id}/{id}, retries with backoff, and resumes after a restart./statusreports the counts.Events. Event ids persist across restarts, with a
gateway.restartedmarker. There are events for every terminal state (rejected, cancelled, restart-recovered failures included) and ajob.cooledevent. Each event carries state, updated_at, schema version and gateway id;job.finishedadds 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
/submissions/{id}/objects/submissions/{id}/pickup-targets/submissions/{id}/artifactETag= SHA-256, 304 support/submissions/{id}/result/submissions/{id}/eln-ingest/results/outbox/events/printers/{id}/agent-mode/submissionsupdated_after,order=newest,offset/submissions,/submissions/{id}/approveeln_project/printers/{id}/robot-calibrationConfig and deployment
submissions.retain_terminal_days(default now null),submissions.cancel_deletes_artifact(false)results.*:gateway_id,ingest_url, poll, retry and timeout settingsagent_workflow.pickup_safe_bed_c,agent_workflow.cooldown_watch_timeout_sdispatch.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)BAMBU_RESULTS_URL,BAMBU_RESULTS_TOKEN;BAMBU_EDGE_SHARED_SECRETis needed for admin flipsNeeded on the agents server: set
agent_mode_eligible: trueonbambu_a1_01and switch it on via the endpoint as an admin; make sure the edge forwards theadminandagentroles inX-Auth-Role. For ELN filing, the central dashboard needs a print-results ingest route plusGET {url}/{device_id}/{id}filing status, and the gateway needsBAMBU_RESULTS_URLandBAMBU_RESULTS_TOKEN. Optionally pointagent_workflow.event_webhook_urlsat/api/ingest/events.Verification
uv run ruff check .uv run pytest -q: 292 passed (stable across 3 runs)