Repository navigation
refactor(agentcore): unify Run and Turn as Turn - #131
Merged
Merged
Conversation
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.
背景
当前 AgentCore 中的
Run和Turn实际上描述的是同一次逻辑执行。Run已经承担了一次完整 Agent Loop 的核心语义,包括输入接收、模型调用、工具执行、状态转移和最终结束;Turn主要负责关联 Preset、输入和 Run 身份,并通过消费 Run Facts 推导自身生命周期。由于当前设计已经确立一个 Turn 对应一个 Run,这两个领域概念被拆分后,
TurnStarted与RunCreated、InputDelivered与InputAccepted等事件需要跨模块协调,同时还要维护身份映射、状态投影和一致性关系。执行恢复、Session Fork 和上下文构建也因此需要同时理解两套模型,增加了领域边界和状态维护的复杂度。变更
Turn直接拥有一次完整逻辑执行的领域状态机和事件历史。Decide/Evolve、Step 和 Effect 执行模型,并将运行时、执行器、Session、Chatlog 及相关测试迁移到Turn。Run领域模块、API、事件和存储路径,不保留兼容层。这样,领域模型可以直接表达一次完整的 Agent 执行,Fork、恢复和上下文构建也围绕同一个逻辑身份展开。
验证
go test ./agentcore/...Related: TWI-18