Skip to content

Agent interface: a contract agents can rely on (addressing, coordinates, errors, output size) #1039

Open

Description

@STE1200

CADCraft's MCP server and control channel already give an agent a typed way into the drawing. We work with LLM agents on real office drawings in another CAD program through a COM/AutoLISP bridge, and most of the time lost there goes to the same few things: an agent addresses something that isn't there and gets no error, it can't tell what coordinate system or unit a value is in, it gets a free-text error it can't act on, or it gets a reply too large to read. CADCraft can get these right now, while the interface is young and before more tools build on it.

Proposed contract, each point small and separate:

Later and larger, not part of this issue: transactions (all-or-nothing over several commands, one undo group; see #933 for a command that kept partial changes), dry-run, compare as an MCP tool, and queries by block name, attribute and property with block contents expanded to WCS. Related: #905 (agent skills, docs only), #803 (render options).

Real-file side: we keep a private corpus of office DWGs and re-run it against main with BricsCAD as an independent reader (#1041). We can add agent tasks on those files (count, measure, check a sheet) as a benchmark, with the reference answers taken from the other program.

Happy to adjust the split or the names if the maintainers prefer another shape.

Activity

  1. ParadoxEthos commented on Oct 15, 2026

    @ParadoxEthos

    +1 to this contract. For the last few months I've been building synTAX, an AutoLISP command that gives an AI sight into a live AutoCAD drawing: it captures the drawing's full state at database depth (environment, sysvars, symbol tables, and every group code of every entity, including XDATA; owner/reactor pointers and binary data chunks are being added now), then adds computed geometry on top (bulge-aware area and perimeter, implied loops from loose LINE chains, scale census, congruent groups, health checks), all as structured TXT/JSON/CSV. The model reasons from exact ground truth instead of guessing at what the drawing contains. Most of my bug fixes there ended up as rules for this kind of contract. Offering them in case they help shape #1040/#1047 and the later steps:

    On 3 (output sized for a context window)

    • Interning repeated strings (layer, linetype, style names) to integer indices, emitting lookup tables after the entity array, and one entity per line cut one 6,647-entity drawing from 2.84 MB to 0.80 MB (−72%) and 101k lines to 7.5k, with every compact record still matching its full record exactly. Worth considering as an opt-in profile: "compact" on query_entities once paging is settled.
    • Dropping the raw DXF group dump by default mattered more than anything else: it was ~40 of every 48 lines per entity and repeated fields already present as named keys. Keeping it behind a flag (raw) meant no consumer broke.

    On 4 (errors are data) — options, not just handles

    • A mistyped or wrongly typed option should abort and change nothing, the same as a bad handle in point 1. In my tool a silently ignored option was the most expensive bug class: the run "succeeded", and the agent then reasoned from output that didn't match what it had asked for. Booleans in particular should reject strings rather than coerce them.

    On 6 (nothing blocks) — interrupted and partial results

    • An interrupted or capped run should still return a valid, parseable result that says so ("status": "interrupted", or "truncated": true with the cap that applied), never a cut-off payload.
    • Every summary should carry a completeness line the agent can check: found vs. decoded vs. skipped, with the reason for each skip (e.g. "3D mesh: present, not analyzed"). Agents treat "not reported" as "not there" unless told otherwise.

    Something not on the list yet: a schema version

    • A schema field on every tool result, with an explicit rule: adding a field is free, but renaming one or changing its position, units or meaning bumps the version and documents a migration. Once tools build on these results (as this issue anticipates), that rule is what keeps them from breaking quietly. It also pairs well with point 2: units and coordinate systems become part of a field's meaning.

    Clean-room note: everything above is about my own code's behavior and output; none of it involves AutoCAD files or output.

    Happy to turn any of these into a PR once #1040 and #1047 land, so I'm not working against them.

    Disclosure: I used Perplexity (Computer) to research CADCraft's codebase and open issues/PRs, compare them against my tool, and draft this comment. The lessons and measurements are from my own tool; I've reviewed the text and stand behind it.

  2. STE1200 commented on Oct 16, 2026

    @STE1200
    ContributorAuthor

    Thanks, this is very useful, and it matches what we see on the COM/AutoLISP side.

    Waiting until #1040/#1047 land before opening PRs sounds right to me too.

  3. STE1200 commented on Oct 25, 2026

    @STE1200
    ContributorAuthor

    Status update from my side: I have closed #1040, #1043, #1047 and #1048. All four conflicted with main after about a week, and none had a review. I would rather not leave stale work in the queue.

    The findings stay valid as of 13 October and are listed here for anyone who picks them up:

    I did not re-check these on current main. If any of them is still wanted, tell me which one, and I will redo it as one small PR against current main.

  4. Rickpixell commented on Oct 26, 2026

    @Rickpixell

    @STE1200, on "Read notes in the CLI" (#1048): still open on the released v0.13.0, measured on Windows 11 with a synthetic file; on main (d3ae8a6) convert still prints only skipped_message, which counts the DXF reader's records, not the DWG read notes (apps/cadcraft-cli/src/main.rs#L283-L285 on v0.13.0). The open #1790 makes the same change (read_notes_message on stderr in info and convert, readNotes in drawing.inspect), but it conflicts with main and has not moved since 22 Oct.

    Case: a 4-entity drawing (2 LINE, 1 CIRCLE, 1 TEXT) saved by cadcraft-cli as DXF, converted by the ODA File Converter 27.1 to an R12 DWG (AC1009), and the type byte of its first entity record set to an unused value (one byte changed). Then:

    command exit code what it says result
    run --metric --cmd 'open {"path":"bad.dwg"}' 0 "warnings":["DWG: 1 object record couldn't be read and was left out; …"] "entities":0
    run bad.dwg --save out.dxf 0 the same note on stderr DXF with 0 entities
    convert bad.dwg out.dxf 0 only wrote out.dxf (19766 bytes) DXF with 0 entities
    info bad.dwg 0 nothing; "entityCount": 0, "skipped": {"count": 0} —

    Same result with two other one-place defects (the CRC of the 2nd record, 8 data bytes of the 3rd). So a script that uses convert or info gets an empty drawing, exit 0 and skipped: 0. Three more things the same case shows, in case they matter for the redo:

    • The note says one record, but all 4 entities are gone; AutoCAD 2026 opens the same damaged file with 2 of the 4.
    • The intact R12 DWG reads completely (4 of 4, through info, convert and run), and so do the same drawing as R13, R14 and 2018 DWG. file-format-parity.md on v0.13.0 lists R11/R12 DWG read as "no"; DWG: name the version and the missing blocks when an R12 or older file opens #1589 (open) is about R12 files whose blocks are not read.
    • Read back in AutoCAD 2026: the out.dxf from the damaged file opens with 0 entities. The one from the intact R12 (and from the R13, R14 and 2000 DWGs) is saved as an R2000 DXF and AutoCAD refuses to load it, stopping at the first CLASS record's group 91, which the open DXF: no CLASS instance counts in R2000 files (AutoCAD LT 2026 hung opening them) #1060 drops from R2000 output (I have not built it). From the 2018 DWG it opens with 4 of 4.

    I could not make a damaged 2000+ DWG that leaves a note (bytes changed inside a TEXT object of an R2000 DWG were read without one), so the R12 file is the only case I measured; the code path above is the same for every version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions