docs: Add comprehensive core loop architecture guide#12263
Closed
omer-bhutta wants to merge 1 commit into
Closed
Conversation
Detailed technical reference covering the multi-turn loop, processor, context assembly, tool system, permission model, compaction, and state management. Written at implementation-level detail for developer handoff. https://claude.ai/code/session_013Gf8B4tpe3d39cb6t9ELAf
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds a detailed architectural documentation file (
CORE_LOOP_ARCHITECTURE.md) that explains how OpenCode orchestrates multi-turn LLM interactions, manages tool execution, assembles context, and handles state transitions.The document is written at a level of detail sufficient for a developer to reimplement the core loop from scratch. It covers:
SessionPrompt.loop()orchestrator, concurrency guards, exit conditions, and step limitsstreamText()invocationThis documentation serves as a reference for understanding the codebase and will help new contributors and maintainers understand the system's design without having to reverse-engineer it from code.
How did you verify your code works?
This is documentation only. The content was derived from careful analysis of the actual source code in
packages/opencode/src/session/and related modules. The document references specific file locations, function names, and line numbers that can be cross-referenced with the actual implementation. The architectural descriptions, data structures, and flow diagrams accurately reflect the current codebase structure and behavior.https://claude.ai/code/session_013Gf8B4tpe3d39cb6t9ELAf