Agent engine
How the XibeCode agent loop works — iterations, modes, tools, completion, and learning.
Agent engine
XibeCode’s core (xibecode-core) runs an autonomous coding agent: model calls → tool use → file/shell changes → verify → continue until the task is done or you stop it.
Surfaces
| Surface | Command | Notes |
|---|---|---|
| One-shot task | xibecode run "…" | Non-interactive autonomous run |
| Task + PR | xibecode run-pr "…" | Branch + GitHub PR after work |
| Interactive chat | xibecode chat / xc | TUI with slash commands |
| Messaging | xibecode gateway | Telegram / Discord / Slack coding sessions |
| Scheduled | xibecode cron + gateway | Periodic agent jobs |
| IDE / ACP | VS Code extension, ACP stdio | Same engine, different hosts |
Agent loop
- Build context (project files, memory, skills, session history).
- Call the LLM with tools (read/write/edit, shell, search, MCP, etc.).
- Execute tool calls safely under permission rules.
- Feed results back; repeat until:
- the model finishes with a final answer, or
- you abort (Ctrl+C, chat cancel, gateway
/stop), or - a finite iteration cap is hit.
Max iterations (unlimited by default)
| Value | Behavior |
|---|---|
0 (default) | Unlimited — loop until completion or abort |
| Positive integer | Hard stop after N model turns |
# Unlimited (default)
xibecode run "refactor auth module"
# Cap at 100 turns
xibecode run "…" -d 100
# Profile default
xibecode config # or setup agent → Max agent iterations = 0Economy cost mode still applies a separate lower cap (economyMaxIterations) so cheap runs stay bounded.
Anti-runaway: repeated identical tool calls are blocked by the loop detector; you can always interrupt.
Modes
Modes control tool categories and behavior (agent, plan, review, debugger, …). See Modes. Plan and review modes still allow shell where needed for verification.
Tools
File ops, shell, search, web fetch, memory, skills, swarm, MCP tools, and more. See Tools.
Learning & memory
After turns, optional learning loop features:
- Curated
MEMORY.md/USER.md - Post-turn review (optional cheap model)
- Write-approval for sensitive memory/skill writes
- Session search across past work
- Skill learner for reusable procedures
See Memory.
Providers & models
Any catalog entry from Providers. Failover pools improve reliability under rate limits.
Cloud execution
Optional E2B sandbox runtime: shell in the cloud while files stay on host (host_only) or full workspace sync (sandbox_full). See Cloud / E2B.
Best practices
- Run
xibecode setuponce, thenxibecode chatfor interactive work. - Prefer unlimited iterations for large refactors; use
-d Nonly when you want a hard budget. - Use economy mode for cheap drafts; normal mode for production changes.
- For always-on coding from phone/Telegram, install the gateway and use
/stopif a run goes wrong.