@cognite/cli 1.9.0-alpha.3 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,10 +12,6 @@ npx @cognite/cli apps create
12
12
 
13
13
  This prompts for your app name, org, project, and cluster, then generates a fully configured React + TypeScript project.
14
14
 
15
- ## Feature Flags
16
-
17
- Set environment variable `COGNITE_ALPHA_ENABLE_SESSION_AUTH` to true in order to enable session authentication enabling auth login and logout commands which will let you skip browser login by securely persisting access tokens on your machine.
18
-
19
15
  ## Authentication
20
16
 
21
17
  New apps created with `npx @cognite/cli apps create` depend on [`@cognite/app-sdk`](https://www.npmjs.com/package/@cognite/app-sdk) — **not `@cognite/cli`** — for auth and host integration. `@cognite/cli` is the CLI used to scaffold, develop, and deploy the app; the generated app itself talks to the Fusion app host via `@cognite/app-sdk`'s Comlink handshake. The template wires this up for you.
@@ -28,6 +24,14 @@ Deploy interactively via browser OAuth:
28
24
  npx @cognite/cli apps deploy --interactive
29
25
  ```
30
26
 
27
+ For local non-interactive deploys, sign in once to persist a refreshable
28
+ session — `apps deploy` picks it up automatically:
29
+
30
+ ```bash
31
+ npx @cognite/cli auth login
32
+ npx @cognite/cli apps deploy
33
+ ```
34
+
31
35
  For CI, set your client secret as an environment variable and run:
32
36
 
33
37
  ```bash
@@ -69,6 +73,7 @@ Browse available skills at [cognitedata/builder-skills](https://github.com/cogni
69
73
  ## Requirements
70
74
 
71
75
  - Node.js ≥ 20
76
+ - npm ≥ 11.10.0 to install/build generated apps — enforced via `engines.npm` + `engine-strict=true` in the generated app's `.npmrc`. Not required for running `@cognite/cli` itself (e.g. via `npx`).
72
77
  - React ≥ 18 (optional peer dependency — only needed for auth components)
73
78
 
74
79
  ## Telemetry
@@ -144,6 +149,7 @@ MOCK_SCENARIO=403 pnpm mock:server
144
149
  | `republish` | `ensureApp` recovers (409), then `uploadVersion` fails (409 — version already published) |
145
150
 
146
151
  The mock server and MSW handlers live in `cli/testing/msw/`. The same handlers are used by the Vitest integration tests in `src/deploy/apphosting-deployer.msw.test.ts`.
152
+
147
153
  ## Maintenance
148
154
 
149
155
  ### Updating the spec-kit vendor snapshot
@@ -0,0 +1,179 @@
1
+ # Agent Project — AI Development Guide
2
+
3
+ This file is for **AI coding assistants** (Cursor, Claude Code, etc.) working in this
4
+ repository. Humans should start with `README.md`.
5
+
6
+ ## Project layout
7
+
8
+ | Path | Purpose |
9
+ |------|---------|
10
+ | `<name>.agent.yaml` | Agent definition — read this file for current field values |
11
+ | `eval/eval.yaml` | Eval cases and optional `include:` fragments under `eval/` |
12
+ | `README.md` | Human-oriented quick start and workflow |
13
+
14
+ ## Reference documentation
15
+
16
+ For full field schemas, tool types, scorer details, and CLI flags beyond what this
17
+ file covers, see the Cognite CLI agents documentation:
18
+
19
+ - [Cognite CLI — Agents](https://docs.cognite.com/dev/sdks/cognite-cli/agents)
20
+ - [Eval cases JSON Schema](https://docs.cognite.com/assets/schemas/agent-eval-cases.schema.json)
21
+
22
+ ## CLI validation
23
+
24
+ The CLI validates both `<name>.agent.yaml` and `eval/eval.yaml` at runtime. Schema errors
25
+ surface before commands execute — you do not need to validate YAML manually:
26
+
27
+ - **`<name>.agent.yaml`** is parsed and checked when you run `push`, `status`, `eval`, or
28
+ other commands that read the project.
29
+ - **`eval/eval.yaml`** (and any `include:` fragments) is validated at the start of
30
+ `cognite agents eval` before cases run.
31
+
32
+ Use the scaffolded templates and examples as your reference for valid field shapes.
33
+
34
+ ## Design principle: discover via tools
35
+
36
+ Agents should **retrieve** answers with declared tools, not rely on eval YAML to inject
37
+ facts into the chat. Evals should validate that behavior.
38
+
39
+ - Use `dataModels`, `instanceSpaces`, and `appContext` to scope **where** the agent
40
+ operates (plant, site, spaces) — not to paste answer text the agent should have found.
41
+ - **`faithfulness` `groundTruth`** is supplied to the **LLM judge only**. It does not replace
42
+ tool use when you are testing retrieval.
43
+
44
+ **Do not** put expected answer facts in `appContext` to make a discovery test pass:
45
+
46
+ ```yaml
47
+ # Wrong — agent sees the answer without using tools
48
+ appContext: "Pump P-101 was shut down on 2024-03-15."
49
+ turns:
50
+ - input: "When was P-101 shut down?"
51
+ scorers:
52
+ - type: faithfulness
53
+ groundTruth: "Pump P-101 was shut down on 2024-03-15."
54
+ ```
55
+
56
+ ```yaml
57
+ # Right — judge checks grounding; agent must still retrieve in production
58
+ turns:
59
+ - input: "When was P-101 shut down?"
60
+ scorers:
61
+ - type: faithfulness
62
+ groundTruth: |
63
+ Pump P-101 was shut down on 2024-03-15 due to bearing wear.
64
+ ```
65
+
66
+ ## Two-layer prompts
67
+
68
+ - **`instructions`** in `<name>.agent.yaml` is the builder-editable system guidance for this agent.
69
+ - The platform may apply additional system behavior that is not editable in this file.
70
+
71
+ ## Workflow
72
+
73
+ `create` → edit `<name>.agent.yaml` → `cognite agents push` → `cognite agents open` (manual test)
74
+ → `cognite agents eval` → `cognite agents publish` when ready.
75
+
76
+ Other commands: `pull`, `list`, `status`, `unpublish`. See `README.md` for examples.
77
+
78
+ **Eval runs against deployed config.** Push first, or run `cognite agents eval --upsert`.
79
+ To evaluate a deployed agent without a local `<name>.agent.yaml` (e.g. Cognite system agents
80
+ you cannot pull), use `cognite agents eval --system-agent` or
81
+ `cognite agents eval --external-id <id>` — only `eval/eval.yaml` is required on disk.
82
+ `--system-agent` and `--external-id` cannot be used together.
83
+ Auth: `cognite auth login`; optional env vars are documented in the CLI package
84
+ `env.example` (do not commit secrets).
85
+
86
+ ## Eval essentials
87
+
88
+ - Cases live in `eval/eval.yaml`; split suites with `include:` (paths relative to `eval/`).
89
+ - Filter runs: `--tag`, `--case` (repeatable), `--fail-fast`, `-v`.
90
+ - Use `--system-agent` to evaluate the Cognite-managed system agent without `<name>.agent.yaml`,
91
+ or `--external-id <id>` for any other deployed agent. These flags skip `<name>.agent.yaml`
92
+ entirely — only `eval/eval.yaml` is required on disk.
93
+ - Multi-turn cases thread the conversation cursor; scorers run on the turns that declare them.
94
+
95
+ | Scorer | Use when | Required / notable fields |
96
+ |--------|----------|---------------------------|
97
+ | `correctness` | General answer quality | `criteria` |
98
+ | `faithfulness` | Output must match judge-supplied facts | `groundTruth` |
99
+ | `toolSelection` | Whether the agent picked the right tools (names only) | Optional `tools`; use runtime names (see below) |
100
+ | `toolInvocation` | Whether tool arguments match the question | Optional `tools`; put parameter details in each tool `description` (see below) |
101
+
102
+ Phoenix metric docs: [Correctness](https://arize.com/docs/phoenix/evaluation/pre-built-metrics/correctness),
103
+ [Faithfulness](https://arize.com/docs/phoenix/evaluation/pre-built-metrics/faithfulness),
104
+ [Tool Selection](https://arize.com/docs/phoenix/evaluation/pre-built-metrics/tool-selection),
105
+ [Tool Invocation](https://arize.com/docs/phoenix/evaluation/pre-built-metrics/tool-invocation).
106
+
107
+ ### Tool scorers: `tools` field and gotchas
108
+
109
+ `toolSelection` and `toolInvocation` need a resolved tool list for the LLM judge.
110
+ The judge does a **literal name membership check** — if the names don't match what
111
+ the agent actually called, the scorer will report `incorrect` even when tool use
112
+ was appropriate.
113
+
114
+ **Eval `tools` are NOT `<name>.agent.yaml` tools.** `<name>.agent.yaml` declares tools for the
115
+ agent runtime (config-time names like `query`). Eval `tools` declare what the
116
+ *judge* should expect the agent to *call* at runtime (e.g. `find_assets`, `execute`).
117
+ These are often different names.
118
+
119
+ **Three categories of tools:**
120
+
121
+ - **Custom tools** (user-defined): config name = runtime name. Tool scorers work
122
+ with tools from `<name>.agent.yaml` — no eval `tools` needed.
123
+ - **Cognite platform tools** (`query`, `ask_document`, etc.): the runtime decomposes
124
+ these into sub-tools (`find_assets`, `list_views`) whose names differ from config.
125
+ Declare runtime tool names in eval `tools`, or use `correctness`/`faithfulness`
126
+ to evaluate outcomes instead.
127
+ - **System tools** (sandbox `execute`, `commandTool`): never in any config. Declare
128
+ them in eval `tools`, or use `correctness`.
129
+
130
+ **Discovering runtime tool names:** Run eval once with `-v` or `--report-dir` and
131
+ look at the `toolsCalled:` output to see what the agent actually invoked.
132
+
133
+ **Tool list cascade** (most specific wins, whole-array replace — not merge-by-name):
134
+
135
+ ```
136
+ scorer.tools → case.tools → included-file.tools → root eval.yaml tools → <name>.agent.yaml tools
137
+ ```
138
+
139
+ With `--external-id` or `--system-agent`, `<name>.agent.yaml` is skipped entirely —
140
+ declare eval `tools` at root, file, case, or scorer level.
141
+
142
+ **Empty resolution skips the scorer.** If no tools resolve after the full cascade,
143
+ the scorer is skipped with a stderr warning (not a misleading "incorrect" verdict).
144
+ Other scorers on the same turn still run. A case whose *only* scorers were all
145
+ skipped fails the verdict (zero scores).
146
+
147
+ **`toolInvocation` description quality:** The judge evaluates arguments against
148
+ whatever you put in each tool's `description`. Include parameter details for
149
+ accurate invocation scoring:
150
+
151
+ ```yaml
152
+ tools:
153
+ - name: find_assets
154
+ description: |
155
+ Find assets in the knowledge graph.
156
+ Parameters: filter (string, required), limit (integer, optional).
157
+ ```
158
+
159
+ Without parameter details, the judge can only check whether arguments "seem
160
+ reasonable" for the user's question — it cannot verify schema compliance.
161
+
162
+ ## Eval YAML inheritance
163
+
164
+ Fields resolve at three levels for session context and case-level tools: root
165
+ `eval/eval.yaml` → included file → individual case. Scorer-level `tools` on a turn
166
+ override case/file/root (and `<name>.agent.yaml` fallback) for that scorer only.
167
+
168
+ - **`tags`** — union (file-level tags merge into each case's tags, deduplicated).
169
+ - **`dataModels`, `instanceSpaces`, `appContext`** — per-field replace (most specific wins; no deep merge).
170
+ - **`tools`** — whole-array replace at each level (not merge-by-name). Used by
171
+ `toolSelection` / `toolInvocation`; does not change what tools the agent can call —
172
+ only what the judge considers when scoring.
173
+
174
+ ## Conventions for AI assistants
175
+
176
+ - Minimize scope when editing YAML; match existing case `id` style and tags.
177
+ - Do not commit credentials; use environment variables.
178
+ - For detailed eval authoring or debugging workflows, use project skills under
179
+ `.cursor/skills` or `.claude/skills` when they are present.
@@ -1,77 +1,41 @@
1
1
  # Eval cases for {{displayName}}
2
- #
3
- # Each case is a conversation with the agent plus one or more "scorers" that
4
- # judge the responses. An LLM judge grades every scored turn. Run the suite with:
5
- #
6
- # cognite agents eval
7
- #
8
- # Supported scorer types:
9
- # - correctness: compares the answer to a reference description you provide
10
- # (`reference`). Use it when you can describe a good answer.
11
- # - faithfulness: checks the answer is grounded in the supplied `context` and
12
- # does not hallucinate. Use it for retrieval / grounded answers.
13
- # - toolSelection: checks whether the agent picked an appropriate tool (or
14
- # correctly used none) for the question, based on the tools
15
- # configured in agent.yaml. Requires no extra fields, but only
16
- # makes sense once you've added tools (see README.md's
17
- # "Adding tools" section).
18
- # - toolInvocation: checks whether the agent invoked tools with correct
19
- # arguments and formatting. Complements toolSelection — use
20
- # both when you need full tool-calling coverage. Requires no
21
- # extra fields.
22
- #
23
- # These are placeholders — edit the inputs, references, and context to match what
24
- # your agent actually does, then add more cases over time.
2
+ # Run with: cognite agents eval
3
+ # Add more cases and scorer types as you add tools. See README.md.
25
4
 
26
5
  # To split cases across multiple files as your suite grows, add:
27
6
  # include:
28
7
  # - cases/maintenance.yaml
29
8
 
9
+ # Optional: tools for toolSelection / toolInvocation scorers (judge rubric — NOT the same
10
+ # as <name>.agent.yaml tools). <name>.agent.yaml configures the runtime (e.g. query); eval tools use
11
+ # names the agent actually calls (e.g. find_assets, execute). Omit when <name>.agent.yaml names
12
+ # match runtime calls; required when using --external-id / --system-agent.
13
+ # tools:
14
+ # - name: find_assets
15
+ # description: |
16
+ # Find assets in the knowledge graph.
17
+ # Parameters: filter (string, required), limit (integer, optional).
18
+
30
19
  cases:
31
- # Single-turn case scored for correctness.
20
+ # Single-turn case: the agent should explain what it can help with.
32
21
  - id: greeting
33
22
  turns:
34
23
  - input: "Hi, what can you help me with?"
35
24
  scorers:
36
25
  - type: correctness
37
- # Describe what a good answer looks like; the judge compares against this.
38
- reference: >-
26
+ criteria: >-
39
27
  A friendly greeting that briefly explains what this agent can help
40
28
  the user with.
41
29
 
42
- # Single-turn case scored for faithfulness against supplied context.
43
- - id: grounded-answer
44
- turns:
45
- - input: "Where is the main compressor located?"
46
- scorers:
47
- - type: faithfulness
48
- # The answer must be grounded in this context and not invent facts.
49
- context: >-
50
- The main compressor (unit C-101) is installed on Deck 2 of the
51
- North platform, next to the gas separation train.
52
-
53
- # Single-turn case scored for tool selection. Assumes you've added the
54
- # `find_assets` tool from README.md's "Adding tools" example — the judge
55
- # checks whether the agent picked an appropriate tool (or none) based on
56
- # the tools listed in agent.yaml.
57
- - id: find-assets-tool
58
- turns:
59
- - input: "Find assets related to compressors in the knowledge graph."
60
- scorers:
61
- - type: toolSelection
62
- - type: toolInvocation
63
-
64
30
  # Multi-turn case: the agent should carry context across turns.
65
- - id: assets-followup
31
+ - id: follow-up
66
32
  turns:
67
- - input: "List the assets in the cooling system."
33
+ - input: "What can you help me with?"
68
34
  scorers:
69
35
  - type: correctness
70
- reference: "Lists the assets that belong to the cooling system."
71
- - input: "Now show only the ones that are currently active."
36
+ criteria: "Describes the agent's capabilities."
37
+ - input: "Can you elaborate on the first thing you mentioned?"
72
38
  scorers:
73
39
  - type: correctness
74
- # Relies on the previous turn — the judge sees the earlier turns as context.
75
- reference: >-
76
- Narrows the previously listed cooling-system assets down to only
77
- the active ones.
40
+ criteria: >-
41
+ Expands on a capability mentioned in the previous response.
@@ -1,6 +1,6 @@
1
1
  # {{displayName}}
2
2
 
3
- > Edit `agent.yaml` to configure your agent — tools, model, instructions.
3
+ > Edit `<name>.agent.yaml` to configure your agent — tools, model, instructions.
4
4
 
5
5
  ## Quick start
6
6
 
@@ -19,24 +19,28 @@ cognite agents publish
19
19
 
20
20
  | Path | Purpose |
21
21
  |------|---------|
22
- | `agent.yaml` | Agent definition (externalId, tools, model, instructions) |
22
+ | `<name>.agent.yaml` | Agent definition (externalId, tools, model, instructions), named after this folder |
23
23
  | `eval/eval.yaml` | Example eval cases — run with `cognite agents eval` |
24
24
  | `README.md` | This file |
25
25
 
26
26
  ## Evaluating the agent
27
27
 
28
28
  `eval/eval.yaml` contains starter test cases (single-turn and multi-turn) that
29
- grade the agent's responses with an LLM judge. After pushing the agent, run:
29
+ grade the agent's responses with an LLM judge. The default cases are designed to
30
+ pass on a freshly pushed agent — push first, then run:
30
31
 
31
32
  ```bash
32
33
  cognite agents eval
33
34
  ```
34
35
 
35
36
  Edit the cases to match what your agent does, and add more over time.
37
+ Add tools in `<name>.agent.yaml` before adding tool-scorer eval cases (`toolSelection`, `toolInvocation`).
36
38
 
37
39
  ## Adding tools
38
40
 
39
- Edit the `tools` array in `agent.yaml`. Available tool types:
41
+ Edit the `tools` array in `<name>.agent.yaml`. Common tool types (illustrative — may not
42
+ reflect all available types; check the Cognite documentation or the agent builder
43
+ UI in Fusion for the latest list):
40
44
 
41
45
  - `analyzeData` — analyze tabular or structured data
42
46
  - `analyzeImage` — analyze images and P&ID diagrams
@@ -74,5 +78,8 @@ tools:
74
78
 
75
79
  ## Deployment with Toolkit
76
80
 
77
- The generated `agent.yaml` is compatible with [Cognite Toolkit](https://docs.cognite.com/cdf/deploy/toolkit/).
78
- Place it in your Toolkit module under `agents/` and deploy with `cdf deploy`.
81
+ The generated `<name>.agent.yaml` is compatible with [Cognite Toolkit](https://docs.cognite.com/cdf/deploy/toolkit/).
82
+ Place it in your Toolkit module under `agents/` and deploy with `cdf deploy`. Toolkit
83
+ treats the `<name>` part as a label and reads the `externalId` from inside the file,
84
+ so you can rename the file freely — the CLI keeps working as long as the folder holds
85
+ one definition.
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: check-agent
3
+ description: >-
4
+ Review <name>.agent.yaml and eval setup locally — description, instructions, tool alignment,
5
+ and common eval mismatches. Use when reviewing an agent, linting config, or asking
6
+ if anything looks wrong before push or publish.
7
+ ---
8
+
9
+ # Check agent
10
+
11
+ Produce a short markdown report from **local files only**. Do not call CDF APIs unless the user explicitly asks; for deployed state, suggest `cognite agents status`.
12
+
13
+ ## Workflow
14
+
15
+ 1. Read `<name>.agent.yaml` — `name`, `description`, `instructions`, `tools`, `exampleQuestions`, labels (e.g. published).
16
+ 2. Read `eval/eval.yaml` and any `include:` files under `eval/`.
17
+ 3. Read `AGENTS.md` when you need eval or prompt conventions.
18
+ 4. Run checks and label each finding **error**, **warn**, or **info** with a concrete fix:
19
+
20
+ | Check | Severity | Rule |
21
+ |-------|----------|------|
22
+ | `description` missing or empty | warn | Add a clear user-facing description. |
23
+ | `instructions` empty or obvious scaffold placeholder | warn | Replace with real guidance (see write-instructions skill). |
24
+ | Tool named in `instructions` but not in `tools[]` | error | Add the tool or remove the mention. |
25
+ | Tool in `tools[]` never mentioned in `instructions` | info | Document when/how to use it. |
26
+ | `toolSelection` / `toolInvocation` in eval but no tools resolve (no eval `tools` at any cascade level and no `<name>.agent.yaml` `tools`) | error | Add a `tools` field at root, file, case, or scorer level in eval yaml, or add tools to `<name>.agent.yaml`. With `--external-id`/`--system-agent`, `<name>.agent.yaml` is not loaded. |
27
+ | `labels` includes published but `exampleQuestions` empty | warn | Add starter questions for Fusion. |
28
+ | Eval case ids duplicated | error | Rename ids in `eval/eval.yaml`. |
29
+
30
+ 5. Optionally skim `README.md` for project-specific tool setup the checks above cannot see.
31
+
32
+ Keep the report scannable: bullet list grouped by severity, then suggested command order (`check-agent` → edit → `push` → `eval`).
33
+
34
+ ## Anti-patterns
35
+
36
+ - Do not block on network or credentials for a default review.
37
+ - Do not rewrite `instructions` in full during a review — flag issues and offer the write-instructions skill if the user wants a rewrite.
38
+ - Do not invent tool config schemas — point to `README.md` and `<name>.agent.yaml` examples.
39
+
40
+ ## Cross-references
41
+
42
+ - To improve `instructions` → **write-instructions** skill, then re-run this check.
43
+ - To add or fix eval coverage → **write-eval-case** skill.
44
+ - After a failed eval → **debug-eval** skill.
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: debug-eval
3
+ description: >-
4
+ Diagnose Cognite agent eval failures from CLI output — config drift, deployment,
5
+ invoke errors, and scorer rationales. Use when eval failed, a scorer failed, or
6
+ the user pastes eval run output.
7
+ ---
8
+
9
+ # Debug eval
10
+
11
+ Work through failures systematically using the user’s eval output (paste or summary).
12
+
13
+ ## Workflow
14
+
15
+ 1. Identify the failing **case id**, **turn**, and **scorer type** (if any). Note exit code and whether the whole suite or one case failed.
16
+ 2. **Config drift** — local `<name>.agent.yaml` / `eval/eval.yaml` may differ from what CDF runs. Suggest `cognite agents push` or `cognite agents eval --upsert` so eval matches the project on disk.
17
+ 3. **Not deployed** — if push was never done or status is stale, suggest `cognite agents push` and `cognite agents status` (run `cognite agents status --help` for flags).
18
+ 4. **Invoke / runtime errors** — auth, routing, or agent errors before scoring. Suggest `cognite auth login`, confirm project/cluster flags, and re-run with verbosity from `cognite agents eval --help` (e.g. `-v`).
19
+ 5. **Scorer failures** — read the judge rationale. For `correctness`, compare the response to `criteria`. For `faithfulness`, check `groundTruth` vs actual tool-retrieved facts. For tool scorers, check where the tool list resolved from (scorer → case → file → root `eval/eval.yaml` → `<name>.agent.yaml`); confirm runtime tool names match what the agent called (`toolsCalled:` output). A "Skipping … no tools available" warning means no tools resolved at all — add a `tools` field at the appropriate cascade level.
20
+ - **Common gotcha:** `<name>.agent.yaml` declares config-time names (e.g. `query`) but the agent calls runtime sub-tools (e.g. `find_assets`). Override with runtime names in eval `tools`.
21
+ - **`--external-id` / `--system-agent`:** `<name>.agent.yaml` tools are not loaded; tools must come from eval yaml.
22
+ 6. **Narrow the run** — suggest isolating with `--case` (repeatable), `--tag`, or `--fail-fast` per `cognite agents eval --help`.
23
+ 7. For scorer semantics or field meaning, read **AGENTS.md** rather than guessing.
24
+
25
+ Summarize likely root cause, concrete next step, and whether the fix is config, deployment, auth, instructions, or the eval case itself.
26
+
27
+ ## Anti-patterns
28
+
29
+ - Do not assume eval uses local YAML without push/`--upsert` unless the user confirmed deployment state.
30
+ - Do not change `criteria` or `groundTruth` to match a bad hallucination — fix retrieval, instructions, or the case intent.
31
+ - Do not list every CLI flag from memory — delegate to `--help`.
32
+
33
+ ## Cross-references
34
+
35
+ - If the case design or scorers are wrong → **write-eval-case** skill.
36
+ - If the agent behavior but instructions are weak → **write-instructions** skill, then **check-agent** for alignment.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: write-eval-case
3
+ description: >-
4
+ Guide authoring eval cases in eval/eval.yaml — scorer choice, multi-turn patterns,
5
+ and YAML structure. Use when adding tests, extending the eval suite, or validating
6
+ agent behavior for a Cognite agent project.
7
+ ---
8
+
9
+ # Write eval case
10
+
11
+ Help the user add or edit cases in `eval/eval.yaml` (or an `include:` fragment under `eval/`).
12
+
13
+ ## Workflow
14
+
15
+ 1. Read `<name>.agent.yaml` — note declared tools, model, and what the agent is meant to do.
16
+ 2. Read `AGENTS.md` — use the eval essentials table for scorer types and required fields, plus inheritance rules for `tags`, `dataModels`, `instanceSpaces`, and `appContext`.
17
+ 3. Ask what behavior to test: single-turn vs multi-turn, happy path vs edge case, and whether tool use should be exercised.
18
+ 4. Choose scorers using the AGENTS.md table:
19
+ - `correctness` when a good answer can be described in `criteria`.
20
+ - `faithfulness` when grounding against judge-only `groundTruth` matters (retrieval / facts).
21
+ - `toolSelection` / `toolInvocation` when tools are available via the cascade: scorer `tools` → case `tools` → file `tools` → root `eval/eval.yaml` `tools` → `<name>.agent.yaml` `tools`. Use runtime names (e.g. `find_assets`, `execute`), not config-time names (e.g. `query`). For `toolInvocation`, include parameter details in each tool's `description`.
22
+ 5. Draft YAML: unique `id`, optional `tags`, one or more `turns` with `input` and `scorers` on the turns you want judged.
23
+ 6. Validate locally: every case has at least one scored turn; no duplicate `id` values across the suite; tool scorers have tools resolvable via the cascade (eval yaml or `<name>.agent.yaml`).
24
+ 7. Remind the user that eval runs against **deployed** config — run `cognite agents push` first, or use `cognite agents eval --upsert`. For run filters and flags, run `cognite agents eval --help`.
25
+
26
+ Match existing `id` and tag style in the file. Prefer small, focused cases over one huge conversation.
27
+
28
+ ## Anti-patterns
29
+
30
+ - Do not put answer facts in `appContext` so the agent passes without using tools — see AGENTS.md “discover via tools”.
31
+ - Do not add `toolSelection` or `toolInvocation` when no tools resolve from the cascade (eval yaml levels + `<name>.agent.yaml`). If tools are empty, these scorers are skipped with a warning — not scored as "incorrect."
32
+ - Do not use `<name>.agent.yaml` config-time names (e.g. `query`) in eval `tools` when the agent calls different runtime sub-tools (e.g. `find_assets`). Run eval with `-v` to discover actual tool names.
33
+ - Do not duplicate case `id` values or leave turns unscored when the user expects a pass/fail result.
34
+ - Do not inline full scorer schemas in chat — point to `AGENTS.md` and the scaffolded examples in `eval/eval.yaml`.
35
+
36
+ ## Cross-references
37
+
38
+ - If the agent cannot pass because instructions are vague or wrong → use the **write-instructions** skill, then re-run eval.
39
+ - If a run fails and the case looks correct → use the **debug-eval** skill.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: write-instructions
3
+ description: >-
4
+ Guide writing or improving agent instructions in <name>.agent.yaml — purpose, constraints,
5
+ tool usage, and response style. Use when improving the system prompt, clarifying
6
+ behavior, or aligning instructions with declared tools.
7
+ ---
8
+
9
+ # Write instructions
10
+
11
+ Edit the `instructions` field in `<name>.agent.yaml`. Platform system behavior may apply on top; you only control the builder-editable layer.
12
+
13
+ ## Workflow
14
+
15
+ 1. Read `<name>.agent.yaml` — current `instructions`, `description`, `tools`, and any `appContext`-related fields you should stay consistent with.
16
+ 2. Read `AGENTS.md` — **Two-layer prompts** (your instructions vs platform behavior) and **discover via tools** (agents should retrieve with tools, not rely on hidden cheat sheets).
17
+ 3. Clarify with the user: primary audience, tone, allowed/refused actions, and which tools must be used for which tasks.
18
+ 4. Structure the prompt clearly:
19
+ - **Purpose** — what the agent is for in one short block.
20
+ - **Working principles** — how to reason, when to use tools, how to handle uncertainty.
21
+ - **Constraints** — safety, data scope, “do not” rules, org/project facts that must not be guessed.
22
+ - **Response style** — format, brevity, widgets or tables if the project uses them.
23
+ 5. For every entry in `tools[]`, add explicit guidance: when to call it, what inputs mean, and what to do if the tool fails.
24
+ 6. Remove contradictions, vague placeholders, and duplicate rules. Prefer specific, testable guidance evals can target.
25
+ 7. After edits, suggest `cognite agents push` and a targeted `cognite agents eval` (see `cognite agents eval --help`).
26
+
27
+ Propose changes as a unified diff or full `instructions` block the user can paste into `<name>.agent.yaml`.
28
+
29
+ ## Anti-patterns
30
+
31
+ - Do not promise capabilities no tool or platform feature provides.
32
+ - Do not embed secrets, tokens, or user credentials in instructions.
33
+ - Do not tell the agent to ignore tools when evals expect tool use (or the reverse).
34
+ - Do not paste entire scorer or CLI reference docs — link to `AGENTS.md` and `--help`.
35
+
36
+ ## Cross-references
37
+
38
+ - After rewriting → run **check-agent** to verify tool/instruction alignment and eval consistency.
39
+ - If evals fail on grounding or retrieval → **debug-eval** skill; if cases need updates → **write-eval-case** skill.
@@ -26,9 +26,9 @@ to: '<%= useCurrentDir ? "" : ((directoryName || name) + "/") %>package.json'
26
26
  "setup-https": "npx @cognite/cli@latest apps setup-https"
27
27
  },
28
28
  "dependencies": {
29
- "@cognite/aura": "^0.3.1",
29
+ "@cognite/aura": "^0.3.5",
30
30
  "@cognite/sdk": "^10.10.0",
31
- "@cognite/app-sdk": "^0.8.0",
31
+ "@cognite/app-sdk": "^0.9.0",
32
32
  "@tabler/icons-react": "^3.35.0",
33
33
  "@tanstack/react-query": "^5.90.10",
34
34
  "clsx": "^2.1.1",
@@ -12,33 +12,37 @@ import App from './App';
12
12
 
13
13
  type AppDeps = NonNullable<ComponentProps<typeof App>['deps']>;
14
14
 
15
- function makeApi(): HostAppAPI {
15
+ type AppApi = Pick<HostAppAPI, 'syncInternalState'>;
16
+
17
+ function makeApi(): AppApi {
16
18
  return {
17
- getProject: vi.fn<HostAppAPI['getProject']>(() => Promise.resolve('<%= project %>')),
18
- getBaseUrl: vi.fn<HostAppAPI['getBaseUrl']>(() => Promise.resolve('https://cognite.test')),
19
- getAccessToken: vi.fn<HostAppAPI['getAccessToken']>(() => Promise.resolve('test-token')),
20
- getAppId: vi.fn<HostAppAPI['getAppId']>(() => Promise.resolve('test-app-id')),
21
19
  syncInternalState: vi.fn<HostAppAPI['syncInternalState']>(() => Promise.resolve(true)),
22
- navigateInternal: vi.fn<HostAppAPI['navigateInternal']>(() => Promise.resolve(true)),
23
- navigateExternal: vi.fn<HostAppAPI['navigateExternal']>(() => Promise.resolve(true)),
24
- registerAgentServer: vi.fn<HostAppAPI['registerAgentServer']>(() => Promise.resolve()),
25
- unregisterAgentServer: vi.fn<HostAppAPI['unregisterAgentServer']>(() => Promise.resolve()),
26
- sendAgentLayoutMode: vi.fn<HostAppAPI['sendAgentLayoutMode']>(() => Promise.resolve()),
27
- sendAgentMessage: vi.fn<HostAppAPI['sendAgentMessage']>(() => Promise.resolve()),
28
- sendAgentTheme: vi.fn<HostAppAPI['sendAgentTheme']>(() => Promise.resolve()),
29
20
  };
30
21
  }
31
22
 
32
- function makeLoadingDeps(): AppDeps {
23
+ function makeConnectedFn(api: AppApi = makeApi()) {
24
+ return vi.fn(() => Promise.resolve({ api }));
25
+ }
26
+
27
+ function makeDeps(): AppDeps {
33
28
  return {
34
- connectToHostApp: vi.fn<AppDeps['connectToHostApp']>(() => new Promise<ConnectToHostAppResult>(() => undefined)),
29
+ connectToHostApp: vi.fn<AppDeps['connectToHostApp']>(() =>
30
+ Promise.resolve({
31
+ api: {
32
+ getProject: vi.fn<HostAppAPI['getProject']>(() => Promise.resolve('<%= project %>')),
33
+ getBaseUrl: vi.fn<HostAppAPI['getBaseUrl']>(() => Promise.resolve('https://cognite.test')),
34
+ getAccessToken: vi.fn<HostAppAPI['getAccessToken']>(() => Promise.resolve('test-token')),
35
+ getAppId: vi.fn<HostAppAPI['getAppId']>(() => Promise.resolve('test-app-id')),
36
+ } as Partial<HostAppAPI> as HostAppAPI,
37
+ })
38
+ ),
35
39
  createClient: vi.fn<AppDeps['createClient']>((config) => new CogniteClient(config)),
36
40
  };
37
41
  }
38
42
 
39
- function makeConnectedDeps(api = makeApi()): AppDeps {
43
+ function makeLoadingDeps(): AppDeps {
40
44
  return {
41
- connectToHostApp: vi.fn<AppDeps['connectToHostApp']>(() => Promise.resolve({ api })),
45
+ connectToHostApp: vi.fn<AppDeps['connectToHostApp']>(() => new Promise<ConnectToHostAppResult>(() => undefined)),
42
46
  createClient: vi.fn<AppDeps['createClient']>((config) => new CogniteClient(config)),
43
47
  };
44
48
  }
@@ -49,12 +53,12 @@ describe('App', () => {
49
53
  });
50
54
 
51
55
  it('renders loading state', () => {
52
- render(<App deps={makeLoadingDeps()} />);
56
+ render(<App deps={makeLoadingDeps()} connectToHostApp={() => new Promise<never>(() => undefined)} />);
53
57
  expect(screen.getByText('Loading project...')).toBeInTheDocument();
54
58
  });
55
59
 
56
60
  it('renders splash with deployment targets and checklist copy', async () => {
57
- render(<App deps={makeConnectedDeps()} />);
61
+ render(<App deps={makeDeps()} connectToHostApp={makeConnectedFn()} />);
58
62
  await waitFor(() => expect(screen.getByText('Welcome to Flows custom apps')).toBeInTheDocument());
59
63
  expect(screen.getByText('App deployment checklist')).toBeInTheDocument();
60
64
  expect(screen.getByText('Plan')).toBeInTheDocument();
@@ -73,7 +77,7 @@ describe('App', () => {
73
77
 
74
78
  it('syncs internal state when the open step changes', async () => {
75
79
  const api = makeApi();
76
- render(<App deps={makeConnectedDeps(api)} />);
80
+ render(<App deps={makeDeps()} connectToHostApp={makeConnectedFn(api)} />);
77
81
  await waitFor(() => expect(screen.getByText('App deployment checklist')).toBeInTheDocument());
78
82
 
79
83
  await userEvent.click(screen.getByText('Explore'));
@@ -85,13 +89,10 @@ describe('App', () => {
85
89
 
86
90
  it('restores the open step from initial state', async () => {
87
91
  const api = makeApi();
88
- const deps: AppDeps = {
89
- connectToHostApp: vi.fn<AppDeps['connectToHostApp']>(() =>
90
- Promise.resolve({ api, initialState: JSON.stringify({ openStep: 'Deploy' }) })
91
- ),
92
- createClient: vi.fn<AppDeps['createClient']>((config) => new CogniteClient(config)),
93
- };
94
- render(<App deps={deps} />);
92
+ render(<App
93
+ deps={makeDeps()}
94
+ connectToHostApp={() => Promise.resolve({ api, initialState: JSON.stringify({ openStep: 'Deploy' }) })}
95
+ />);
95
96
  await waitFor(() => expect(screen.getByText('App deployment checklist')).toBeInTheDocument());
96
97
 
97
98
  await waitFor(() =>