Skip to content

Document nested withCycles behavior and recommended patterns#26

Merged
amavashev merged 1 commit intomainfrom
claude/analyze-spring-issue-29-vBIY9
Mar 23, 2026
Merged

Document nested withCycles behavior and recommended patterns#26
amavashev merged 1 commit intomainfrom
claude/analyze-spring-issue-29-vBIY9

Conversation

@amavashev
Copy link
Contributor

Summary

Added documentation to the README explaining the behavior and gotchas of nested withCycles calls, along with recommended patterns to avoid budget double-counting.

Changes

  • Added new "Nested withCycles Calls" section to README documenting:
    • That nested withCycles calls are allowed but create independent reservations
    • How this leads to double-counting of budget deductions
    • A concrete example showing the problem (600 total deducted instead of 500)
    • The recommended pattern: place withCycles only at the outermost entry point
    • An example of the recommended approach with plain async inner functions

Details

This documentation clarifies an important behavioral characteristic that users should be aware of when using withCycles in nested function calls. The guidance helps prevent unexpected budget exhaustion and encourages a cleaner architecture where cycle guards are applied at system boundaries rather than throughout the call stack.

https://claude.ai/code/session_012fx4F3BKF7QHZ5WMN1Jaua

Add section explaining that nested withCycles calls create independent
reservations that deduct budget separately. Recommend placing the guard
at the outermost entry point only.

Related to runcycles/cycles-spring-boot-starter#29

https://claude.ai/code/session_012fx4F3BKF7QHZ5WMN1Jaua
@amavashev amavashev merged commit 1e5d393 into main Mar 23, 2026
3 checks passed
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