Skip to content

Commit 65627ed

Browse files
committed
update docs
1 parent d069058 commit 65627ed

2 files changed

Lines changed: 211 additions & 0 deletions

File tree

File renamed without changes.

docs/EXAMPLES.md

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
# Examples
2+
3+
Short, runnable patterns for **`apiVersion: agentic.dev/v0`**. For the full YAML spec, CLI behaviour, and field semantics, see [**`design_doc.md`**](design_doc.md).
4+
5+
---
6+
7+
## 1. Scaffold with `agentctl init`
8+
9+
```bash
10+
agentctl init my-agent-system
11+
```
12+
13+
Creates a directory layout like:
14+
15+
```text
16+
my-agent-system/
17+
project.yaml
18+
policies/default.yaml
19+
tools/helper.yaml
20+
workflows/hello.yaml
21+
```
22+
23+
The generated files match the snippets in sections 2–4 below (with `metadata.name` set from the argument you pass to `init`).
24+
25+
---
26+
27+
## 2. Root `project.yaml` (mock model, local-only)
28+
29+
`spec.imports` lists YAML files relative to the project root. `defaults.model` uses the form **`namespace/model_id`**, where **`namespace`** matches a key under `spec.providers.models`.
30+
31+
```yaml
32+
apiVersion: agentic.dev/v0
33+
kind: Project
34+
metadata:
35+
name: my-agent-system
36+
spec:
37+
imports:
38+
- ./policies/default.yaml
39+
- ./tools/helper.yaml
40+
- ./workflows/hello.yaml
41+
defaults:
42+
policy: default
43+
model: mock/gpt-4
44+
providers:
45+
models:
46+
mock:
47+
type: mock
48+
```
49+
50+
---
51+
52+
## 3. Policy, native tool, tool-only workflow
53+
54+
**`policies/default.yaml`**
55+
56+
```yaml
57+
apiVersion: agentic.dev/v0
58+
kind: Policy
59+
metadata:
60+
name: default
61+
spec:
62+
execution:
63+
maxWallClockSeconds: 300
64+
maxTotalCostUsd: 5
65+
```
66+
67+
**`tools/helper.yaml`** — `type: native` uses built-in tools (see design doc for names).
68+
69+
```yaml
70+
apiVersion: agentic.dev/v0
71+
kind: Tool
72+
metadata:
73+
name: helper
74+
spec:
75+
type: native
76+
```
77+
78+
**`workflows/hello.yaml`** — each step sets **exactly one** of `uses` (tool) or `agent` (LLM agent).
79+
80+
```yaml
81+
apiVersion: agentic.dev/v0
82+
kind: Workflow
83+
metadata:
84+
name: hello
85+
spec:
86+
policy: default
87+
steps:
88+
- id: greet
89+
uses: tool.helper.echo
90+
with:
91+
message: "hello"
92+
```
93+
94+
Run the usual loop from the parent of the project directory:
95+
96+
```bash
97+
agentctl validate --project my-agent-system
98+
agentctl plan --project my-agent-system
99+
agentctl apply --project my-agent-system --auto-approve
100+
agentctl run workflow/hello --project my-agent-system
101+
```
102+
103+
---
104+
105+
## 4. OpenAI chat (real model)
106+
107+
The control plane currently wires **`type: openai`** to the OpenAI **`/v1/chat/completions`** API. Set a key via **`apiKeyFrom`** (MVP: **`env:VAR`** only).
108+
109+
**`project.yaml`** (add an `openai` provider and point defaults at an OpenAI model id):
110+
111+
```yaml
112+
apiVersion: agentic.dev/v0
113+
kind: Project
114+
metadata:
115+
name: my-agent-system
116+
spec:
117+
imports:
118+
- ./policies/default.yaml
119+
- ./tools/helper.yaml
120+
- ./agents/assistant.yaml
121+
- ./workflows/chat.yaml
122+
defaults:
123+
policy: default
124+
model: openai/gpt-4o-mini
125+
providers:
126+
models:
127+
mock:
128+
type: mock
129+
openai:
130+
type: openai
131+
apiKeyFrom: env:OPENAI_API_KEY
132+
```
133+
134+
```bash
135+
export OPENAI_API_KEY="sk-..." # required before validate/plan/apply/run
136+
```
137+
138+
**`agents/assistant.yaml`** — `metadata.name` is what workflow steps reference in **`agent:`**. The executor expects the model’s reply to be a **JSON object** (plain text, not fenced code blocks).
139+
140+
```yaml
141+
apiVersion: agentic.dev/v0
142+
kind: Agent
143+
metadata:
144+
name: assistant
145+
spec:
146+
model: openai/gpt-4o-mini
147+
policy: default
148+
instructions: |
149+
You are a concise assistant. Respond with a single JSON object only, no markdown.
150+
Shape: {"message": "<your reply>"}
151+
```
152+
153+
**`workflows/chat.yaml`**
154+
155+
```yaml
156+
apiVersion: agentic.dev/v0
157+
kind: Workflow
158+
metadata:
159+
name: chat
160+
spec:
161+
policy: default
162+
steps:
163+
- id: reply
164+
agent: assistant
165+
with:
166+
topic: "Say hello in one short sentence."
167+
```
168+
169+
```bash
170+
agentctl run workflow/chat --project my-agent-system
171+
```
172+
173+
Optional: add **`spec.output.schema`** on the agent (path relative to project root) to validate the JSON against JSON Schema; see test fixtures under `internal/engine/testdata/` and **`design_doc.md`**.
174+
175+
---
176+
177+
## 5. Environment overlay
178+
179+
Declare an **`Environment`** resource and pass **`-e` / `--env`** to `validate`, `plan`, or `apply` when you want overrides (for example stricter or looser policy limits).
180+
181+
**`environments/staging.yaml`**
182+
183+
```yaml
184+
apiVersion: agentic.dev/v0
185+
kind: Environment
186+
metadata:
187+
name: staging
188+
spec:
189+
overrides:
190+
policies:
191+
default:
192+
execution:
193+
maxWallClockSeconds: 600
194+
```
195+
196+
Add **`./environments/staging.yaml`** to **`spec.imports`** in `project.yaml`, then:
197+
198+
```bash
199+
agentctl validate --project my-agent-system -e staging
200+
```
201+
202+
---
203+
204+
## 6. Model reference cheat sheet
205+
206+
| `defaults.model` / `spec.model` (agent) | Meaning |
207+
|----------------------------------------|---------|
208+
| `mock/gpt-4` | Deterministic mock string (no network) |
209+
| `openai/gpt-4o-mini` | OpenAI API model id `gpt-4o-mini` via `providers.models.openai` |
210+
211+
The segment before **`/`** must match a key under **`spec.providers.models`**. Unsupported provider types fail at runtime with an error from the model registry.

0 commit comments

Comments
 (0)