In the previous chapter, Antigravity Workflows, we learned how to give the AI a blueprint (a workflows.json file). This ensured the AI knew what to do.
However, there was still a bottleneck: You.
In a standard workflow, the AI does step 1, then stops and asks, "What next?" You have to click "Approve" or type "Continue" for every single step. If you want to build a complex app, you might have to approve 50 different actions.
What if the AI could click "Next" for itself?
Autonomous Orchestration (Loki Mode) removes the human from the loop.
Instead of an assistant that waits for orders, Loki Mode turns the AI into a Virtual CTO (Chief Technology Officer). You give it a high-level goal (like a Product Requirements Document), and it manages the entire project lifecycle—hiring sub-agents, writing code, running tests, and fixing bugs—while you sleep.
How does an AI run autonomously without hallucinating or destroying your codebase? It follows a strict recursive loop called RARV.
This is the "heartbeat" of Loki Mode.
Most AI scripts fail because they keep coding blindly. Loki Mode is different because of the Verify step. If the AI writes code that breaks the build, the Verify step catches it, and the AI enters a "Fix it" loop automatically.
Using Loki Mode is deceptively simple. You don't write code; you provide a Product Requirements Document (PRD).
Create a file named my-app-idea.md:
# Todo App PRD
Build a simple Todo App using React and Node.js.
- Users must be able to add tasks.
- Tasks should be saved to a SQLite database.
- Use Tailwind CSS for styling.
In your terminal, you invoke the autonomous runner.
# The magic command
./autonomy/run.sh ./my-app-idea.md
The system wakes up. It reads your file, creates a plan, and starts spawning agents. You will see logs like this:
[Orchestrator] Plan approved. Phase 1: Setup.
[Agent: Architect] Creating folder structure...
[Agent: Engineer] Installing React dependencies...
[Agent: QA] Running tests... Failed.
[Agent: Engineer] Fixing bug in package.json...
[Agent: QA] Tests passed. Moving to Phase 2.
How does a shell script manage a team of AI agents? Let's break down the architecture.
At its core, Loki Mode is a while loop that runs until the project is marked "Complete."
Since AI models have short memories, Loki Mode uses a special file called .loki/CONTINUITY.md.
Think of this as the Project Board. Every time an agent finishes a task, they must write a summary into this file. Before the next agent starts, they must read this file.
Example Content of CONTINUITY.md:
## Current Phase: Development
## Last Action
- Agent "Backend-Dev" created the database schema.
- Status: Success.
## Next Steps
1. Create the API Routes (Pending)
2. Connect Frontend to API (Pending)
## Mistakes & Learnings
- Do not use port 3000, it is occupied. Use 8080.
Let's look at the actual logic used in the autonomy/run.sh script (simplified for clarity).
The script calls the AI, feeds it the current context, and executes the tools the AI asks for.
#!/bin/bash
# Simplified pseudo-code of the runner
while [ "$PROJECT_STATUS" != "COMPLETE" ]; do
# 1. Build the prompt with history
PROMPT="Read CONTINUITY.md. What is the next step?"
# 2. Call the AI (Claude/GPT)
OUTPUT=$(call_ai_model "$PROMPT")
# 3. Execute the tool the AI requested
execute_tool "$OUTPUT"
# 4. Check for errors and loop again
update_continuity_file
done
Loki Mode is smart about who does the work. It doesn't use the expensive "Smartest Model" for everything.
Opus (High intelligence, slow).Sonnet (Balanced).Haiku (Fast, cheap).It dynamically selects the model based on the task complexity.
# Pseudo-code for agent dispatching
def dispatch_agent(task_type):
if task_type == "PLANNING":
return spawn_agent(model="claude-3-opus")
if task_type == "TESTING":
# We can run 5 testers in parallel!
return spawn_agent(model="claude-3-haiku")
This allows Loki Mode to be fast and cost-effective, running multiple "Haiku" agents in parallel to write tests while the "Opus" agent thinks about architecture.
The most important part of Loki Mode is the Verify step in the RARV cycle.
If you ask a standard AI to "write code," it outputs text and says "Done." Loki Mode does not trust the output.
server.js.node server.js.This recursive self-healing is what allows the system to run for hours without human intervention.
In this chapter, we unlocked the highest level of automation: Autonomous Orchestration.
We now have an AI that can think, plan, and execute. But as the project grows, a single CONTINUITY.md file isn't enough to remember everything. How does the AI remember the file structure of a massive project or the specific design decisions made three days ago?
In the next chapter, we will look at how the system uses the file system itself as a long-term memory.
👉 Next: File-Based Planning & Memory
Generated by Code IQ