Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pnpm tsx examples/improve/improve.ts
| [`mcp-delegation`](./mcp-delegation/) | another agent needs Runtime's delegation tools over MCP |
| [`fleet-delegation`](./fleet-delegation/) | delegated workers must share a fleet workspace |
| [`knowledge-gating`](./knowledge-gating/) | execution must stop when required knowledge is below threshold |
| [`researcher-loop`](./researcher-loop/) | a domain uses the optional `agent-knowledge` peer and a hard isolation check |
| [`researcher-loop`](./researcher-loop/) | a domain preset on a caller-owned profile, with a hard tenant-isolation check |
| [`sanitized-telemetry-streaming`](./sanitized-telemetry-streaming/) | runtime telemetry must be useful without leaking user content |

## Specialized examples
Expand Down
1 change: 1 addition & 0 deletions examples/driver-loop/scripted-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function scriptedWorkerClient(): SandboxClient {
data: { model: 'scripted', tokensIn: 200, tokensOut: 40, costUsd: 0.0006 },
},
{ type: 'result', data: { result: { note } satisfies NoteOutput } },
{ type: 'done', data: { outcome: { type: 'completed' } } },
]
},
})
Expand Down
1 change: 1 addition & 0 deletions examples/quickstart/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const profile = {
const worker = inProcessSandboxClient({
onPrompt: (): SandboxEvent[] => [
{ type: 'result', data: { result: { note: 'Shipped one-click restore.' } } },
{ type: 'done', data: { outcome: { type: 'completed' } } },
],
})

Expand Down
1 change: 1 addition & 0 deletions examples/quickstart/quickstart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const worker = inProcessSandboxClient({
},
},
},
{ type: 'done', data: { outcome: { type: 'completed' } } },
],
})

Expand Down
14 changes: 6 additions & 8 deletions examples/researcher-loop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ written. It also shows the **propose-don't-apply** contract: the winning agent r

## How it works

1. `researcherProfile({ task })` hands you three things wired to work together: the system prompt for
a research agent, the output parser that turns its reply into structured findings, and the
validator that scores them.
1. `researcherProfile({ profile, task })` hands you three things wired to work together on top of a
profile you own: the system prompt for a research agent, the output parser that turns its reply
into structured findings, and the validator that scores them. The harness, provider and model
stay yours; the preset supplies the research half.
2. A tiny **driver** launches two agents on the same question (a "fanout"), collects both answers,
and asks the loop to pick the best valid one.
3. The validator scores each answer on citation density and per-claim evidence, and **hard-fails**
Expand All @@ -32,11 +33,8 @@ written. It also shows the **propose-don't-apply** contract: the winning agent r
## Run

```bash
# 1. Install the one optional package this example needs (the runtime does NOT depend on it —
# domain packs are injected, not bundled, so it isn't installed by default):
pnpm add -D @tangle-network/agent-knowledge

# 2. Run it (fully offline — the two agent answers are scripted fixtures, no model call, no key):
# Fully offline — the two agent answers are scripted fixtures, no model call, no key, no
# extra package. `researcherProfile` ships in this repo, under @tangle-network/agent-runtime/profiles.
pnpm tsx examples/researcher-loop/researcher-loop.ts
```

Expand Down
18 changes: 14 additions & 4 deletions examples/researcher-loop/researcher-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,31 @@
* different knowledge namespace, so the bad candidate is pruned by construction.
*
* Offline: the two synthetic researcher outputs and the stand-in `sandboxClient` live in
* ./synthetic-researcher.ts. Needs the optional `@tangle-network/agent-knowledge` peer.
* ./synthetic-researcher.ts. No model call, no key, no extra package.
*
* Run: pnpm tsx examples/researcher-loop/researcher-loop.ts
*/

import type { AgentProfile } from '@tangle-network/agent-interface'
import { type Driver, runAgentRounds } from '@tangle-network/agent-runtime/kernel'
import {
type ResearchOutput,
type ResearchTask,
researcherProfile,
} from '@tangle-network/agent-knowledge/profiles'
import { type Driver, runAgentRounds } from '@tangle-network/agent-runtime/kernel'
} from '@tangle-network/agent-runtime/profiles'
import { sandboxClient, task } from './synthetic-researcher'

// The caller owns the harness/provider/model identity; the preset supplies the research system
// prompt, the output parser, and the validator on top of it. `scripted` is what the offline
// sandbox client below answers to — swap it for a real provider to run this live.
const researcher = {
name: 'researcher',
harness: 'cli-base',
model: { provider: 'scripted', default: 'scripted/researcher' },
} satisfies AgentProfile

async function main(): Promise<void> {
const { output, validator, agentRunSpec } = researcherProfile({ task })
const { output, validator, agentRunSpec } = researcherProfile({ profile: researcher, task })
const driver: Driver<ResearchTask, ResearchOutput, 'pick-winner' | 'fail'> = {
name: 'fanout',
// A "round" = one plan → run workers → decide cycle. This driver is SINGLE-ROUND:
Expand Down
3 changes: 2 additions & 1 deletion examples/researcher-loop/synthetic-researcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* whole output, so the kernel prunes it and the valid candidate wins.
*/

import type { ResearchOutput, ResearchTask } from '@tangle-network/agent-knowledge/profiles'
import { inProcessSandboxClient, type SandboxClient } from '@tangle-network/agent-runtime/kernel'
import type { ResearchOutput, ResearchTask } from '@tangle-network/agent-runtime/profiles'
import type { SandboxEvent } from '@tangle-network/sandbox'

export const namespace = 'example-tenant'
Expand Down Expand Up @@ -138,6 +138,7 @@ export const sandboxClient: SandboxClient = inProcessSandboxClient({
},
},
{ type: 'result', data: { result: output } },
{ type: 'done', data: { outcome: { type: 'completed' } } },
]
},
})
2 changes: 1 addition & 1 deletion tsconfig.examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
"sourceMap": false
},
"include": ["examples"],
"exclude": ["node_modules", "dist", "examples/researcher-loop"]
"exclude": ["node_modules", "dist"]
}