Functions in Modus are stateless, request-response operations that handle
specific tasks with precision and speed. They get in, complete their objective,
and report back—no unnecessary complications, no lingering presence, just pure
operational efficiency.You can think of a function as an endpoint—each function you write automatically
becomes a callable API endpoint that external systems can access.Functions are the backbone of your app, handling everything from data gathering
to AI-powered analysis, all while maintaining clean, predictable behavior.
Functions are stateless, request-response operations designed for fast,
predictable execution. They’re your go-to choice when you need quick data
processing, external API integration, or computational tasks without maintaining
state between requests.
When you deploy your functions, Modus automatically exposes them through a
GraphQL API. Your functions become either queries (for data retrieval) or
mutations (for data modifications) based on their operation type.
Most functions become GraphQL queries—perfect for fetching and processing data:
Copy
Ask AI
// This function becomes a GraphQL queryfunc GatherThreatIntelligence(source string) (*ThreatReport, error) { // Data gathering and processing operation return fetchThreatData(source)}
Functions are perfect for most computational tasks, but when you need persistent
state, complex multi-step workflows, or processes that remember details across
multiple interactions, it’s time to consider agents.Consider upgrading to agents when your use case requires:
Persistent memory across multiple requests
Conversation context that builds over time
Multi-step workflows spanning extended periods
Recovery from failures with state preservation
Continuous monitoring with context retention
Your functions form the API backbone of your app—fast, reliable, and always
ready for the next request. They handle the immediate computational needs while
your agents manage the long-term stateful processes.