Skip to content

fix(async-agent): improve save_checkpoint directory creation and handle null tasks in load_checkpoint - #487

Open
santhreal wants to merge 1 commit into
bojieli:mainfrom
santhreal:fix/async-agent-checkpoint-robustness
Open

fix(async-agent): improve save_checkpoint directory creation and handle null tasks in load_checkpoint#487
santhreal wants to merge 1 commit into
bojieli:mainfrom
santhreal:fix/async-agent-checkpoint-robustness

Conversation

@santhreal

Copy link
Copy Markdown
Contributor

In chapter4/async-agent/runtime.py, save_checkpoint raised FileNotFoundError when target parent directories did not exist, and load_checkpoint raised TypeError during log formatting when a checkpoint JSON had "tasks": null.

This fix automatically creates parent directories via os.makedirs and uses len(data.get('tasks') or []). Includes regression tests in chapter4/async-agent/test_checkpoint_robustness.py.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@santhreal, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 27e9089f-3c63-46c1-ad75-bce950a7e5d5

📥 Commits

Reviewing files that changed from the base of the PR and between ca666c1 and c88bc28.

📒 Files selected for processing (2)
  • chapter4/async-agent/runtime.py
  • chapter4/async-agent/test_checkpoint_robustness.py

Comment @coderabbitai help to get the list of available commands.

@bojieli bojieli left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null-tasks path is still broken before the guarded log line: load_checkpoint calls self.tasks.restore(data.get("tasks", [])), which passes None when the JSON contains "tasks": null. TaskManager.restore then iterates over None and raises TypeError. The included test uses MagicMock for runtime.tasks, so it masks this failure. Please normalize once (for example, tasks = data.get("tasks") or []), pass that value to restore and use it for the count, then exercise load_checkpoint with a real TaskManager in the regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants