Skip to main content
⚠️ DEPRECATED: The generateCode method is deprecated and will be removed in a future version. Please migrate to executeCommand for better flexibility and control.See migration guide below for how to update your code.

Method signature

Parameters

VibeKitStreamCallbacks Interface

Return value

CodexResponse (for Codex Agent)

ClaudeResponse (for Claude Agent)

Agent-specific behavior

Codex Agent

  • Streaming Support: Full streaming support with real-time updates
  • Sandbox Environment: Executes code in isolated E2B sandbox
  • Mode Support: Both “ask” and “code” modes fully supported

Claude Agent

  • Streaming Support: Limited - provides start/end notifications only
  • Execution: Direct API calls without sandbox environment
  • Mode Support: Both modes supported with fallback behavior

Examples

Basic Code Generation

With Streaming Callbacks

With Conversation History and Branch

Error handling

The method throws errors in the following cases:
  • Agent not initialized: When the configured agent type doesn’t match the initialized agent
  • Agent-specific errors:
    • Codex: Sandbox creation/execution failures, API errors
    • Claude: API authentication issues, rate limits
  • Configuration errors: Missing required API keys or invalid setup

Migration to executeCommand

The generateCode method has been deprecated in favor of the more flexible executeCommand method. Here’s how to migrate your code:

Basic Migration

Before (generateCode):
After (executeCommand):

With Branch Support

Before (generateCode):
After (executeCommand):

Event Handling Migration

Before (generateCode with callbacks):
After (executeCommand with events):

Agent-Specific Commands

For different agents, use these command patterns: Claude:
Codex:
Gemini:
OpenCode:
Grok:

Benefits of executeCommand

  • More Control: Direct access to agent CLI commands
  • Branch Support: Automatic git branch switching
  • Better Events: Use standard stdout/stderr events instead of custom callbacks
  • Flexibility: Execute any shell command in the sandbox environment
  • Consistency: Single method for all command execution needs

Notes

  • Required Mode: The mode parameter is now required and must be specified
  • Object Parameters: All parameters are now passed as a destructured object for better API consistency
  • Branch Support: The optional branch parameter allows for version control or environment context
  • Streaming Differences: Codex provides real-time streaming, while Claude only provides start/end notifications
  • Environment Support: Daytona environment is not yet supported and will throw an error
  • Conversation Context: History is preserved across calls to maintain conversation context