Skip to content

Commit dd000c2

Browse files
committed
docs: improved documentation
1 parent 9714e9c commit dd000c2

File tree

6 files changed

+172
-11
lines changed

6 files changed

+172
-11
lines changed

docs/concepts.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ using:
2323
- shell
2424
```
2525
26+
#### Agent Configuration Fields
27+
28+
- **`agent`**: The system prompt defining the agent's role
29+
- **`task`**: The objective or behavior (can use Jinja2 templating)
30+
- **`generator`**: Override the default LLM model
31+
- **`reasoning`**: Enable reasoning for supported models (`low`, `medium`, or `high`)
32+
- **`description`**: Human-readable description of the agent
33+
- **`version`**: Version string for your agent
34+
- **`requires`**: Minimum Nerve version requirement (e.g., `">=1.2.0"`)
35+
- **`defaults`**: Pre-set values for variables that can be overridden via CLI
36+
- **`limits`**: Execution constraints:
37+
- `max_steps`: Maximum number of steps
38+
- `max_cost`: Maximum cost in USD
39+
- `timeout`: Timeout in seconds
40+
- **`jail`**: Restrict namespace access to specific filesystem paths
41+
- **`using`**: List of built-in namespaces to import
42+
- **`mcp`**: MCP server configurations
43+
- **`tools`**: Custom tool definitions
44+
2645
#### Enable Reasoning
2746

2847
For models supporting reasoning, you can add a `reasoning` field to enable it, with a value that can either be `low`, `medium` or `high`.
@@ -35,7 +54,7 @@ Nerve supports [Jinja2](https://jinja.palletsprojects.com/) templating for dynam
3554
- Reference built-in variables like `{{ CURRENT_DATE }}` or `{{ LOCAL_IP }}`
3655

3756
### Tools
38-
Tools extend the agents capabilities. They can be:
57+
Tools extend the agent's capabilities. They can be:
3958
- **Shell commands** (interpolated into a shell script)
4059
- **Python functions** (via annotated `tools.py` files)
4160
- **Remote tools via MCP** (from another Nerve instance or a compatible server)
@@ -52,6 +71,34 @@ tools:
5271
tool: curl wttr.in/{{ city }}
5372
```
5473

74+
#### Tool Configuration Properties
75+
76+
Tools can have additional properties:
77+
```yaml
78+
tools:
79+
- name: process_data
80+
description: Process the input data
81+
complete_task: true # Marks task as complete when this tool returns
82+
print: true # Print tool output to console
83+
mime: "application/json" # Specify output format
84+
arguments:
85+
- name: data
86+
description: Input data
87+
tool: | # For shell-based tools, the command template
88+
echo "Processing: {{ data }}"
89+
```
90+
91+
#### Auto-loading Tools
92+
If a `tools.py` file exists in the agent's directory, it's automatically loaded without needing to specify it in the YAML configuration.
93+
94+
#### Tools in Templates
95+
You can call tools directly from Jinja2 templates in prompts:
96+
```yaml
97+
task: |
98+
Process this data: {{ get_data_tool() }}
99+
And analyze the results.
100+
```
101+
55102
### Workflows
56103
A **workflow** is a YAML file that chains multiple agents sequentially. Each agent in the pipeline can:
57104
- Use a different model
@@ -107,4 +154,3 @@ graph TD
107154
```
108155

109156
This loop continues until the task is complete, failed, or times out.
110-

docs/evaluation.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ nerve eval path/to/evaluation --output results.json
2020
```
2121
Each case is passed to the agent, and results (e.g., completion, duration, output) are saved.
2222

23+
### Trace Integration
24+
Evaluation runs can automatically generate trace files for debugging:
25+
```bash
26+
nerve eval path/to/evaluation --output results.json --trace eval-trace.jsonl
27+
```
28+
This captures all events during evaluation for analysis, including tool calls, variable changes, and execution flow.
29+
2330

2431
## 🗂 Case Formats
2532
Nerve supports three evaluation case formats:
@@ -91,4 +98,3 @@ Results are written to a `.json` file with details like:
9198
- [concepts.md](concepts.md#evaluation)
9299
- [index.md](index.md): CLI usage
93100
- [mcp.md](mcp.md): when using remote agents or tools in evaluation
94-

docs/index.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,39 @@ Run it with:
7070
nerve run new-agent --url cnn.com
7171
```
7272

73+
#### Full Configuration Example
74+
```yaml
75+
# Complete agent configuration with all available fields
76+
agent: You are a helpful assistant.
77+
task: Make an HTTP request to {{ url }}
78+
generator: openai/gpt-4o # optional, override default generator
79+
reasoning: medium # optional: low, medium, or high for reasoning models
80+
description: "This agent makes HTTP requests" # optional description
81+
version: "1.0.0" # optional version string
82+
requires: ">=1.2.0" # optional minimum Nerve version requirement
83+
84+
# Set default values for variables
85+
defaults:
86+
url: "https://example.com"
87+
timeout: 30
88+
89+
# Restrict namespace access to specific paths
90+
jail:
91+
filesystem:
92+
- "/allowed/path"
93+
- "{{ target_dir }}"
94+
95+
# Set execution limits
96+
limits:
97+
max_steps: 100
98+
max_cost: 5.0
99+
timeout: 300 # seconds
100+
101+
using:
102+
- shell
103+
- task
104+
```
105+
73106
#### Enable Reasoning
74107
75108
For models supporting reasoning, you can add a `reasoning` field to enable it, with a value that can either be `low`, `medium` or `high`.
@@ -168,10 +201,10 @@ Run in interactive step-by-step mode:
168201
nerve run agent -i
169202
```
170203
Available commands:
171-
- `step`, `s`, or `Enter`: one step
172-
- `continue`, `c`: run till done
173-
- `view`, `v`: view current state
174-
- `quit`, `q`, `exit`: exit
204+
- `step`, `s`, or `Enter`: Execute one step
205+
- `continue`, `c`: Run until task completion
206+
- `view`, `v`: View current state and variables
207+
- `quit`, `q`, `exit`: Exit the agent
175208

176209
### 🎥 Record & Replay
177210
Record sessions:
@@ -184,6 +217,13 @@ nerve play trace.jsonl
184217
nerve play trace.jsonl -f # fast-forward
185218
```
186219

220+
### 📊 Trace Files
221+
Trace files are JSONL (JSON Lines) format with one event per line:
222+
```bash
223+
nerve run agent --trace trace.jsonl
224+
```
225+
Events include: `task_started`, `step_started`, `tool_called`, `variable_change`, `task_complete`, and more. This is useful for debugging agent behavior and analyzing execution flow.
226+
187227
### 🛠 Adding Tools
188228
See [concepts.md](concepts.md#tools) for details.
189229

@@ -288,4 +328,4 @@ nerve run <agent-name> --litellm-tracing langfuse
288328
- [mcp.md](mcp.md): Advanced agent integration with MCP
289329
- `namespaces.md`: (Coming soon)
290330

291-
Run `nerve -h` to explore all commands and flags.
331+
Run `nerve -h` to explore all commands and flags.

docs/mcp.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,47 @@ mcp:
3737
url: stream://localhost:8080/example
3838
```
3939
40+
### MCP Server Configuration Options
41+
42+
Full configuration options for MCP servers:
43+
44+
```yaml
45+
mcp:
46+
my_server:
47+
# For stdio-based servers (process communication)
48+
command: python # Command to execute
49+
args: ["server.py"] # Arguments for the command
50+
env: # Environment variables
51+
API_KEY: "secret"
52+
DEBUG: "true"
53+
session_timeout: 5 # Connection timeout in seconds (default: 5)
54+
55+
# For SSE (Server-Sent Events)
56+
sse_server:
57+
url: http://localhost:9090/ # SSE endpoint
58+
headers: # Optional HTTP headers
59+
Authorization: "Bearer token"
60+
X-Custom-Header: "value"
61+
timeout: 5 # Connection timeout (default: 5)
62+
read_timeout: 300 # Read timeout in seconds (default: 5 minutes)
63+
64+
# For Streamable HTTP
65+
stream_server:
66+
url: stream://localhost:8080/example # Prefix with stream://
67+
headers: # Optional HTTP headers
68+
Authorization: "Bearer token"
69+
timeout: 5 # Connection timeout
70+
read_timeout: 300 # Read timeout
71+
```
72+
73+
### Transport Mechanisms
74+
75+
Nerve supports three transport mechanisms for MCP:
76+
77+
- **stdio**: Process-based communication (default). The MCP server runs as a subprocess and communicates via standard input/output.
78+
- **SSE**: Server-Sent Events over HTTP. Connect to an HTTP endpoint that streams events.
79+
- **Streamable HTTP**: HTTP with streaming responses. Similar to SSE but uses a different protocol (prefix URL with `stream://`).
80+
4081
You can connect to any of the [publicly available MCP servers](https://github.com/punkpeye/awesome-mcp-servers), or define your own custom tools.
4182

4283
## 🖧 MCP Server
@@ -115,4 +156,3 @@ For full examples, see the [mcp-recipe](https://github.com/evilsocket/nerve/tree
115156
- [concepts.md](concepts.md#mcp-model-context-protocol) — overview of how MCP fits into Nerve's architecture
116157
- [index.md](index.md) — quick usage examples
117158
- [workflows.md](workflows.md) — for linear pipelines (MCP enables more complex ones)
118-

docs/namespaces.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
Nerve offers a rich set of predefined tools, organized in namespaces, that the agent can import [via the `using` directive](index.md#usage). This page contains the list of namespaces available in Nerve, with the descriptive prompt that will be provided to the model.
44

5+
> [!NOTE]
6+
> The `jail` directive can restrict filesystem and filesystem_w namespaces to specific paths:
7+
> ```yaml
8+
> jail:
9+
> filesystem: ["/allowed/path", "/another/allowed/path"]
10+
> filesystem_w: ["/writable/path", "{{ dynamic_path }}"]
11+
> ```
12+
> Variables can be used in jail paths for dynamic configuration.
13+
514
## 🔧 anytool
615
716
Let the agent create its own tools in Python.
@@ -334,4 +343,3 @@ Provides tools for getting the current date and time and waiting for a given num
334343
* `seconds` <i>(<class 'int'>)</i>: The number of seconds to wait
335344
336345
</details>
337-

docs/workflows.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,28 @@ tools:
116116
[ ... ]
117117
```
118118

119+
## 🔄 State and Variables
120+
121+
### Variable Passing
122+
Variables are shared across all agents in a workflow. Each agent can:
123+
- Read variables set by previous agents
124+
- Set new variables for subsequent agents
125+
- Override existing variables
126+
127+
### Default Values
128+
Each agent can define defaults that apply when variables aren't set:
129+
```yaml
130+
defaults:
131+
temperature: 0.7
132+
max_tokens: 1000
133+
```
134+
135+
### Variable Interpolation
136+
All text fields support Jinja2 templating:
137+
```yaml
138+
task: Process {{ food }} with {{ ingredients }}
139+
```
140+
119141
## 📎 Notes
120142
- Agents receive inputs from previous agents via templating variables (e.g., `{{ ingredients }}`)
121143
- Each tool must call `complete_task: true` to advance the workflow
@@ -125,4 +147,3 @@ tools:
125147
- [concepts.md](concepts.md#workflows)
126148
- [mcp.md](mcp.md): for building advanced orchestrations
127149
- [index.md](index.md): CLI usage overview
128-

0 commit comments

Comments
 (0)