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
- User provides input:
"Reverse this: Hello World" - LLM analyzes request and available tools
- LLM calls
reverse_text(text="Hello World") - Tool returns:
"dlroW olleH" - LLM responds: "I reversed it: dlroW olleH"