Docyrus Agent Design
Build a custom AI agent with docyrus agent, then validate its configuration and test that it's well-formed. An agent is a row in tenant_ai_agent (identity + model + capability config) plus a set of sub-resources (tools, data sources, docs, MCPs, connections, dynamic contexts, workflow steps, deployments). This skill is the design workflow; the platform's conceptual capability catalog lives in docyrus-platform (references/ai-capabilities.md), and exhaustive CLI flags are available via docyrus agent <sub> --help (command index: docyrus-cli-app).
Workflow
Confirm app + auth. Agents are dev-app scoped.
docyrus auth who --json
docyrus apps list --json # target appSlug / appId
Design the agent. Decide its shape (is it a conversational assistant, a callable skill, or a workflow agent?), its instructions, its default/backup models, and which capabilities it needs (tools? data sources? files? knowledge base? web search?). Toggle a capability on before attaching the matching sub-resource. See references/agent-model.md to map intent → fields.
Create the agent. The only required field is --skillName. Set identity + model + capability toggles in the same call. See Create.
Attach sub-resources in this order (each is its own command group, see Sub-resources):
- data-sources the agent can read/write (turn on
--supportDataSources first),
- tools the agent can call (turn on
--supportTools; author the tool first with docyrus-app-ai-tools, then attach it here),
- docs (knowledge; turn on
--supportKnowledgeBase), mcps, connections (forward/subagent), dynamic-contexts,
- workflow-steps (only if
--hasWorkflow), then deployments (+ deployment-tools / deployment-data-sources).
Validate — re-read the agent and each sub-resource list; confirm config + attachments landed. See Validate.
Test — confirm the agent is well-formed (lists cleanly, references resolve) and, where possible, exercise it. See Test.
A full worked example (assistant with a data source, an attached tool, and a knowledge doc) is in references/workflow-examples.md.
Command cheat-sheet
Selectors: --appId | --appSlug, --agentId. Sub-resource row id is the generic --id (not --toolId/--dataSourceId). Deployment-nested groups also need --deploymentId. Write commands take camelCase flags or --data/--from-file JSON (flags merge over JSON; API keys are snake_case). Append --json.
Create an agent
docyrus agent create --appSlug crm \
--skillName "deal_coach" --name "Deal Coach" --agentName "deal-coach" \
--description "Helps reps qualify and advance deals" \
--instructions "You are a CRM assistant. Be concise. Use the deals data source to answer." \
--isAssistant true --mode conversation \
--supportTools true --supportDataSources true --supportKnowledgeBase true --json
# → capture data.id as AGENT_ID
⚠️ Known backend issue (verified on env=dev). agent create currently fails with cannot insert a non-DEFAULT value into column "name". The dev create service (apps/api/src/dev/app/agent.service.ts createAgent) inserts name, but tenant_ai_agent.name is a generated column (GENERATED ALWAYS AS (COALESCE(agent_name, skill_name)) STORED) — Postgres rejects any explicit insert into it, regardless of flags. Until the service stops inserting name, agents can't be created via this endpoint. The flag/usage below is correct and will work once fixed; in the meantime, operate on agents created through another path. The flag values themselves are unaffected — Postgres derives name from agent_name/skill_name.
--skillName is the only required field. Everything else is optional with server defaults (mode→conversation, ownership→CUSTOM, status→1, is_agent→true, is_assistant/is_skill→false, memory_token_limit→4000).
- Identity:
--name (display), --agentName (internal), --description, --category, --welcomeMessage.
- Models:
--defaultAiModelId, --backupAiModelId, --cotAiModelId, --defaultReasoningLevel, --temperature, --maxTokens. Model ids are free-form FK strings (no enum) — resolve a real core_ai_model id, don't invent one.
- Shape toggles:
--isAgent, --isAssistant, --isSkill, --hasWorkflow, --multipleDeployment, --jsonOutput.
- Capability toggles gate the sub-resources:
--supportTools, --supportDataSources, --supportFiles, --supportKnowledgeBase, --supportWebSearch. Turn the relevant one on before attaching.
--ownership enum is APP | CUSTOM | PRODUCT | SYSTEM | USER (default CUSTOM). ⚠️ The flag help text says SYSTEM | APP | TENANT — that is wrong; TENANT is not valid.
- JSON-only config (schemas, memory options) goes via
--data: instruction_schema, input_form_schema, output_render_schema, memory_options, plus the long tail in references/agent-model.md.
Sub-resources
Each group supports list/get/create/update/delete (a few exceptions noted). Always pass app + --agentId; the row is --id.
docyrus agent data-sources create --appSlug crm --agentId AGENT_ID --tenantDataSourceId <ds-id> --privilege read --json
docyrus agent tools create --appSlug crm --agentId AGENT_ID --coreAiToolId <tool-id> --json # define <tool-id> first via apps ai-tools (docyrus-app-ai-tools)
docyrus agent docs create --appSlug crm --agentId AGENT_ID --title "Pricing FAQ" --content "..." --json
docyrus agent mcps create --appSlug crm --agentId AGENT_ID --tenantMcpServerId <id> --json
docyrus agent connections create --appSlug crm --agentId AGENT_ID --connectedAiAgentId <id> --connectionType subagent --json
docyrus agent dynamic-contexts create --appSlug crm --agentId AGENT_ID --name "Today" --systemMessage "..." --json
docyrus agent workflow-steps create --appSlug crm --agentId AGENT_ID --name "Step 1" --type prompt --inputSchema '{}' --outputSchema '{}' --json
docyrus agent deployments create --appSlug crm --agentId AGENT_ID --name "Production" --json
docyrus agent list --appSlug crm --json
docyrus agent get --appSlug crm --agentId AGENT_ID --json
The full sub-resource table (required-on-create fields, createOnly fields, enums) is in references/agent-model.md.
Critical rules
- Only
--skillName is required to create an agent. Don't over-specify; rely on server defaults and add what the use case needs.
- Capability toggle before attachment. Attaching a data source/tool/knowledge doc without turning on the matching
--support* flag leaves the agent unable to use it. Set the toggle on create (or update) first.
--ownership valid values are APP | CUSTOM | PRODUCT | SYSTEM | USER (default CUSTOM); the flag help is inaccurate.
- Tools are a two-step, separate flow.
docyrus agent tools create --coreAiToolId <id> only attaches an existing app-scoped tool (a tenant_ai_tool/core_ai_tool) to the agent. You define the tool first via docyrus apps ai-tools — see docyrus-app-ai-tools.
- Sub-resource rows use
--id, not --toolId/--dataSourceId (deliberate, to avoid clashing with body flags). createOnly fields (--coreAiToolId on tools, --tenantDataSourceId on data-sources) are rejected on update; --archived is update-only.
agent tasks and agent recurring-tasks are non-functional against the current backend (no matching dev routes → 404, verified: Cannot GET …/agents/:id/tasks). Don't design around them; schedule recurring work with an automation recurrence trigger (docyrus-automation-design) instead.
- Sub-resource
create ops need an agent you can see under RLS. Sub-resource creates run inside an RLS-enforced write transaction that re-checks the agent via agentExists (id + tenant + app). An agent owned by another user (or with a null owner) is invisible there and the create returns 404 "resource not found" — even though list/get (broader reads) show it. Operate on agents you own. (Sub-resource list ops are verified working; create happy-path is currently gated by the create bug above.)
agent get/list/create/upload etc. don't error on extra JSON keys — sub-resource "required on create" fields (e.g. title, name, core_ai_tool_id, connection_type) are enforced by the backend DTO, so a missing one returns a server error, not a CLI complaint. Read back to confirm.
- Model/data-source/tool ids are real FKs, not enums — resolve them (e.g. from
list-data-sources, apps ai-tools list) before attaching; a fabricated id fails server-side.
- Validate then test, every time. Re-read the agent + sub-resource lists. Delete throwaway agents you create.
Validate
docyrus agent get --appSlug <app> --agentId <id> --json — confirm identity, models, mode, ownership, and that each --support* toggle is set as intended.
- For each attached kind:
docyrus agent data-sources list … , docyrus agent tools list … , docyrus agent docs list … , etc. — confirm the attachments exist and reference the right ids.
- If
--hasWorkflow: docyrus agent workflow-steps list … — confirm steps, their type, and parent/sort_order sequencing.
- If deployed:
docyrus agent deployments list … and the deployment-tools/data-sources lists.
Per-field "what correct looks like" is in references/workflow-examples.md.
Test
- Well-formed check: every list above returns the expected rows and every referenced id resolves (no dangling FK). The agent
get shows capability toggles consistent with its attachments.
- Exercise it where a path exists — invoke the agent from an automation
ai-agent node (docyrus-automation-design) or the app's chat surface, give it a prompt that needs an attached data source/tool, and confirm it uses them.
- Clean up: delete throwaway sub-resources, then
docyrus agent delete --appSlug <app> --agentId <id> --json.
Full test playbook in references/workflow-examples.md.
References
- references/agent-model.md — Agent fields grouped by purpose (identity, models, shape, capabilities, render/output, memory, multi-agent), the enum values and server defaults, and the full sub-resource table (groups, required-on-create, createOnly, enums).
- references/workflow-examples.md — End-to-end worked agent (assistant + data source + tool + knowledge doc), validation checklist, test playbook.
- docyrus-platform →
references/ai-capabilities.md — what the agent builder can do. docyrus-cli-app — CLI command index; docyrus agent <sub> --help for exhaustive flags. docyrus-app-ai-tools — author the AI tools an agent calls (apps ai-tools); attach them to the agent here with agent tools create --coreAiToolId.
1---2name: docyrus-agent-design3description: Design, build, validate, and test a custom Docyrus AI agent end-to-end using the `docyrus agent` CLI commands and its sub-resources. Use when the user wants to create or configure a custom AI agent (assistant/skill/workflow agent) in a dev app — set its instructions, pick its models, toggle capabilities (tools, data sources, files, knowledge base, web search), attach data sources, attach tools, add knowledge docs, wire MCP servers, connect agents (forward/subagent), add dynamic contexts, build workflow steps, or create deployments. Covers choosing the agent shape, the required vs optional config, the sub-resource attach order, and proving the agent is well-formed. Triggers on "create an AI agent", "build an assistant", "configure an agent", "give the agent a data source / tool / knowledge", "agent workflow steps", "agent deployment", "connect agents", `docyrus agent create`, `docyrus agent tools`, `docyrus agent data-sources`, `docyrus agent workflow-steps`, or any custom-agent design + validation task. For a4---5
6# Docyrus Agent Design
7
8Build a custom AI agent with `docyrus agent`, then **validate** its configuration and **test** that it's well-formed. An agent is a row in `tenant_ai_agent` (identity + model + capability config) plus a set of **sub-resources** (tools, data sources, docs, MCPs, connections, dynamic contexts, workflow steps, deployments). This skill is the design workflow; the platform's conceptual capability catalog lives in **docyrus-platform** (`references/ai-capabilities.md`), and exhaustive CLI flags are available via `docyrus agent <sub> --help` (command index: **docyrus-cli-app**).
9
10## Workflow
11
121. **Confirm app + auth.** Agents are dev-app scoped.
13 ```bash
14 docyrus auth who --json
15 docyrus apps list --json # target appSlug / appId
16 ```
17
182. **Design the agent.** Decide its shape (is it a conversational **assistant**, a callable **skill**, or a **workflow** agent?), its instructions, its default/backup models, and which capabilities it needs (tools? data sources? files? knowledge base? web search?). Toggle a capability **on** before attaching the matching sub-resource. See [references/agent-model.md](references/agent-model.md) to map intent → fields.
19
203. **Create the agent.** The only required field is `--skillName`. Set identity + model + capability toggles in the same call. See [Create](#create-an-agent).
21
224. **Attach sub-resources** in this order (each is its own command group, see [Sub-resources](#sub-resources)):
23 - **data-sources** the agent can read/write (turn on `--supportDataSources` first),
24 - **tools** the agent can call (turn on `--supportTools`; author the tool first with **docyrus-app-ai-tools**, then attach it here),
25 - **docs** (knowledge; turn on `--supportKnowledgeBase`), **mcps**, **connections** (forward/subagent), **dynamic-contexts**,
26 - **workflow-steps** (only if `--hasWorkflow`), then **deployments** (+ deployment-tools / deployment-data-sources).
27
285. **Validate** — re-read the agent and each sub-resource list; confirm config + attachments landed. See [Validate](#validate).
29
306. **Test** — confirm the agent is well-formed (lists cleanly, references resolve) and, where possible, exercise it. See [Test](#test).
31
32A full worked example (assistant with a data source, an attached tool, and a knowledge doc) is in [references/workflow-examples.md](references/workflow-examples.md).
33
34## Command cheat-sheet
35
36Selectors: `--appId | --appSlug`, `--agentId`. Sub-resource **row** id is the generic `--id` (not `--toolId`/`--dataSourceId`). Deployment-nested groups also need `--deploymentId`. Write commands take camelCase flags **or** `--data`/`--from-file` JSON (flags merge over JSON; API keys are **snake_case**). Append `--json`.
37
38### Create an agent
39
40```bash
41docyrus agent create --appSlug crm \
42 --skillName "deal_coach" --name "Deal Coach" --agentName "deal-coach" \
43 --description "Helps reps qualify and advance deals" \
44 --instructions "You are a CRM assistant. Be concise. Use the deals data source to answer." \
45 --isAssistant true --mode conversation \
46 --supportTools true --supportDataSources true --supportKnowledgeBase true --json
47# → capture data.id as AGENT_ID
48```
49
50> ⚠️ **Known backend issue (verified on env=dev).** `agent create` currently fails with `cannot insert a non-DEFAULT value into column "name"`. The dev create service (`apps/api/src/dev/app/agent.service.ts` `createAgent`) inserts `name`, but `tenant_ai_agent.name` is a generated column (`GENERATED ALWAYS AS (COALESCE(agent_name, skill_name)) STORED`) — Postgres rejects **any** explicit insert into it, regardless of flags. Until the service stops inserting `name`, agents can't be created via this endpoint. The flag/usage below is correct and will work once fixed; in the meantime, operate on agents created through another path. The flag values themselves are unaffected — Postgres derives `name` from `agent_name`/`skill_name`.
51
52- **`--skillName` is the only required field.** Everything else is optional with server defaults (`mode`→`conversation`, `ownership`→`CUSTOM`, `status`→1, `is_agent`→true, `is_assistant`/`is_skill`→false, `memory_token_limit`→4000).
53- Identity: `--name` (display), `--agentName` (internal), `--description`, `--category`, `--welcomeMessage`.
54- Models: `--defaultAiModelId`, `--backupAiModelId`, `--cotAiModelId`, `--defaultReasoningLevel`, `--temperature`, `--maxTokens`. Model ids are free-form FK strings (no enum) — resolve a real `core_ai_model` id, don't invent one.
55- Shape toggles: `--isAgent`, `--isAssistant`, `--isSkill`, `--hasWorkflow`, `--multipleDeployment`, `--jsonOutput`.
56- **Capability toggles gate the sub-resources**: `--supportTools`, `--supportDataSources`, `--supportFiles`, `--supportKnowledgeBase`, `--supportWebSearch`. Turn the relevant one **on** before attaching.
57- `--ownership` enum is `APP | CUSTOM | PRODUCT | SYSTEM | USER` (default `CUSTOM`). ⚠️ The flag help text says `SYSTEM | APP | TENANT` — that is **wrong**; `TENANT` is not valid.
58- JSON-only config (schemas, memory options) goes via `--data`: `instruction_schema`, `input_form_schema`, `output_render_schema`, `memory_options`, plus the long tail in [references/agent-model.md](references/agent-model.md).
59
60### Sub-resources
61
62Each group supports `list`/`get`/`create`/`update`/`delete` (a few exceptions noted). Always pass app + `--agentId`; the row is `--id`.
63
64```bash
65docyrus agent data-sources create --appSlug crm --agentId AGENT_ID --tenantDataSourceId <ds-id> --privilege read --json
66docyrus agent tools create --appSlug crm --agentId AGENT_ID --coreAiToolId <tool-id> --json # define <tool-id> first via apps ai-tools (docyrus-app-ai-tools)
67docyrus agent docs create --appSlug crm --agentId AGENT_ID --title "Pricing FAQ" --content "..." --json
68docyrus agent mcps create --appSlug crm --agentId AGENT_ID --tenantMcpServerId <id> --json
69docyrus agent connections create --appSlug crm --agentId AGENT_ID --connectedAiAgentId <id> --connectionType subagent --json
70docyrus agent dynamic-contexts create --appSlug crm --agentId AGENT_ID --name "Today" --systemMessage "..." --json
71docyrus agent workflow-steps create --appSlug crm --agentId AGENT_ID --name "Step 1" --type prompt --inputSchema '{}' --outputSchema '{}' --json
72docyrus agent deployments create --appSlug crm --agentId AGENT_ID --name "Production" --json
73docyrus agent list --appSlug crm --json
74docyrus agent get --appSlug crm --agentId AGENT_ID --json
75```
76
77The full sub-resource table (required-on-create fields, createOnly fields, enums) is in [references/agent-model.md](references/agent-model.md#sub-resources).
78
79## Critical rules
80
81- **Only `--skillName` is required** to create an agent. Don't over-specify; rely on server defaults and add what the use case needs.
82- **Capability toggle before attachment.** Attaching a data source/tool/knowledge doc without turning on the matching `--support*` flag leaves the agent unable to use it. Set the toggle on `create` (or `update`) first.
83- **`--ownership` valid values are `APP | CUSTOM | PRODUCT | SYSTEM | USER`** (default `CUSTOM`); the flag help is inaccurate.
84- **Tools are a two-step, separate flow.** `docyrus agent tools create --coreAiToolId <id>` only **attaches** an existing app-scoped tool (a `tenant_ai_tool`/`core_ai_tool`) to the agent. You define the tool first via `docyrus apps ai-tools` — see **docyrus-app-ai-tools**.
85- **Sub-resource rows use `--id`**, not `--toolId`/`--dataSourceId` (deliberate, to avoid clashing with body flags). `createOnly` fields (`--coreAiToolId` on tools, `--tenantDataSourceId` on data-sources) are rejected on `update`; `--archived` is update-only.
86- **`agent tasks` and `agent recurring-tasks` are non-functional** against the current backend (no matching dev routes → 404, verified: `Cannot GET …/agents/:id/tasks`). Don't design around them; schedule recurring *work* with an automation `recurrence` trigger (**docyrus-automation-design**) instead.
87- **Sub-resource `create` ops need an agent you can see under RLS.** Sub-resource creates run inside an RLS-enforced write transaction that re-checks the agent via `agentExists` (id + tenant + app). An agent owned by another user (or with a null owner) is invisible there and the create returns 404 "resource not found" — even though `list`/`get` (broader reads) show it. Operate on agents you own. (Sub-resource `list` ops are verified working; `create` happy-path is currently gated by the create bug above.)
88- **`agent get/list/create/upload` etc. don't error on extra JSON keys** — sub-resource "required on create" fields (e.g. `title`, `name`, `core_ai_tool_id`, `connection_type`) are enforced by the **backend DTO**, so a missing one returns a server error, not a CLI complaint. Read back to confirm.
89- **Model/data-source/tool ids are real FKs**, not enums — resolve them (e.g. from `list-data-sources`, `apps ai-tools list`) before attaching; a fabricated id fails server-side.
90- **Validate then test, every time.** Re-read the agent + sub-resource lists. Delete throwaway agents you create.
91
92## Validate
93
941. `docyrus agent get --appSlug <app> --agentId <id> --json` — confirm identity, models, `mode`, `ownership`, and that each `--support*` toggle is set as intended.
952. For each attached kind: `docyrus agent data-sources list … `, `docyrus agent tools list … `, `docyrus agent docs list … `, etc. — confirm the attachments exist and reference the right ids.
963. If `--hasWorkflow`: `docyrus agent workflow-steps list …` — confirm steps, their `type`, and `parent`/`sort_order` sequencing.
974. If deployed: `docyrus agent deployments list …` and the deployment-tools/data-sources lists.
98
99Per-field "what correct looks like" is in [references/workflow-examples.md](references/workflow-examples.md#validation-checklist).
100
101## Test
102
1031. **Well-formed check:** every list above returns the expected rows and every referenced id resolves (no dangling FK). The agent `get` shows capability toggles consistent with its attachments.
1042. **Exercise it** where a path exists — invoke the agent from an automation `ai-agent` node (**docyrus-automation-design**) or the app's chat surface, give it a prompt that needs an attached data source/tool, and confirm it uses them.
1053. **Clean up:** delete throwaway sub-resources, then `docyrus agent delete --appSlug <app> --agentId <id> --json`.
106
107Full test playbook in [references/workflow-examples.md](references/workflow-examples.md#test-playbook).
108
109## References
110
111- **[references/agent-model.md](references/agent-model.md)** — Agent fields grouped by purpose (identity, models, shape, capabilities, render/output, memory, multi-agent), the enum values and server defaults, and the full sub-resource table (groups, required-on-create, createOnly, enums).
112- **[references/workflow-examples.md](references/workflow-examples.md)** — End-to-end worked agent (assistant + data source + tool + knowledge doc), validation checklist, test playbook.
113- **docyrus-platform** → `references/ai-capabilities.md` — what the agent builder can do. **docyrus-cli-app** — CLI command index; `docyrus agent <sub> --help` for exhaustive flags. **docyrus-app-ai-tools** — author the AI tools an agent calls (`apps ai-tools`); attach them to the agent here with `agent tools create --coreAiToolId`.