|
| 1 | +--- |
| 2 | +title: "Ejecting to code: Modus" |
| 3 | +description: |
| 4 | + "Export your Threads conversations as production-ready Modus applications with |
| 5 | + full control and transparency" |
| 6 | +--- |
| 7 | + |
| 8 | +Hypermode's **"eject to code"** feature lets you take visually or |
| 9 | +conversationally built agents and export them as production-grade, audit-able |
| 10 | +source code. This means you can iterate rapidly using Hypermode's agent-building |
| 11 | +tools—and when you're ready, seamlessly turn the agent into real code that can |
| 12 | +be reviewed, modified, versioned, and run anywhere your team needs. |
| 13 | + |
| 14 | +**Hypermode doesn't not trap your logic in a black box.** you can always eject |
| 15 | +to code for transparency, extensibility, and control—making the platform safe |
| 16 | +and useful for both business users and engineers. |
| 17 | + |
| 18 | +## From conversation to audit-able code |
| 19 | + |
| 20 | +Remember your Code Review Agent that analyzes pull requests and creates Linear |
| 21 | +tickets? Here's what that Threads conversation becomes when exported as a Modus |
| 22 | +app. |
| 23 | + |
| 24 | +Exported agents are powered by the **Modus framework**. Once ejected, they |
| 25 | +become standard microservices or API endpoints, deployable on your |
| 26 | +infrastructure—just like any other well-structured software component. You can |
| 27 | +version-control the generated code, customize the logic, and wrap it within your |
| 28 | +organization's CI/CD, observability, and security practices. |
| 29 | + |
| 30 | +This export-to-code model **bridges the gap between no/low-code agent creation |
| 31 | +and production software engineering**. It gives non-technical users the power of |
| 32 | +rapid prototyping, while developers retain full trust and control for real-world |
| 33 | +deployments. |
| 34 | + |
| 35 | +### Your agent becomes structured code |
| 36 | + |
| 37 | +```go |
| 38 | +package main |
| 39 | + |
| 40 | +import ( |
| 41 | + "fmt" |
| 42 | + "strings" |
| 43 | + "time" |
| 44 | + "github.com/hypermodeinc/modus/sdk/go/pkg/agents" |
| 45 | + "github.com/hypermodeinc/modus/sdk/go/pkg/models" |
| 46 | + "github.com/hypermodeinc/modus/sdk/go/pkg/models/openai" |
| 47 | +) |
| 48 | + |
| 49 | +type CodeReviewAgent struct { |
| 50 | + agents.AgentBase |
| 51 | + |
| 52 | + // Persistent memory - remembers your training from Threads |
| 53 | + ReviewHistory []CodeReview `json:"review_history"` |
| 54 | + TeamPreferences TeamSettings `json:"team_preferences"` |
| 55 | + SecurityRules []SecurityCheck `json:"security_rules"` |
| 56 | + NamingConventions []NamingRule `json:"naming_conventions"` |
| 57 | + LastActivity time.Time `json:"last_activity"` |
| 58 | +} |
| 59 | + |
| 60 | +type TeamSettings struct { |
| 61 | + SecurityPriority string `json:"security_priority"` // "High" |
| 62 | + QualityPriority string `json:"quality_priority"` // "Medium" |
| 63 | + RequiredTags []string `json:"required_tags"` // ["code-review-bot"] |
| 64 | + NotificationChannel string `json:"notification_channel"` |
| 65 | +} |
| 66 | + |
| 67 | +func (a *CodeReviewAgent) Name() string { |
| 68 | + return "CodeReviewAgent" |
| 69 | +} |
| 70 | +``` |
| 71 | + |
| 72 | +### Your training becomes system prompts |
| 73 | + |
| 74 | +```go |
| 75 | +func (a *CodeReviewAgent) buildSystemPrompt() string { |
| 76 | + return fmt.Sprintf(`You are a code review agent trained through conversation. |
| 77 | +
|
| 78 | +Your team preferences: |
| 79 | +- Security issues: %s priority |
| 80 | +- Code quality issues: %s priority |
| 81 | +- Always tag tickets with: %v |
| 82 | +- Focus on variable naming conventions (avoid 'data1', 'temp_thing') |
| 83 | +
|
| 84 | +Based on %d previous reviews, you've learned to: |
| 85 | +- Identify SQL injection vulnerabilities |
| 86 | +- Suggest parameterized queries for database access |
| 87 | +- Recommend descriptive variable names |
| 88 | +- Create Linear tickets automatically for issues found |
| 89 | +
|
| 90 | +Maintain the conversational tone and detailed feedback style established in training.`, |
| 91 | + a.TeamPreferences.SecurityPriority, |
| 92 | + a.TeamPreferences.QualityPriority, |
| 93 | + a.TeamPreferences.RequiredTags, |
| 94 | + len(a.ReviewHistory)) |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | +### Your tool integrations become functions |
| 99 | + |
| 100 | +```go |
| 101 | +func (a *CodeReviewAgent) analyzePullRequest(prData string) (*string, error) { |
| 102 | + // AI analysis with your trained context |
| 103 | + model, err := models.GetModel[openai.ChatModel]("gpt-4") |
| 104 | + if err != nil { |
| 105 | + return nil, err |
| 106 | + } |
| 107 | + |
| 108 | + systemPrompt := a.buildSystemPrompt() |
| 109 | + |
| 110 | + input, err := model.CreateInput( |
| 111 | + openai.NewSystemMessage(systemPrompt), |
| 112 | + openai.NewUserMessage(fmt.Sprintf("Review this pull request:\n%s", prData)), |
| 113 | + ) |
| 114 | + if err != nil { |
| 115 | + return nil, err |
| 116 | + } |
| 117 | + |
| 118 | + output, err := model.Invoke(input) |
| 119 | + if err != nil { |
| 120 | + return nil, err |
| 121 | + } |
| 122 | + |
| 123 | + analysis := output.Choices[0].Message.Content |
| 124 | + |
| 125 | + // Tool integrations you configured in Connections |
| 126 | + issues := a.extractIssues(analysis) |
| 127 | + var ticketsCreated []string |
| 128 | + |
| 129 | + for _, issue := range issues { |
| 130 | + if strings.Contains(strings.ToLower(issue.Type), "security") { |
| 131 | + ticket, err := a.createLinearTicket(issue, "High", a.TeamPreferences.RequiredTags) |
| 132 | + if err == nil { |
| 133 | + ticketsCreated = append(ticketsCreated, ticket) |
| 134 | + } |
| 135 | + } else { |
| 136 | + ticket, err := a.createLinearTicket(issue, "Medium", a.TeamPreferences.RequiredTags) |
| 137 | + if err == nil { |
| 138 | + ticketsCreated = append(ticketsCreated, ticket) |
| 139 | + } |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + // State persists across sessions automatically |
| 144 | + a.ReviewHistory = append(a.ReviewHistory, CodeReview{ |
| 145 | + PullRequest: prData, |
| 146 | + Analysis: analysis, |
| 147 | + Issues: issues, |
| 148 | + Tickets: ticketsCreated, |
| 149 | + Timestamp: time.Now(), |
| 150 | + }) |
| 151 | + a.LastActivity = time.Now() |
| 152 | + |
| 153 | + result := fmt.Sprintf("%s\n\nCreated tickets: %v", analysis, ticketsCreated) |
| 154 | + return &result, nil |
| 155 | +} |
| 156 | +``` |
| 157 | + |
| 158 | +### GraphQL API generated automatically |
| 159 | + |
| 160 | +```go |
| 161 | +// Your Threads conversation becomes this API endpoint |
| 162 | +func ReviewPullRequest(agentId string, prData string) (string, error) { |
| 163 | + result, err := agents.SendMessage( |
| 164 | + agentId, |
| 165 | + "analyze_pull_request", |
| 166 | + agents.WithData(prData), |
| 167 | + ) |
| 168 | + if err != nil { |
| 169 | + return "", err |
| 170 | + } |
| 171 | + if result == nil { |
| 172 | + return "", fmt.Errorf("no response from agent") |
| 173 | + } |
| 174 | + return *result, nil |
| 175 | +} |
| 176 | +``` |
| 177 | + |
| 178 | +## What you get with ejected code |
| 179 | + |
| 180 | +### Complete Modus app |
| 181 | + |
| 182 | +Your exported agent runs on **Modus**, Hypermode's open source agent runtime: |
| 183 | + |
| 184 | +```bash |
| 185 | +# Your agent becomes a standard Modus app |
| 186 | +git clone your-exported-agent |
| 187 | +cd code-review-agent |
| 188 | +modus dev # Local development |
| 189 | +modus deploy # Production deployment |
| 190 | +``` |
| 191 | + |
| 192 | +### Standard microservices and APIs |
| 193 | + |
| 194 | +The exported code isn't a prototype—it's enterprise-grade software that becomes: |
| 195 | + |
| 196 | +- **Standard microservices** deployable on your infrastructure |
| 197 | +- **API endpoints** that integrate with existing systems |
| 198 | +- **Version-controlled code** you can customize and extend |
| 199 | +- **Audit-able logic** that developers can review and trust |
| 200 | + |
| 201 | +Technical features include: |
| 202 | + |
| 203 | +- **Persistent Memory**: Agent state survives restarts and failures |
| 204 | +- **Concurrent Execution**: Handle thousands of simultaneous operations |
| 205 | +- **Sand-boxed Security**: Each agent instance runs in isolation |
| 206 | +- **Built-in Observability**: Logging, tracing, and debugging out of the box |
| 207 | +- **WebAssembly Runtime**: Fast, portable execution anywhere—server, edge, or |
| 208 | + desktop |
| 209 | + |
| 210 | +### Developer-friendly handoff |
| 211 | + |
| 212 | +Platform teams get real software they can audit and extend: |
| 213 | + |
| 214 | +- **Full Code Transparency**: Every behavior from Threads is visible in code |
| 215 | +- **Standard DevOps**: CI/CD, testing, monitoring work normally |
| 216 | +- **No Vendor Lock-in**: Runs anywhere Modus runs |
| 217 | +- **Version Control**: Treat agents like any other microservice |
| 218 | + |
| 219 | +## The power of Modus |
| 220 | + |
| 221 | +Your ejected agent is built on Modus, an open source, serverless framework |
| 222 | +designed specifically for agent development: |
| 223 | + |
| 224 | +### Key features |
| 225 | + |
| 226 | +- **WebAssembly powered runtime**: Small, portable, high-performance execution |
| 227 | + engine |
| 228 | +- **Built-in agent memory**: Both short-term and long-term memory with graph |
| 229 | + data structures |
| 230 | +- **Flexible tool support**: Consume Model Context Protocol (MCP) servers or |
| 231 | + build custom tools |
| 232 | +- **Serverless scale-to-zero**: Agents spin up on demand and scale to zero when |
| 233 | + idle |
| 234 | +- **Language-agnostic**: Write in Go, Rust, AssemblyScript, or your language of |
| 235 | + choice |
| 236 | +- **Full observability**: Action-level tracing and inference logging for |
| 237 | + debugging |
| 238 | + |
| 239 | +### When to eject to code |
| 240 | + |
| 241 | +Common use cases for ejecting include: |
| 242 | + |
| 243 | +- **Auditing agent logic** before putting it into production |
| 244 | +- **Integrating agent code** into a larger system or microservices architecture |
| 245 | +- **Modifying, extending, or customizing** generated code to meet advanced |
| 246 | + requirements |
| 247 | +- **Ensuring reproducibility** and version tracking via GitHub or other source |
| 248 | + control tools |
| 249 | +- **Custom integrations** beyond available Connections |
| 250 | +- **Complex multi-agent coordination** with custom orchestration logic |
| 251 | +- **Integration with existing systems** that require specific deployment |
| 252 | + patterns |
| 253 | +- **Full development lifecycle control** including testing, staging, and |
| 254 | + production environments |
| 255 | +- **Team ownership** where developers need to maintain and extend agent logic |
| 256 | + |
| 257 | +## Learn more about Modus |
| 258 | + |
| 259 | +Ready to dive deeper into agent development with Modus? The ejected code is just |
| 260 | +the beginning. |
| 261 | + |
| 262 | +**[Explore the complete Modus documentation →](/modus)** |
| 263 | + |
| 264 | +Learn about: |
| 265 | + |
| 266 | +- Building agents from scratch with the Modus framework |
| 267 | +- Advanced memory management and persistence patterns |
| 268 | +- Custom tool development and Model Context Protocol integration |
| 269 | +- Multi-agent coordination and workflow orchestration |
| 270 | +- Production deployment and scaling strategies |
| 271 | + |
| 272 | +## Your agent works perfectly in Threads |
| 273 | + |
| 274 | +For many use cases, keeping your agent hosted automatically in Threads is |
| 275 | +ideal—the Hypermode platform handles deployment, scaling, and maintenance for |
| 276 | +you. |
| 277 | + |
| 278 | +**Ready for more control?** When you need to hand off to engineers, integrate |
| 279 | +with existing systems, or build coordinated multi-agent workflows, ejecting to |
| 280 | +code gives you a complete Modus app that your development team can own, extend, |
| 281 | +and deploy anywhere. |
| 282 | + |
| 283 | +--- |
| 284 | + |
| 285 | +_Your Threads conversation was just the design phase. With Modus, you can build |
| 286 | +agents that become as reliable and scalable as any microservice in your |
| 287 | +infrastructure._ |
0 commit comments