Skip to main content
Prerequisites: Basic understanding of AI agents and completed Deploy Your First Agent tutorial

Overview

RunAgent is built on several core concepts that work together to create a seamless multi-language AI agent deployment platform. Understanding these concepts will help you build more effective agents and troubleshoot issues.

Entrypoints

What are Entrypoints?

Entrypoints are Python functions that define how your agent can be invoked. They serve as the bridge between your agent’s logic and the universal API that RunAgent creates.

Entrypoint Characteristics

  • Function Signature: Defines the API contract for all languages
  • Parameters: Automatically become API parameters
  • Return Value: Becomes the response sent to clients
  • Documentation: Function docstrings become API documentation

Entrypoint Types

Synchronous Entrypoints

Return a single value immediately:

Streaming Entrypoints

Return an iterator for real-time responses:

Entrypoint Naming Convention

  • Synchronous: Use descriptive names like chat, analyze, process
  • Streaming: End with _stream suffix like chat_stream, analyze_stream

Tags

What are Tags?

Tags are identifiers that map entrypoint functions to API endpoints. They allow you to have multiple entrypoints in the same agent and call them by name.

Tag Best Practices

  • Use descriptive, lowercase names
  • Avoid special characters and spaces
  • Use underscores for multi-word tags
  • Keep tags consistent across environments

Agent Lifecycle

1. Initialization

When you run runagent serve .:
  1. Configuration Loading: Reads runagent.config.json
  2. Entrypoint Discovery: Imports and validates entrypoint functions
  3. Server Startup: Starts REST and WebSocket servers
  4. Health Check: Verifies all entrypoints are callable

2. Request Processing

When a client makes a request:
  1. Request Validation: Validates parameters against function signature
  2. Function Invocation: Calls the appropriate entrypoint function
  3. Response Processing: Handles return value or streaming
  4. Client Response: Sends response back to client

3. Shutdown

When you stop the agent:
  1. Graceful Shutdown: Finishes processing current requests
  2. Resource Cleanup: Closes connections and frees resources
  3. Server Stop: Shuts down REST and WebSocket servers

Multi-Language Translation

How Function Signatures Become APIs

RunAgent automatically translates Python function signatures into language-specific APIs:
Becomes:

Type Translation Rules

Streaming Architecture

How Streaming Works

  1. Client Request: Client calls streaming entrypoint
  2. WebSocket Connection: Establishes real-time connection
  3. Iterator Processing: Python generator yields chunks
  4. Real-time Transmission: Chunks sent immediately to client
  5. Native Iteration: Client receives chunks in language-appropriate way

Streaming Patterns

Python Generator

JavaScript Async Iterator

Rust Futures Stream

Configuration System

runagent.config.json Structure

Configuration Validation

RunAgent validates your configuration by:
  1. File Existence: Checking that specified files exist
  2. Module Import: Verifying modules can be imported
  3. Function Existence: Confirming functions exist in modules
  4. Signature Validation: Ensuring functions are callable
  5. Tag Uniqueness: Verifying tags are unique

Error Handling

Error Types

Client-Side Errors

  • AuthenticationError: Invalid or missing API key
  • AgentNotFoundError: Agent doesn’t exist
  • ValidationError: Invalid request parameters
  • RateLimitError: Too many requests
  • TimeoutError: Request timed out
  • NetworkError: Connection issues

Server-Side Errors

  • ImportError: Cannot import entrypoint module
  • FunctionError: Entrypoint function raised exception
  • ConfigurationError: Invalid configuration
  • ServerError: Internal server error

Error Propagation

Errors flow from Python functions through RunAgent to client SDKs:
Becomes:

Security Model

Sandboxing

RunAgent provides multiple layers of security:
  1. Process Isolation: Each agent runs in its own process
  2. Resource Limits: CPU and memory constraints
  3. Network Isolation: Controlled network access
  4. File System: Restricted file system access

API Security

  • Authentication: API key-based authentication
  • Authorization: Role-based access control
  • Rate Limiting: Request rate limiting
  • Input Validation: Parameter validation and sanitization

Performance Considerations

Scalability

RunAgent is designed to scale:
  1. Horizontal Scaling: Multiple agent instances
  2. Load Balancing: Automatic request distribution
  3. Auto-scaling: Dynamic instance management
  4. Caching: Response caching for performance

Optimization Tips

  1. Efficient Entrypoints: Keep functions focused and fast
  2. Streaming: Use streaming for long-running operations
  3. Caching: Cache expensive computations
  4. Resource Management: Monitor memory and CPU usage

Common Patterns

1. Simple Chat Agent

2. Data Processing Agent

3. Streaming Analysis Agent

Troubleshooting

Common Issues

  1. Import Errors: Check Python path and dependencies
  2. Function Not Found: Verify module and function names
  3. Type Errors: Ensure parameter types match
  4. Streaming Issues: Check iterator return type
  5. Configuration Errors: Validate JSON syntax

Debug Tips

  1. Enable Logging: Use verbose logging for debugging
  2. Test Locally: Test functions before deploying
  3. Check Dependencies: Ensure all imports are available
  4. Validate Configuration: Use configuration validation tools
  5. Monitor Performance: Track response times and resource usage

Next Steps

Architecture Overview

Learn about RunAgent’s system architecture

Production Considerations

Understand production deployment requirements

Security

Learn about RunAgent’s security model

Advanced Tasks

Explore advanced agent development patterns
🎉 Great work! You now understand the core concepts that make RunAgent work. These concepts form the foundation for building powerful, multi-language AI agents!

Still have a question?