Tickets

Convex component for typed work queues where humans and AI agents open, claim, hand off, and resolve tickets with leases, fencing, and state machines.

Installation

npm install @vllnt/convex-tickets

About Tickets

Work items that humans and AI agents open, claim, discuss, hand off and resolve, as a Convex component. One core powers three thin layers: an agent board, a support desk and project tracking. The component stores the record and enforces the rules; your app decides who may act and starts the agents.

Use cases
- Agent boards: agents claim, work and resolve tickets while people watch the queue.
- Support desks: customers open tickets and staff or agents reply and resolve.
- Project tracking: queues with your own state names for planned work.
- Human-in-the-loop agents: an agent asks for input, waits, and resumes when answered.

How it works
Queues use your own state names mapped to six fixed categories. Claims are single-winner, with optional leases and claim numbers that reject late writes. Input requests support ask-wait-resume. Blockers (up to 20 per ticket) are skipped by "claim next". Handoffs have hop limits, ping-pong checks, rate limits and crash-loop escalation. Queues, states, fields and results are typed end to end. Eight ready-made agent tools (open, list, get, claim, reply, requestInput, handoff, resolve) let the host bind the acting party, and agentQueue, deskQueue and projectQueue presets get you started.

Integration
A host hook per transition lets you wake an agent or notify a person. Your backend decides who may act and starts the agents. Install with npm install convex @vllnt/convex-tickets@canary. Version-matched docs and llms.txt ship in the npm package for coding agents. Status: 0.1.0 canary.

Links: [GitHub](https://github.com/vllnt/convex-tickets), [npm](https://www.npmjs.com/package/@vllnt/convex-tickets), [docs](https://oss.vllnt.com/packages/convex-tickets). Related components: [@vllnt/convex-notifications](https://github.com/vllnt/convex-notifications) and [@vllnt/convex-permissions](https://github.com/vllnt/convex-permissions).

Maintained by [bntvllnt](https://bntvllnt.com) at [VLLNT](https://vllnt.com). Find the author on [GitHub](https://github.com/bntvllnt) and [X](https://x.com/bntvllnt).

Benefits

Use cases

how to build a human-in-the-loop AI agent workflow in Convex

The @vllnt/convex-tickets component provides a requestInput method that moves a ticket to a waiting state, pausing the agent until the requester replies. When the requester calls reply with the required fields, the ticket automatically resumes to the started category. This lets an agent yield control to a human and pick up exactly where it left off without polling.

how to implement a work queue with leases and exactly-once claims in Convex

The @vllnt/convex-tickets component issues a claimSeq number on every successful claim. Any write that carries a stale claimSeq is rejected with CLAIM_LOST, preventing a former holder from corrupting a ticket another worker already owns. Leases are configurable per queue: set leaseMs to a duration for agents that must renew, or null for human-held tickets that may stay open for days.

how to add a support desk or helpdesk queue to a Convex app

The @vllnt/convex-tickets component ships a deskQueue preset that defines new, open, pending, on_hold, solved, and canceled states with leases disabled so staff can hold tickets across sessions. You call defineQueue with your own field and result types, mount the component, run sync after each deploy to persist the definitions, and then use open, claim, reply, and resolve from your backend mutations.

how to coordinate multiple AI agents handing off tasks in Convex

The @vllnt/convex-tickets component provides a handoff method that transfers a ticket to another queue or a named party and increments a hop counter. Built-in safeguards include configurable hop limits, ping-pong detection, per-ticket rate limits, and crash-loop escalation. Eight prebuilt agent tools (open, list, get, claim, reply, requestInput, handoff, resolve) can be bound to the acting agent so the host controls who is authorized to act.

Frequently asked questions

What is the difference between @vllnt/convex-tickets and @convex-dev/workpool?

The @vllnt/convex-tickets component is for work items that have a named holder, a thread, typed fields, a typed result, blockers, and a history that multiple parties read and act on. The @convex-dev/workpool component is for background jobs that only need retries and a concurrency cap with no holder or thread. If you need to run the actual agent loop or LLM calls, use @convex-dev/agent and record the work in convex-tickets.

How does @vllnt/convex-tickets prevent two agents from claiming the same ticket?

The @vllnt/convex-tickets component uses single-winner claim logic: only one party holds a ticket at a time. Each successful claim returns a claimSeq number that acts as a fence. Any subsequent write that provides an outdated claimSeq is rejected with CLAIM_LOST, so a formerly-holding agent that crashed and recovered cannot overwrite the new holder's work.

How do you define custom states for a queue in @vllnt/convex-tickets?

You call defineQueue and declare your state names mapped to one of six fixed categories: backlog, unstarted, started, waiting, done, and canceled. The component's rules operate on categories, not state names, so your domain vocabulary is preserved end to end. A queue that declares no states gets five defaults; a queue with custom states must cover unstarted, started, done, and canceled at minimum.

Does @vllnt/convex-tickets run agent loops or LLM calls itself?

No. The @vllnt/convex-tickets component stores records and enforces rules; it executes no agent logic. Use @convex-dev/agent for LLM calls and agent loops, then record and coordinate that work through convex-tickets. A host hook fires on every transition so your backend can wake an agent or notify a person at the right moment.

What version of Convex is required and how do you install @vllnt/convex-tickets?

The @vllnt/convex-tickets component requires convex@^1.45.0. Install with npm install @vllnt/convex-tickets@canary convex, using the canary tag until version 0.1.0 is released. After mounting the component in convex.config.ts, run the syncQueues mutation after every deploy to write your queue definitions into the component.

Links

Components

Open-source building blocks for your Convex app

Browse components in this category.

Loading components