Skip to main content

Simple Agent Example

A minimal agent that greets users and performs text operations.

Code

from sypho_sdk import entrypoint, tool, AgentContext

@tool
async def reverse_text(text: str):
"""Reverse the given text string"""
return text[::-1]

@tool
async def count_words(text: str):
"""Count words in the given text"""
return {"word_count": len(text.split())}

@entrypoint
async def main(input: dict, context: AgentContext):
"""
You are a text processing assistant.

You can:
- Reverse text strings
- Count words in text

Always be helpful and respond concisely.
"""
pass # LLM handles execution in agent mode

Build and Deploy

# Initialize project
sypho init greeting-agent
cd greeting-agent

# Add code to src/agent.py (above)

# Build
sypho build --version 0.1.0

# Deploy
sypho deploy --version 0.1.0

Run

sypho run greeting-agent:0.1.0 \
--input '{"message": "Reverse this: Hello World"}'

Execution Flow

  1. User provides input: "Reverse this: Hello World"
  2. LLM analyzes request and available tools
  3. LLM calls reverse_text(text="Hello World")
  4. Tool returns: "dlroW olleH"
  5. LLM responds: "I reversed it: dlroW olleH"

Next Steps