A3S CodeExamples
Planning
Task decomposition with goal tracking
Planning
Planning mode decomposes a complex prompt into a structured execution plan before running. Each step is tracked independently, enabling goal-oriented multi-step tasks.
Planning adds one extra LLM call to generate the plan. Use it for complex multi-file tasks; skip it for simple queries.
Enable Planning
const session = agent.session('/my-project', {
permissive: true,
planning: true,
goalTracking: true,
});
const result = await session.send(
'Add input validation to all API endpoints, write tests, and update the README'
);
console.log(result.text);
console.log(`Tool calls: ${result.toolCallsCount}`);session = agent.session("/my-project",
permissive=True,
planning=True,
goal_tracking=True,
)
result = session.send(
"Add input validation to all API endpoints, write tests, and update the README"
)
print(result.text)
print(f"Tool calls: {result.tool_calls_count}")Streaming Planning Events
const stream = await session.stream('Refactor and test the auth module');
while (true) {
const { value, done } = await stream.next();
if (done || !value) break;
if (value.type === 'planning_start') {
console.log(`📋 Planning: ${value.prompt}`);
} else if (value.type === 'plan_ready') {
console.log(`Plan (${value.steps.length} steps):`);
value.steps.forEach((step, i) => console.log(` ${i + 1}. ${step}`));
} else if (value.type === 'end') {
break;
}
}for event in session.stream("Refactor and test the auth module"):
t = event.get("type")
if t == "planning_start":
print(f"📋 Planning: {event['prompt']}")
elif t == "plan_ready":
print(f"Plan ({len(event['steps'])} steps):")
for i, step in enumerate(event["steps"], 1):
print(f" {i}. {step}")
elif t == "end":
breakAPI Reference
SessionOptions
Prop
Type
Planning Events
Prop
Type