Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Anthony Shaw
2026-02-11 13:33:29 -08:00
committed by GitHub
parent 3b4d601ba7
commit 84486c2e46
4 changed files with 19 additions and 10 deletions

View File

@@ -4,10 +4,14 @@ Build autonomous coding loops where an AI agent picks tasks, implements them, va
> **Runnable example:** [recipe/ralph_loop.py](recipe/ralph_loop.py)
>
> From the repository root, install dependencies and run:
>
> ```bash
> cd recipe && pip install -r requirements.txt
> python ralph_loop.py
> pip install -r cookbook/copilot-sdk/python/recipe/requirements.txt
> python cookbook/copilot-sdk/python/recipe/ralph_loop.py
> ```
>
> Make sure `PROMPT_build.md` and `PROMPT_plan.md` exist in your current working directory before running the loop.
## What is a Ralph Loop?

View File

@@ -55,11 +55,11 @@ async def ralph_loop(mode: str = "build", max_iterations: int = 50):
))
# Log tool usage for visibility
session.on(lambda event:
print(f"{event.data.tool_name}")
if event.type.value == "tool.execution_start" else None
)
def log_tool_event(event):
if event.type.value == "tool.execution_start":
print(f"{event.data.tool_name}")
session.on(log_tool_event)
try:
await session.send_and_wait(
MessageOptions(prompt=prompt), timeout=600