Using SRE SDK to Build Agents
The SmythOS SDK is a toolkit for building agents programmatically on top of the Smyth Runtime Environment.
It offers a clean API for defining agents, adding skills, composing workflows, and connecting to core components.
When to use the SDK
Key Capabilities
Feature | Description |
---|---|
Agent API | Define, prompt, and manage agents in TypeScript |
Skills | Add custom functions and API calls |
Components | Compose modular workflows (LLMs, APIs, logic, data) |
Streaming | Real-time agent responses |
Storage/VectorDB | Built-in access to memory and storage layers |
State Handling | Save/load agent state and skills |
Getting Started
Install the SDK:
npm install @smythos/sdk
Create an agent:
import { Agent } from '@smythos/sdk';
const agent = new Agent({
name: 'Assistant',
model: 'gpt-4o',
behavior: 'You answer user questions.',
});
Add a skill:
agent.addSkill({
name: 'echo',
description: 'Repeat the user input.',
process: async ({ text }) => text,
});
Prompt the agent:
const result = await agent.prompt('Tell me about SmythOS.');
console.log(result);
See more complete examples in the SDK repo.
Building Blocks
Agents
Agents combine a model, behavior, and a set of skills.
const agent = new Agent({
name: 'DataBot',
model: 'gpt-4',
behavior: 'Summarizes and analyzes data.',
});
Skills
Define a skill to extend agent actions or expose tools to the LLM.
agent.addSkill({
name: 'summarize',
description: 'Summarizes text.',
ai_exposed: true,
process: async ({ input }) => summarizeText(input),
});
Directly call a skill:
const sum = await agent.call('summarize', { input: 'SmythOS is an agent runtime.' });
Components
Compose workflows from building blocks like LLMs, APIs, or logic tools.
import { GenAILLM, Classifier } from '@smythos/sdk';
const llm = GenAILLM({ model: 'gpt-4o' }, agent);
const classifier = Classifier({ classes: ['news', 'sports'] }, agent);
classifier.in({ Input: llm.out.Reply });
Prompting and Streaming
Get a response:
const output = await agent.prompt('How does vector search work?');
Stream agent output for real-time applications:
const stream = await agent.prompt('Stream me this.').stream();
stream.on('data', (chunk) => process.stdout.write(chunk));
Integration Patterns
- Save/load agent state or workflow definitions
- Use built-in connectors for LLMs, storage, or vector DBs
- Run locally for dev; deploy with custom configs in production
More Examples
Explore the SDK examples folder for advanced agent projects.
What’s Next
Combine with Studio