Skip to main content
Build a text analysis agent that accepts a topic and returns a structured analysis with a summary, key points, and a sentiment rating. It demonstrates:
  • The @agent decorator for metadata
  • Calling an LLM through ctx.llm.generate_object() for structured output
  • Returning structured data with ok()

Prerequisites

  • Friday Studio installed and running - daemon reachable at http://localhost:18080
  • Python 3.11+ and uv (for IDE support)
  • A text editor (VS Code recommended)

Step 1: Set up IDE support

You need the SDK installed locally for autocomplete and type checking. Create a Python environment and install the SDK:
Create .vscode/settings.json in your agent directory:
Reload VS Code after creating the file. Cmd+click on AgentContext in the next step should jump to the SDK definition.

Step 2: Create the agent file

Create a directory for your agent anywhere on your machine:
This agent accepts text input and returns structured analysis. It uses:
  • A @dataclass to define the output shape
  • ctx.llm.generate_object() to request structured JSON from an LLM
  • The host’s LLM provider - your code never handles API keys
Write ~/my-agents/text-analyzer/agent.py:

Step 3: Build and test

Register your agent with Friday:
The daemon validates the agent, copies source files, and hot-reloads the registry. No restart required. Verify the registration succeeded:
Test your agent with the CLI (requires Studio running at http://localhost:15200):
Or hit the daemon directly:
The response streams as SSE events. After a moment you see the result:
Try a different input:
Your agent classifies this as "sentiment": "negative".
Add --json for raw NDJSON output, useful for piping to jq:

Step 4: Iterate

Edit ~/my-agents/text-analyzer/agent.py, then re-register and test:
This cycle - edit, restart, test - is your development loop.
There’s a skill for that. The writing-friday-python-agents skill lets coding agents like Claude Code write and modify Friday agents directly - correct imports and proper capability calls.
Bump the version to keep old builds available for rollback:
Both versions are stored, but Friday resolves text-analyzer to the latest semver version (1.0.1).

Step 5: Register in a space (optional)

To use your agent within a Friday space (for planner routing, signals, and multi-agent orchestration), add it to your space’s workspace.yml:
workspace.yml
The type: user field tells Friday this is a custom Python agent. The id must match the id in the @agent decorator. This step is not required for direct execution.

Advanced topics

For CI/CD pipelines or automation, register agents via the daemon API on port 18080:
Error responses include the phase that failed (prereqs, validate, or write):
Agent not found after registering - Check that registration returned {"ok": true, ...}. Verify the agent ID matches what you pass to the execute command. Run friday agent list to see all registered agents.Build fails with syntax errors - The SDK uses pure Python dataclasses - no Pydantic. Ensure your type hints use standard library types only.Registration returns 400 - Your @agent decorator metadata failed validation. Required fields: id, version, description.ImportError on third-party packages - Ensure the package is installed in the agent’s Python environment. You can pip install additional pure-Python packages. Use ctx.http and ctx.llm for I/O that needs host audit logging and credential management.Credentials not working - Verify your .env file contains ANTHROPIC_API_KEY and re-register the agent: friday agent register /abs/path/to/agent.py.

Next steps

Call LLMs

Different models, structured output, and error handling.

Make HTTP requests

Fetch data from external APIs.

Use MCP tools

Invoke GitHub, databases, and other MCP servers.

How agents work

The subprocess model and host capabilities.