AI workflow: start, material collection, workspace and templates
Structure of the AI workflow engine, the start checks and the preflight, profiles and autonomy modes, the scope of attachments and workspace, uploads, type templates and background execution.
The AI workflow controller uses the workflow engine to plan steps from the user's prompt (and attachments), chooses a model per capability from the existing AI settings (capability scopes), has the scheduler run the steps and gives a consolidated answer at the end. Long AI calls never run inside the web request.
Data model
Table names carry the installation's own prefix in the database.
| Table | Role |
|---|---|
gpt_run | run: user, prompt, profile, mode, workspace, limits, state |
gpt_step, gpt_dependency | steps and their dependencies |
gpt_attachment, gpt_source | attachment references and sources |
gpt_template | type templates (delete: status = 9) |
aiconfig | model assignment per capability |
aiusage | usage and cost |
cron_queue | gpt_workflow rows |
Further run tables: gpt_message, gpt_conversation, gpt_followup, gpt_decision, gpt_normalization, gpt_cooldown. The workflow SQL lives in the engine library; the owning model is the workflow module's own model.
Start (start, POST only)
- Entity decoding of the prompt; an empty prompt or one over 100,000 characters is an error.
- Material collection: document centre files with roles, business objects, an earlier run's result — only data of allowed companies, the rest silently left out.
- Preflight (key, budget, model name); on failure the run does not start (
PREFLIGHT_FAILED). - Profile: rule-based choice for
auto; profiles economy, standard, precise, maximum, research. Autonomy: strict, advisory, autonomous. - Workspace: client, storage account, drive, folder, type code. Optional limits: steps, iterations, API calls, tokens, cost, parallelism, provider and model, web and deep research.
- Run and attachment references inserted, then the
gpt_workflowjob queued. Reply: run and trace ID, the skipped (0-character) attachments and the preflight warnings.
Upload and templates
upload: one file into the document centre folder of the run's (or the form's) workspace through the document store'saddDocument; the reply is the document ID. Without a storage rule (gpt_workflowordocumentobject storage) an error.templatesave: saves the questionnaire (prompt, profile, options, research, expected material roles) as a type, updating the same code, read back; empty name:error_template_name.templatedelete:status = 9.
Background execution
A gpt_workflow row → processForCronqueue of the catalog task controller: runs the run's steps in time slices with atomic step claiming; the engine requeues itself while work remains. Accelerating entry points: the task controller's run slot endpoint with a secret (own slot lock, parallel steps) and a worker started from the framework's scheduler list, which fires N slot requests without waiting. Providers: OpenAI, Anthropic, Gemini.
Permissions
execute(permission input only) before calling the engine;startandsetmodelrequire POST (BAD_REQUEST).templatefor types.- For the workspace the client only within content scope, the storage account only within the storage account scope, the type code only an existing active template.
- The start form's type templates are only loaded with
execute.