Skip to main content

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

Use the SDK for version-controlled agent projects, advanced logic, backend integration, or automated workflows. Ideal for CI/CD and testing pipelines.

Key Capabilities

FeatureDescription
Agent APIDefine, prompt, and manage agents in TypeScript
SkillsAdd custom functions and API calls
ComponentsCompose modular workflows (LLMs, APIs, logic, data)
StreamingReal-time agent responses
Storage/VectorDBBuilt-in access to memory and storage layers
State HandlingSave/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

You can import SDK-built agents into Agent Studio for visualization and collaboration.