-
Notifications
You must be signed in to change notification settings - Fork 4
Document recursive problem patterns for LLM workers #41
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
Conversation
Catalog 15 concrete problems that benefit from recursive LLM worker architectures, with sketched implementations using llm-do: 1. Document summarization (hierarchical map-reduce) 2. Task decomposition / planning 3. Code analysis and refactoring 4. Mathematical/logical proof 5. Research question exploration 6. Debate/adversarial analysis 7. Creative writing (hierarchical expansion) 8. Data pipeline construction 9. Test generation 10. Knowledge graph construction 11. Bug root cause analysis 12. Multi-level translation/localization 13. Game AI / decision trees 14. Explanation generation 15. Contract/legal analysis Also documents four implementation patterns: - Pattern A: Self-recursive worker (requires policy change) - Pattern B: Twin workers (works now) - Pattern C: Typed recursion (different workers per level) - Pattern D: Depth-controlled via explicit parameter Key insight: recursion works because messages are locals, not globals. Each call gets fresh context, preventing unbounded accumulation.
Summary of ChangesHello @zby, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces extensive documentation outlining how to effectively utilize recursive patterns within LLM worker architectures. It addresses the inherent context limitations of large language models by providing a structured approach to breaking down complex problems into manageable, recursive sub-tasks. The document serves as a foundational resource, detailing various problem domains where recursion is beneficial and offering practical implementation strategies, thereby enabling the development of more robust and scalable LLM-powered applications. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This is an excellent and very thorough document cataloging recursive patterns for LLM workers. It's well-structured and provides great examples. I've added a few comments to improve clarity and correctness in some of the examples and explanations. Specifically, I've pointed out a structural mismatch in one of the schemas, noted a few missing schema definitions that would improve clarity, and corrected a calculation regarding recursion depth.
|
|
||
| class CounterargumentAnalysis(BaseModel): | ||
| counterargument: str | ||
| rebuttals: list[str] |
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.
The rebuttals: list[str] field in CounterargumentAnalysis creates a structural mismatch with the recursive process. The recursive call to debate_analyzer returns a full ArgumentAnalysis object, and flattening this to a list of strings would lose valuable structured information.
To better represent the recursive analysis and preserve the structured output, consider replacing rebuttals with a field that can hold the nested ArgumentAnalysis object. I've suggested renaming it to analysis for clarity.
| rebuttals: list[str] | |
| analysis: "ArgumentAnalysis" |
| name: kg_builder | ||
| description: Build knowledge graphs from text recursively | ||
| model: anthropic:claude-haiku-4-5 | ||
| schema_out_ref: schemas.py:KnowledgeFragment |
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.
| name: game_ai | ||
| description: Explore game trees for optimal decisions | ||
| model: anthropic:claude-haiku-4-5 | ||
| schema_out_ref: schemas.py:GameAnalysis |
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.
|
|
||
| The default max_depth of 5 is usually sufficient because: | ||
|
|
||
| 1. **Exponential work**: Each level multiplies work. Depth 5 with branching factor 3 = 243 calls |
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.
The calculation for the number of calls appears to be ambiguous. For a tree of depth 5 with a branching factor of 3, the number of calls at the deepest level (the leaves) is 3^5 = 243. However, the total number of calls in the entire tree is 364. Please clarify whether you're referring to total calls or just leaf-node calls to ensure the documentation is precise.
| 1. **Exponential work**: Each level multiplies work. Depth 5 with branching factor 3 = 243 calls | |
| 1. **Exponential work**: Each level multiplies work. A tree of depth 5 with a branching factor of 3 has 243 leaf nodes, and a total of 364 calls. |
Catalog 15 concrete problems that benefit from recursive LLM worker
architectures, with sketched implementations using llm-do:
Also documents four implementation patterns:
Key insight: recursion works because messages are locals, not globals.
Each call gets fresh context, preventing unbounded accumulation.