form-write-direct
Save form submissions and simple CRUD deterministically — no LLM, no tokens, no streaming
Plane: data_pattern
Steps:
1. useCollection — For plain saves: call insert/update/remove directly — deterministic, instant, free.
2. useToolInvocation — Only when you need a SPECIFIC agent tool deterministically (e.g. a registered agent's mongodb_query) — direct tool call, still no LLM.
Examples
End-to-end example
import { useState } from 'react';
import { useCollection } from '@flowstack/sdk';
export function ContactForm() {
const [email, setEmail] = useState('');
const [msg, setMsg] = useState('');
const { insert } = useCollection('submissions', { layer: 'shared' });
return (
<form
onSubmit={async e => {
e.preventDefault();
await insert({ email, msg, submitted_at: new Date().toISOString() });
setEmail(''); setMsg('');
}}
>
<input value={email} onChange={e => setEmail(e.target.value)} placeholder="Email" />
<textarea value={msg} onChange={e => setMsg(e.target.value)} />
<button type="submit">Send</button>
</form>
);
}
WarningNever route form saves through useAgent — an LLM in the write path adds latency, cost, and nondeterminism for zero value.
WarninguseToolInvocation targets one agent tool by name (agentName + toolName) and blocks concurrent calls to the same tool.
WarningValidate in the component before insert; the collection is schemaless and will accept whatever you send.
See also
per-user-store · shared-pool · reason-write-read · useToolInvocation · useCollection
Source: sync-recipes.mjs ← https://sage-api.flowstack.fun/recipes.json · Also available in llms-full.txt and registry.json.