useAllemAgent
Agent hook with status tracking, step history, and tool call awareness. Built on the Vercel AI SDK.
import { useAllemAgent } from "@allem-sdk/agents";Options
| Prop | Type | Default | Description |
|---|---|---|---|
| api | string | — | Override API endpoint from AllemAIProvider |
| model | string | — | Model identifier (e.g. "gemini-2.0-flash") |
| provider | "google" | "anthropic" | "openai" | — | Provider name |
| systemPrompt | string | — | System prompt sent with requests |
| headers | Record<string, string> | — | Extra headers merged with provider headers |
| experimental_throttle | number | — | Throttle wait in ms for updates |
Returns
All properties from UseChatHelpers, plus:
| Property | Type | Description |
|---|---|---|
| agentStatus | AgentStatus | "idle" | "thinking" | "calling-tool" | "done" |
| steps | AgentStep[] | Ordered list of steps taken in the current turn |
| currentToolCalls | AgentToolCall[] | Tool calls from the most recent step |
| isAgentRunning | boolean | Whether the agent is actively processing |
| messages | UIMessage[] | Array of chat messages |
| sendMessage | ({ text }): Promise | Send a message to the agent |
| status | "ready" | "submitted" | "streaming" | Underlying chat status |
| stop | () => void | Stop the agent |
Usage
import { AllemAIProvider } from "@allem-sdk/ai";
import { useAllemAgent } from "@allem-sdk/agents";
function App() {
return (
<AllemAIProvider api="/api/agent" provider="google">
<Agent />
</AllemAIProvider>
);
}
function Agent() {
const {
messages,
sendMessage,
agentStatus,
steps,
currentToolCalls,
isAgentRunning,
} = useAllemAgent();
return (
<div>
{agentStatus === "calling-tool" && (
<p>Using tool: {currentToolCalls[0]?.toolName}</p>
)}
{messages.map((m) => (
<div key={m.id}>
{m.parts?.filter((p) => p.type === "text").map((p) => p.text).join("")}
</div>
))}
<p>Steps taken: {steps.length}</p>
</div>
);
}