Add RALPH-loop recipes to Copilot SDK cookbook#696
Merged
aaronpowell merged 13 commits intogithub:mainfrom Feb 11, 2026
Merged
Conversation
Add iterative RALPH-loop (Read, Act, Log, Persist, Halt) pattern implementations for all four supported languages: - C#/.NET: ralph-loop.cs with documentation - Node.js/TypeScript: ralph-loop.ts with documentation - Python: ralph_loop.py with documentation (async API) - Go: ralph-loop.go with documentation Each recipe demonstrates: - Self-referential iteration where AI reviews its own output - Completion promise detection to halt the loop - Max iteration safety limits - File persistence between iterations Verified against real Copilot SDK APIs: - Python: fully verified end-to-end with github-copilot-sdk - Node.js: fully verified end-to-end with @github/copilot-sdk - C#: compiles and runs successfully with GitHub.Copilot.SDK - Go: compiles against github.com/github/copilot-sdk/go v0.1.23
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “RALPH-loop” (Read, Act, Log, Persist, Halt) recipe to the Copilot SDK cookbook, providing documentation and runnable examples across .NET, Node.js/TypeScript, Python, and Go.
Changes:
- Added new RALPH-loop runnable recipes for .NET, Node.js/TypeScript, Python, and Go.
- Added new RALPH-loop documentation pages for each language.
- Updated the cookbook index README to link the new recipe and updated the status text.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 23 comments.
Show a summary per file
| File | Description |
|---|---|
| cookbook/copilot-sdk/python/recipe/ralph_loop.py | Adds a Python runnable RALPH-loop implementation (async-based). |
| cookbook/copilot-sdk/python/ralph-loop.md | Adds Python documentation for the RALPH-loop recipe. |
| cookbook/copilot-sdk/nodejs/recipe/ralph-loop.ts | Adds a Node.js/TS runnable RALPH-loop implementation. |
| cookbook/copilot-sdk/nodejs/ralph-loop.md | Adds Node.js/TS documentation for the RALPH-loop recipe. |
| cookbook/copilot-sdk/go/recipe/ralph-loop.go | Adds a Go runnable RALPH-loop implementation (context-based API). |
| cookbook/copilot-sdk/go/ralph-loop.md | Adds Go documentation for the RALPH-loop recipe. |
| cookbook/copilot-sdk/dotnet/recipe/ralph-loop.cs | Adds a .NET runnable RALPH-loop implementation. |
| cookbook/copilot-sdk/dotnet/ralph-loop.md | Adds .NET documentation for the RALPH-loop recipe. |
| cookbook/copilot-sdk/README.md | Adds RALPH-loop links under each language and updates cookbook status text. |
Comments suppressed due to low confidence (1)
cookbook/copilot-sdk/dotnet/ralph-loop.md:72
- The doc snippet repeats the same pattern of calling
session.On(...)inside the loop. That will accumulate handlers across iterations and can causeTaskCompletionSource.SetResultto be invoked multiple times. Update the snippet to register the handler once (or unsubscribe per-iteration) and useTrySetResultto avoid exceptions from duplicate assistant message events.
var done = new TaskCompletionSource<string>();
session.On(evt =>
{
if (evt is AssistantMessageEvent msg)
{
_lastResponse = msg.Data.Content;
done.SetResult(msg.Data.Content);
}
});
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Removed mention of the RALPH-loop recipe from the README.
…l alignment - Move session.On handler outside loop to prevent handler accumulation (C#) - Use TrySetResult instead of SetResult to avoid duplicate-set exceptions (C#) - Wrap CreateSessionAsync in broader try/finally so client always stops (C#) - Fix PersistentRalphLoop to use maxIterations parameter instead of hardcoded 10 - Align model name to gpt-5.1-codex-mini across all doc snippets - Fix completion promise DONE -> COMPLETE in usage snippet - Replace Claude references with generic model terminology
Contributor
Author
|
@aaronpowell I Choo-choo-choose you to review my PR please. |
Align all 4 language recipes (Node.js, Python, .NET, Go) with the Ralph Playbook architecture: - Simple version: minimal outer loop with fresh session per iteration - Ideal version: planning/building modes, backpressure, git integration - Fresh context isolation instead of in-session context accumulation - Disk-based shared state via IMPLEMENTATION_PLAN.md - Example prompt templates (PROMPT_plan.md, PROMPT_build.md, AGENTS.md) - Updated cookbook README descriptions
Git operations (commit, push) belong in the prompt instructions, not hardcoded in the loop orchestrator. The SDK recipes should focus purely on the SDK API: create client, create session, send prompt, destroy.
- 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)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
aaronpowell
requested changes
Feb 11, 2026
Contributor
aaronpowell
left a comment
There was a problem hiding this comment.
There's a spelling error - either expand te as taskExecution (which I think it is) or add it to the ignore list
aaronpowell
approved these changes
Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new RALPH-loop recipe to the Copilot SDK cookbook with implementations in all four supported languages.
All examples use the
gpt-5.1-codex-minimodel.