Skip to content

Agents

An agent is a file in agents/. The file name, without .ts, is the key an agent stage refers to.

agents/greeter.ts
'use agent';
import { useModel } from '@flue/runtime';
import { defaultModel } from '@knetikdotdev/sdk';
export function Greeter() {
useModel(defaultModel());
return 'You write short, friendly greetings. Reply with a JSON array of objects {id, label, detail} and nothing else.';
}
// Flue agent identities must be unique across the host, so every module namespaces its agents.
Greeter.agentName = 'hello-greeter';

knetik check enforces them:

  • The file starts with 'use agent'.
  • It exports a function whose name starts with a capital letter.
  • It sets <Fn>.agentName = '<module-id>-<name>'. Letters, digits and single dashes only, no dots.
  • Every agent a stage names exists, and an agent no stage uses produces a warning.

The function body is Flue’s agent API. The string it returns is the agent’s instructions.

defaultModel() from the SDK returns KNETIK_DEFAULT_MODEL, or faux/stub-1 when it is unset. The host decides the model, so a module does not hard-code one. Tests and knetik dev replace it with a scripted model.

Import these from @knetikdotdev/sdk/agent inside agent files.

Helper Gives the agent
useKnetikTools({ search, fetchPage }) web_search and fetch_page tools, backed by the deployment’s search provider and the safe page fetch. Both return untrusted text from the open web, and the tool descriptions tell the model so. It acts on the current run, never on model-chosen arguments. Returns false and mounts nothing when the host provides no capabilities.
useMcpConnector(name, { tools }) The tools of an MCP connector declared in the manifest. The URL and the token come from the host and refresh per request; the model never sees either. Without a usable connection the agent simply has no tools from it.
import { useKnetikTools } from '@knetikdotdev/sdk/agent';
export function Strategist() {
useModel(defaultModel());
useKnetikTools({ search: true, fetchPage: true });
return 'You are an editorial strategist. Check facts with the tools before proposing angles.';
}
Strategist.agentName = 'content-creator-strategist';

Anything fetched from the web is data, not instructions. The content creator fences each source in <source> tags, labels them untrusted and defangs any attempt to close the fence. But the real defenses are structural: agents cannot publish, the writer has no tools, and a person approves before anything leaves the system. Design your gates the same way.