Jules Agent API Integration
Delegate coding tasks to Jules, Google’s AI agent for code, directly from your LLM. Jules can create sessions, analyze repositories, propose plans, and automatically open pull requests.What It Does
The Jules Agent integration allows your LLM to:- Create coding sessions - Start tasks in GitHub repositories
- Monitor progress - Track Jules as it works
- Approve plans - Review and approve proposed changes
- Auto-create PRs - Jules opens pull requests automatically
- Send messages - Interact with active sessions
Key Feature: Body Payload Template
This integration showcases HandsAI’s bodyPayloadTemplate feature for complex nested JSON structures:{{param}} placeholders with actual parameter values.
Setup
1. Get Your Jules API Key
Sign in to Jules
Go to jules.google.com and sign in
Get API Key
Navigate to jules.google.com/settings and generate an API key
2. Import the Configuration
The Jules configuration is included inNUEVOS_HITOS.json:
Example Workflow
Step 1: List Available Sources
First, discover which repositories Jules can access: LLM tool call:Step 2: Create a Session
Start a new coding task with Jules: User request:“Ask Jules to add TypeScript support to the HandsAI project”LLM tool call:
Step 3: Monitor Progress
Check the session status: LLM tool call:Step 4: Approve Plan (if needed)
If Jules is waiting for approval: LLM tool call:Step 5: Jules Creates PR
WithautomationMode: "AUTO_CREATE_PR", Jules automatically:
- Creates a new branch
- Commits the changes
- Opens a pull request on GitHub
- Returns the PR URL
Automation Modes
AUTO_CREATE_PR
AUTO_CREATE_PR
Jules automatically creates a pull request when the task is complete. Best for trusted workflows.
Manual Mode
Manual Mode
Omit
automationMode to require manual approval at each step. Best for sensitive changes.Real-World Use Cases
Feature Development
“Add dark mode to the dashboard”
Bug Fixes
“Fix the memory leak in the worker process”
Refactoring
“Refactor authentication to use JWT”
Documentation
“Add JSDoc comments to all public functions”
Advanced: Session Management
List All Sessions
Interactive Refinement
Send follow-up messages to guide Jules:Body Payload Template Explained
ThebodyPayloadTemplate feature allows complex nested structures:
Template:
prompt: “Add TypeScript support”source: “sources/github/Vrivaans/HandsAI”startingBranch: “main”automationMode: “AUTO_CREATE_PR”
This is especially useful for APIs that require specific nested JSON structures that don’t map to flat parameter lists.
Security Considerations
Troubleshooting
Session stuck in ACTIVE state
Session stuck in ACTIVE state
Send a message to check progress or wait for Jules to complete the task. Sessions may take several minutes for complex changes.
Source not found
Source not found
Ensure the repository is connected to Jules at jules.google.com and use the exact source format:
sources/github/owner/repoPermission denied
Permission denied
Verify your API key has access to the repository and that Jules has the necessary GitHub permissions.
From the HandsAI README
Jules Agent API — Integration with Jules from Google to delegate code tasks to an autonomous AI agent that creates PRs automatically. Import the config from NUEVOS_HITOS.json (requires API Key from jules.google.com/settings).
Next Steps
Overview
Back to use cases overview
GitHub Integration
Manage repos with GitHub API
API Reference
Learn about import/export
Development
Extend HandsAI with new tools