docs/ONE_SENTENCE.md View source on GitHub

One sentence to plan (beta)

中文

This is a beta feature. On wording it has not seen before, about eight in ten requests get the right plan straight away; the rest may get an extra question, a "cannot do this", or a plan that is wrong. Every action that changes data runs only after you confirm it, so when a plan is wrong you cancel it and nothing changes; read-only questions are answered without changing anything. Planning uses DeepSeek Flash (deepseek-flash) by default with thinking on (DeepSeek's default). The entry and every result card in the interface carry a "Beta" mark.

Type what you want in the Agent dialog, for example "Set up a box annotation project for car and truck with two people cross-checking and a 10% spot check". Datakeel turns the sentence into a chain of existing controlled actions, shows what each step changes, what it costs and whether it needs a signature, and runs nothing until you confirm. Questions such as "who has the highest rework rate this week" are answered directly by a read function, filtering reviews by the requested UTC window (today, this_week, last_week, this_month, last_7_days, last_30_days, or rolling days) and counting all project reviews when no window is stated.

How a sentence is understood

  1. Rules first, only when they use everything. A few fixed recipes (set up an annotation project, take back someone's untouched tasks and give them to someone else, draft a label set) and simple read questions are recognised without a model. When a model is configured, a recipe is used only if it accounts for every object and number in the sentence ("5000 images", a dataset name); otherwise the model plans. Both paths go through the same checks.
  2. Then one model call. Otherwise one bounded call is made to the conversation's model. The prompt contains the registry (every action and read function with its parameters, required ones marked and short choices spelled out, and its Chinese and English wording), the full schemas of the four likeliest actions, the visible objects (people with disabled accounts marked, projects, datasets, versions, label sets, skills with their annotation type and domain), the speaker's roles and the page context. The call asks for one JSON object at temperature 0; anything else is discarded.
  3. Strict checking. Every step must be a registered action with valid parameters. Names are resolved against the catalog (names, English names, ids, aliases; the object on the page wins): one match is used, several become a choice, none becomes a question. "I", "me" and "我" are the speaker. A project, package, dataset or label set used by a write must come from the page, the previous turn, an earlier step or the person's own words (the model quotes the words it mapped, so a translated name such as "the auto-generated project" counts only when those words are in the sentence); a value the model copied from the catalog is turned back into a question. Only reads may fall back to the single existing project.
  4. Nothing is dropped silently. A parameter the action does not take gets one repair call to the model; if it is still unknown, the person is asked. Every sentence ends in a plan, an answer, a question, a refusal (only for missing permissions), a failed model call said as such with its reason (timeout, HTTP status, network, or an answer that stays unreadable), or a plain "this cannot be done here" with the list of what the platform can do. The last one is used only when nothing registered is related: when the model names related actions, the person is asked which one they mean. Internal errors are said in one plain sentence, never as raw error text. Nothing falls through to the free conversation.

Parameters come from the sentence, the page context and the previous turn's objects. The Do it in one sentence button on the labeling page opens the dialog with the project, dataset, version, label set, package and open task; any page can link to #/agent?project=…&task=…&selected_kind=production_task&selected=a,b, and the HTTP API accepts the same context. Positions follow the order the lists show ("the first two tasks", "task #8", "the second package"); a position that does not exist is asked about. A subset ("the duplicate images", "the selected rows") is resolved to the exact objects before the card is shown, and a plan whose scope is wider than the sentence is asked about instead. A missing required value is asked for in plain words with at most five one-click candidates, never as an id; optional values keep their defaults and the card marks them. Permission is checked first: a request the person may not perform is refused before any question, naming the missing scope (for example production:manage), exactly as the same action would be refused by hand.

The plan card shows each step's parameters as a person reads them: names instead of ids, counts with the first few names, defaults marked. A change to an existing label set starts from its current version: "add a pedestrian label" keeps every existing label, and the card lists what is added, removed or renamed with the annotations the change affects (the same numbers as label_set_diff). Labels can be named by id, name or translation; removals and renames carry the migration the new version needs (a rename keeps the label id, a removal leaves existing annotations for manual review), derived from the final list rather than taken from the model, and a label the set does not have is asked about. Tasks have no names, so the card shows their position in the task list ("tasks 1 and 2"); files show their file names. A new skill, role, team or person takes its id from its name, values an operation needs at execution (a new skill's annotation type and domain) are asked before a card is shown, and "give Li the vehicle box skill" adds to the skills Li already holds. Sample files on a drafting card show their file names, and a direct answer to a question is a plain summary of names and numbers without identities (the full data stays in the answer's data). A model answer with one bracket out of place is repaired before it is read (only one closer changes, and the result must parse), a words map written inside the parameters is read as the step's own, and an answer that still cannot be read is asked for once more; a second failure is reported as a failed model call.

The Web Agent dialog enters the planner for every message (it always sends page context). New Web conversations use the configured model (DATAKEEL_OPENAI_API_KEY or DATAKEEL_ANTHROPIC_API_KEY). On auto, a conversation routes only to models of the configured endpoint (all three tiers use deepseek-flash when only DeepSeek is configured); the offline demo provider is used only when no key is set, and the page says plainly when no usable model is configured. The HTTP message API enters the planner only when the request carries context, so older clients keep the free conversation.

Scope and fixed checks

Groups are read before planning. The model describes tasks the way the person said them (whose, unassigned, untouched, reworked more than N rounds, in which package, "#8", the first N) and Datakeel reads that group from the project before a card is made, so the plan lists exactly the tasks a confirmation changes. A write on a described group leaves out tasks someone else holds and tasks with saved human annotation unless the words ask for them ("also the ones already labeled", a named holder, a rework count); revoking leaves out only annotated tasks. The card says how many were left out and why. "The tasks" without any scope is asked about rather than widened to the whole project, and changing files of a whole dataset needs "all".

Every plan passes fixed checks, no model involved. A plan that would change nothing (a label that already exists, the current lease, an account that is already active, tasks already assigned to that person) is answered with "it is already like that" instead of a card. A step must match the speaker's verb and role (a reviewer's "send back" is a review decision, not a reopen; an annotator's "put it back" is a release), a cloud model or spending step needs words that ask for drafting or a model, an existing label set named without "new" is changed rather than duplicated, and a full skill or team list may not drop what the person did not mention. A broken rule gets one repair call to the model; if it is still broken, the person is asked. A disabled account is recognised and never given work: the question says it is disabled and offers active people. A review decision without a revision uses the task's latest one, and a later step can take one item of an earlier step's list ({"$ref": "s1.package_ids", "$nth": 1} is the first package a split made).

Chains, confirmation and resuming

A plan is stored as an action chain. Each step is an ordinary controlled action; {"$ref": "s1.label_set_id"} takes a value from an earlier step's receipt and a step may fan out over several targets.

  • Confirm: the person presses Confirm and run (or runs datakeel intents run <chain>; HTTP POST /api/intents/chains/{id}/run). Steps are prepared and executed one by one through the same services as manual actions, so receipts, audit and lineage are identical and name the person.
  • Dependent later steps: when a claim, dispatch, release, revoke, submission, review, upgrade or similar step depends on task holding, task state, workflow tier or dispatch strategy left by an earlier step in the same plan, the first step remains executable and the dependent suffix gets no execution card. The result and chain notes say deferred for replanning. This is a beta safety boundary, not an execution failure: the requested later work stays in the notes, and after the earlier step finishes, ask for the next step again so it is planned against the new state.
  • Signatures: a step that is irreversible, external or governed waits in the approval queue. Sign it in the chain card or on the Approvals page, then the chain continues. The signer is the request's person; a browser's placeholder local is recorded as that person, and naming anyone else is refused.
  • Failure: the chain stops at the failed step with its reason; finished steps stay done. Resume (or the same CLI/HTTP call) skips steps and fan-out targets that already executed and never repeats them. A rejected signature also fails the step; resuming submits a fresh plan for a new signature.
  • Only the person who asked can read or run a chain. MCP and the Agent can never confirm or execute a write: there is no MCP tool for chains, and the Agent only proposes.

datakeel intents plan "<sentence>" [--dataset --version --project --package --actor] plans from the command line; datakeel intents show <chain> prints it.

Wording registry (required for every action)

The entry reads only the action registry. Every action and every read function must register Chinese and English phrases and at least two examples, one Chinese and one English. A gate test (tests/intents/test_language_gate.py) fails when an entry is missing any of them. Add wording for a new action as one 4-tuple in datakeel/actions/action_language.py (ACTION_LANGUAGE) or datakeel/actions/production_language.py (PRODUCTION_LANGUAGE): (phrase_zh, phrase_en, example_zh, example_en). Read functions use datakeel/ontology/function_language.py.

Drafting a label set and guidelines

draft_label_set is a controlled action ("Draft a vehicle label set and guidelines from these images"). It needs a signature and writes nothing before that. It reads:

  • Data standards: every code list that lists kinds of objects becomes a label subtree (the field is the parent label, "traffic light kind" → traffic light with one child per kind); a code list that describes a state or property (colour, occlusion, yes/no) becomes an attribute on the subtree it names. The reason for each decision is stored in the draft's source notes.
  • Existing annotations: categories in annotation batches of the dataset and in earlier label sets; annotated samples serve as positive and negative examples, also when no sample files were chosen.
  • Sampled files: up to 50 files of the dataset version.

The result is a new unpublished label set version with Chinese and English names, attributes, an overview and per-label guidelines with positive and negative examples. Every label gets a rule; names, attributes or examples the model leaves out are filled from the sources. Examples cite real sample ids; any id the model invents is dropped and counted. The version records its sources (standards, label sets, datasets, samples, model, tokens, cost, plan id). In the chain card, edit names and guidelines and Save edits (a create_label_set update plan), then Publish… through the ordinary publish_label_set signature sheet.

Profiles: offline (default, deterministic, no cost); cloud-text (deepseek-flash, key in DATAKEEL_DRAFT_TEXT_API_KEY); cloud-vision (qwen3.5-flash on DashScope with thumbnails, key in DATAKEEL_DRAFT_VISION_API_KEY). A cloud draft shows its estimated cost on the signature sheet and refuses to run when the approved max_cost_usd is below the estimate; planning and execution count the same sources (each category once), so a draft approved at its estimate runs. cloud-text turns DeepSeek thinking off for the structured answer. A billed call whose answer cannot be used fails the run and records its tokens and cost in the run's error. Without profile, a draft uses cloud-vision (samples) or cloud-text when its key is set, else offline. Models and endpoints can be changed with DATAKEEL_DRAFT_TEXT_MODEL/_BASE_URL and DATAKEEL_DRAFT_VISION_MODEL/_BASE_URL.

Drafting sizes its output limit by the label count (4,000 to 8,192 tokens), and the planned budget covers one repair round. Common field-name slips (key for id, name_cn) are mapped directly; unreadable items or a cut-off answer go back to the model once with the list of problems, and whatever was usable is kept. Standards, sampled files, existing annotations and any combination all yield bilingual names, attributes, and positive and negative examples: attributes people already filled become attribute definitions, rules describe examples in words when no sample can be cited, and the overview states the counted sources of its examples. Every billed drafting call, failed ones included, is stored as a call trace and appears in the cost summary.

Limits

  • The planner model is the conversation's model, with room for 4000 output tokens so reasoning models still return the JSON. The offline demo provider uses only the recipes.