Add SDK features to all Ralph loop recipes

- Add WorkingDirectory/working_directory to pin sessions to project root
- Add OnPermissionRequest/on_permission_request for unattended operation
- Add tool execution event logging for visibility
- Add See Also cross-links to error-handling and persisting-sessions
- Add best practices for WorkingDirectory and permission auto-approval
- Consistent across all 4 languages (Node.js, Python, .NET, Go)
This commit is contained in:
Anthony Shaw
2026-02-11 11:56:11 -08:00
parent 92df16da5a
commit 1074e34682
9 changed files with 139 additions and 18 deletions

View File

@@ -39,9 +39,19 @@ async function ralphLoop(mode: Mode, maxIterations: number) {
for (let i = 1; i <= maxIterations; i++) {
console.log(`\n=== Iteration ${i}/${maxIterations} ===`);
// Fresh session — each task gets full context budget
const session = await client.createSession({
model: "claude-sonnet-4.5",
// Pin the agent to the project directory
workingDirectory: process.cwd(),
// Auto-approve tool calls for unattended operation
onPermissionRequest: async () => ({ allow: true }),
});
// Log tool usage for visibility
session.on((event) => {
if (event.type === "tool.execution_start") {
console.log(`${event.data.toolName}`);
}
});
try {