Skip to content

Commit 2e72087

Browse files
bryaneganclaude
andcommitted
Update AGENT_COORDINATION.md with run_and_narrow() API
Document the automated feedback loop: run_and_narrow() executes a command in a sandbox and returns output + narrowing report in one call. Also mention narrow_with_observations() for richer audit data. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ccac182 commit 2e72087

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

docs/AGENT_COORDINATION.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,41 @@ let tighter_task = report.suggested_config;
237237
// This sandbox only grants cargo + crates.io
238238
```
239239

240+
### `run_and_narrow()` — Automated feedback loop
241+
242+
Instead of manually collecting observations, use `run_and_narrow()` to
243+
execute and narrow in one call:
244+
245+
```rust
246+
let task = TaskSandbox::new("/workspace")
247+
.needs_tools(["cargo", "git", "npm"])
248+
.needs_network(["crates.io", "registry.npmjs.org"]);
249+
250+
let result = task.run_and_narrow("cargo", &["test"])?;
251+
println!("{}", result.narrowing.summary);
252+
// "Unused capabilities: tools: [git, npm], domains: [registry.npmjs.org]"
253+
254+
// Use the tighter config next time:
255+
let tighter = result.narrowing.suggested_config;
256+
```
257+
258+
For richer observation data (from `gleisner record` or the audit pipeline),
259+
use `narrow_with_observations()`:
260+
261+
```rust
262+
let result = task.narrow_with_observations(output, observed_from_audit_log);
263+
```
264+
240265
The narrowing loop:
241266

242267
```
243268
Run 1: Declare [cargo, git, npm] + [crates.io, registry.npmjs.org]
244-
Observe: only cargo + crates.io used
245-
narrow() → suggested: [cargo] + [crates.io]
269+
run_and_narrow("cargo", &["test"])
270+
→ "Unused capabilities: tools: [git, npm], domains: [registry.npmjs.org]"
246271
247-
Run 2: Declare [cargo] + [crates.io]
248-
Observe: cargo + crates.io used
249-
narrow() → "All declared capabilities were used — configuration is already minimal."
272+
Run 2: Use suggested_config → [cargo] + [crates.io]
273+
run_and_narrow("cargo", &["test"])
274+
→ "All declared capabilities were used — configuration is already minimal."
250275
```
251276

252277
### `merge(other)` — Combine multi-agent needs

0 commit comments

Comments
 (0)