Skip to content

Filling in a new field on existing slots takes one AI tool call per slot #725

Open

Description

@richshaw

Needs your OK: this adds an update_slots tool to the AI connector, so an assistant can change many slots in one call. Swap pipeline:proposed for pipeline:ready to have it built.

What happens

When an assistant adds a field, the signup's existing slots have no value for it. add_field's description says so: "Existing slots have no value for a new field until one is set with update_slot." update_slot (src/mcp/tools/slots.ts) changes one slot. So filling in a new field on 30 slots takes 30 tool calls, and the organizer waits through each one. Each call also runs its own policy guard, transaction and signup lock, and writes its own slot.updated row.

The same goes for any change across many slots, such as raising every shift's spots or closing one day's slots.

Adding and reordering already work in one call: add_slots takes up to 500 rows (addSlotsBulk), and reorder_slots takes the whole order. Changing slots has no bulk path, in the tools or the REST API.

Fix, in outline

  • A service, updateSlotsBulk(db, actor, signupId, { slots }) in src/services/slots.ts. slots is 1 to 500 rows of { slotId, values?, capacity?, status? }, each slotId once. It:
    • opens with withSignupWriteLock, then lockSlotsForSignup: signup first, then slots, as the add-before and reorder paths do
    • refuses a slotId that isn't a slot of this signup, with invalid_input naming the row (slots.3.slotId)
    • runs updateSlot's checks on each row: values against the fields (listFieldsForSignup, read once), capacity not below the places taken (counted once for all the slots), and slot_at from extractSlotAt with the signup's settings
    • is all or nothing: the first row that fails returns its error, with its index, and nothing is written
    • writes the rows in one UPDATE … FROM a JSON array, as writeSlotOrder does
    • records one slot.updated row, { slotIds, changed, bulk: true }, and a slot.rescheduled row for each slot whose time moved, as updateSlot does. The time-change emails and the reminders' settle check read those by slot (src/jobs/slot-changes.ts, src/jobs/notify-rules.ts).
    • returns the slots in the order given
  • A tool, update_slots, in src/mcp/tools/slots.ts:
    • input { signupId, slots: [...] }; each row is update_slot's schema without sortOrder, strict, plus slotId
    • scope signups:write, destructiveHint: true
    • returns { slots } through slotOut
    • its description says what it does: changes several slots of one signup in one call, by the same rules as update_slot, and changes nothing if any row is refused
  • Point to it. add_field's description names update_slots for filling in a new field. Add the tool to TOOLS in src/mcp/tools/index.ts.

Choices this makes

  • A new tool, not an array on update_slot. update_slot's input stays as it is, so calls from existing clients keep working. The tool list grows from 18 to 19.
  • Values replace, as update_slot's do. A row's values replaces all of that slot's values, so an assistant filling in one field sends the others too. Merging would save tokens, but then two tools would treat the same values differently.
  • All or nothing. A partial success would leave the assistant working out which rows to send again.
  • Up to 500 rows, the same cap as add_slots.
  • One slot.updated row per call, as add_slots writes one slot.created. slot.rescheduled stays one per slot.
  • Tools only. No REST endpoint: the Build tab saves one slot at a time and has no use for one.

Watch for

  • Tool descriptions say what a tool does, never what the model should do. src/mcp/registry.test.ts fails on the usual phrasings, and the Claude connectors directory checks this.
  • The roster test in registry.test.ts spells out every tool name. Add update_slots there.
  • instructions.ts gets one more name in its closing tools line. That line sits after the 2048-byte part, so its size test should still pass. Run it.
  • The MCP body cap is 1,000,000 bytes (MAX_BODY_BYTES in src/app/api/mcp/route.ts), enough for 500 rows of values. That route is on the high-risk list, so don't change it.
  • docs/telemetry.md documents slot.updated. Add the bulk payload.
  • Evals. A follow-up case in evals/mcp/followup-evals.json ("add a Location field and fill it in") that expects update_slots would show whether assistants find it. pnpm eval:mcp isn't a CI gate.
  • CHANGELOG line under Added.

Done when

  • A DB test: update_slots fills in a new field on 30 slots in one call, and get_signup shows the values.
  • A DB test: one row with a value that doesn't fit its field, or a slotId from another signup, changes nothing and names the row.
  • A DB test: moving two slots to a new date writes one slot.rescheduled row for each.
  • pnpm lint && pnpm typecheck && pnpm knip && pnpm test && pnpm test:db pass.

Split out of #245 (its first part) for the pipeline, and checked against src/mcp/tools/slots.ts, src/mcp/tools/fields.ts, src/mcp/tools/index.ts, src/mcp/registry.test.ts, src/mcp/instructions.ts, src/services/slots.ts and src/app/api/mcp/route.ts on main at 2d4fdfe. https://claude.ai/code/session_016YZ9SUWWJa1udHCjU5fUma

Activity

  1. added
    enhancement
    pipeline:ux
    on Oct 30, 2026
  2. self-assigned this
    on Nov 21, 2026
  3. removed
    pipeline:working
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementpipeline:buildingpipeline:ux

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions