-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add RALPH-loop recipes to Copilot SDK cookbook #696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RALPH-loop recipes to Copilot SDK cookbook #696
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
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
|
@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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 9 comments.
Files not reviewed (1)
- cookbook/copilot-sdk/nodejs/recipe/package-lock.json: Language not supported
aaronpowell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a spelling error - either expand te as taskExecution (which I think it is) or add it to the ignore list
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.