Skip to content

修复 workflow llm_call ToolContext 传播#1664

Merged
jason-aelf merged 1 commit into
auto-work-devfrom
refactor/issue-1652-toolcontext
Jun 2, 2026
Merged

修复 workflow llm_call ToolContext 传播#1664
jason-aelf merged 1 commit into
auto-work-devfrom
refactor/issue-1652-toolcontext

Conversation

@jason-aelf
Copy link
Copy Markdown
Collaborator

摘要

修复 #1652workflow llm_call 子请求现在从 workflow runtime ToolContext 单一事实源派生上下文。

  • 删除有损的 WorkflowLlmRuntimeOverrides / LlmOverrides runtime mirror。
  • LLMCallModule 从 runtime ToolContext 派生 child LlmControl 七个窄字段。
  • child ToolContext 只在存在 caller/channel/sender binding/connected services/external metadata/skill recovery 等非控制面工具执行语义时写入;LlmControl-only 场景不写 child ToolContext
  • 补充 runtime、adapter、full ToolContext、control-only 回归测试。

Scope / 范围

6 files changed, 208 insertions, 97 deletions.

  • src/workflow/Aevatar.Workflow.Core/Execution/WorkflowExecutionRuntimeContext.cs
  • src/workflow/Aevatar.Workflow.Core/Modules/LLMCallModule.cs
  • test/Aevatar.Integration.Tests/WorkflowAdditionalModulesCoverageTests.cs
  • test/Aevatar.Integration.Tests/WorkflowGAgentCoverageTests.cs
  • test/Aevatar.Workflow.Core.Tests/Execution/WorkflowExecutionContextAdapterTests.cs
  • test/Aevatar.Workflow.Core.Tests/Execution/WorkflowExecutionRuntimeContextTests.cs

验证

  • dotnet build aevatar.slnx --nologo — passed
  • dotnet test test/Aevatar.Workflow.Core.Tests/Aevatar.Workflow.Core.Tests.csproj --filter "FullyQualifiedName~WorkflowExecutionRuntimeContext|FullyQualifiedName~WorkflowExecutionContextAdapter|FullyQualifiedName~LLMCallModule" --nologo — passed, 24 tests
  • dotnet test test/Aevatar.Integration.Tests/Aevatar.Integration.Tests.csproj --filter "FullyQualifiedName~LlmCallModule_ShouldForwardTypedRuntimeContextOverrides|FullyQualifiedName~WorkflowRunGAgent" --nologo — passed, 36 tests
  • dotnet test test/Aevatar.Integration.Tests/Aevatar.Integration.Tests.csproj --filter "FullyQualifiedName~LlmCallModule_ShouldForwardControlOnlyRuntimeContextWithoutChildToolContext" --nologo — passed, 1 test
  • bash tools/ci/test_stability_guards.sh — passed
  • bash tools/ci/architecture_guards.sh — passed

Consensus-rnd

🤖 Auto-loop / codex-refactor-loop issue-1652

⟦AI:AUTO-LOOP⟧

Remove the lossy runtime LLM override mirror so llm_call derives its child request from the workflow ToolContext single source of truth.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jason-aelf jason-aelf added crnd:lifecycle:managed Item is managed by codex-refactor-loop. auto-loop-reviewing Phase 8 reviewer codex round in flight crnd:human:auto Controller may continue without maintainer intervention. labels Jun 2, 2026
@jason-aelf
Copy link
Copy Markdown
Collaborator Author

jason-aelf commented Jun 2, 2026

🤖 PR #1664 测试覆盖 Review: approve

TL;DR


详细说明

LLMCallModule 是 workflow 的 llm_call 分发模块;本次关键风险是 runtime AgentToolExecutionContext 是否正确拆成 ChatRequestEvent.LlmControl 和 child ToolContext。我打开了实际测试文件确认,LlmCallModule_ShouldForwardTypedRuntimeContextOverrides 断言了 7 个 LlmControl 字段,并验证 RequestCallerChannel、sender binding、connected services、external metadata、skill recovery 都会进入 child ToolContextLlmCallModule_ShouldForwardControlOnlyRuntimeContextWithoutChildToolContext 覆盖 control-only 场景,确保只发 LlmControl 而不附带 child ToolContext

稳定性和测试质量方面,触达测试 diff 没有新增 [Skip][Trait("Category","Manual")]Task.Delay(...)WaitUntilAsync(...)Assert.True(true) 或 only-not-throw 类测试;tools/ci/test_polling_allowlist.txt 未变化。删除的旧断言对应已移除的 LlmOverrides 表面,已由新 runtime fact 和 dispatch payload 断言替代。


📎 完整 codex 原始输出(存档备查)
---
pr: 1664
role: tests
verdict: approve
---

## Verdict
Approve: the changed workflow ToolContext propagation behavior has focused tests with concrete payload assertions, and the diff does not add polling waits, skips, manual traits, or weakened assertions.

## Evidence
- `test/Aevatar.Integration.Tests/WorkflowAdditionalModulesCoverageTests.cs:2001` (`LlmCallModule_ShouldForwardTypedRuntimeContextOverrides`) exercises the new `LLMCallModule` dispatch path from runtime `AgentToolExecutionContext` to `ChatRequestEvent`, asserting all seven `LlmControl` fields plus child `ToolContext` sections (`Request`, `Caller`, `Channel`, sender binding, connected services, external metadata, and skill recovery) and verifying request metadata remains a single passthrough entry.
- `test/Aevatar.Integration.Tests/WorkflowAdditionalModulesCoverageTests.cs:2095` (`LlmCallModule_ShouldForwardControlOnlyRuntimeContextWithoutChildToolContext`) covers the control-only branch: control fields are promoted into `chatRequest.LlmControl`, while `chatRequest.ToolContext` remains null.
- `test/Aevatar.Workflow.Core.Tests/Execution/WorkflowExecutionRuntimeContextTests.cs:48` (`SetToolContext_ShouldStoreToolContextAsOnlyRuntimeFact`) and `:144` (`SetRequestMetadata_ShouldNotMutateExistingToolContext`) cover the runtime-context contract change: `ToolContext` is the stored fact, `LlmOverrides` is absent, and request metadata updates do not erase an existing tool context.
- `test/Aevatar.Workflow.Core.Tests/Execution/WorkflowExecutionContextAdapterTests.cs:31` keeps adapter coverage for exposing the same runtime context and verifies the new `ToolContext` value through the adapter.
- Static diff scan over touched tests found no added `[Skip]`, `[Trait("Category","Manual")]`, `Task.Delay(...)`, `WaitUntilAsync(...)`, `Assert.True(true)`, or not-throw-only tests; `tools/ci/test_polling_allowlist.txt` is unchanged.

⟦AI:AUTO-LOOP⟧
REVIEW_DONE:1664:tests:approve

⟦AI:AUTO-LOOP⟧

@jason-aelf
Copy link
Copy Markdown
Collaborator Author

jason-aelf commented Jun 2, 2026

🤖 Architect review approve: ToolContext 单一事实源合规

TL;DR

  • 这是什么: PR 修复 workflow llm_call ToolContext 传播 #1664 的架构合规 review。
  • 结论: architect 角度 approve,未发现新增 CLAUDE.md / AGENTS.md 架构违规。
  • 下一步: controller 可按共识规则继续合并判定,测试质量由 tests reviewer 单独覆盖。

详细说明

本次只看 PR #1664 / issue #1652WorkflowExecutionRuntimeContext 现在只保留单一 ToolContext 运行态事实源,并删除 WorkflowLlmRuntimeOverrides 镜像,符合“事实源唯一”和“删除优先”的规则。

LLMCallModule 从 typed AgentToolExecutionContext 派生 child ChatRequestEvent.LlmControl,并且只有存在 request identity、caller、channel、sender binding、connected services、external metadata、skill recovery 等非控制面语义时才写 child ToolContext。这保持了控制语义强类型化,也避免把工具执行上下文降级回通用 metadata bag。


📎 完整 codex 原始输出(存档备查)

pr: 1664
role: architect
verdict: approve

Verdict

approve - no architectural compliance concerns found for PR #1664 / issue #1652.

Evidence

  • Scope honesty: changed files are limited to src/workflow/Aevatar.Workflow.Core/Execution/WorkflowExecutionRuntimeContext.cs, src/workflow/Aevatar.Workflow.Core/Modules/LLMCallModule.cs, and the corresponding workflow/core/integration tests declared by .refactor-loop/runs/implement-issue-1652.md; no SCOPE_EXTEND was needed.
  • Single runtime fact: src/workflow/Aevatar.Workflow.Core/Execution/WorkflowExecutionRuntimeContext.cs:24-30 keeps Connector, RequestPassthroughMetadata, CapturedSecureInputs, and the single ToolContext runtime fact, while the PR deletes the WorkflowLlmRuntimeOverrides mirror. This aligns with CLAUDE.md clause 事实源唯一:跨请求/跨节点一致性事实必须有唯一权威来源(Actor 持久态或分布式状态),不依赖进程内偶然状态。 and AGENTS.md clause 不保留无效层:空转发、重复抽象、无业务价值代码直接删除。
  • Strong typed semantics: src/workflow/Aevatar.Workflow.Core/Modules/LLMCallModule.cs:336-360 derives child ChatRequestEvent.LlmControl from typed AgentToolExecutionContext credential/routing fields, not from a metadata bag. This aligns with CLAUDE.md clause 核心语义强类型:影响业务语义、控制流、稳定读取且仓库内可控的数据,必须建模为 proto field / typed option / typed sub-message,禁止塞入通用 bag。
  • Boundary split preserved: src/workflow/Aevatar.Workflow.Core/Modules/LLMCallModule.cs:371-402 emits child ToolContext only when non-control tool execution semantics are present, while control-only values stay in LlmControl; this avoids mixing typed control semantics with pass-through metadata and aligns with AGENTS.md clause 数据语义分层:传输元数据用于追踪与上下文;业务语义以领域事件与读模型为准,不混用语义层次。
  • Deletion-first: WorkflowLlmRuntimeOverrides and BuildLlmControlToolContext are removed rather than kept as compatibility shims; no empty-forwarding interface, dead wrapper, parallel pathway, new *WriteActor / *ReadActor / *Store, new schema/protocol file, or external repository reference is introduced.
  • Old/New comment policy: ${HOST_REFACTOR_COMMENT_POLICY:-none} is unset/empty in this environment, so it normalizes to none; the PR diff adds no new Old/New/iteration refactor-history source comments.
  • Host production SSOT boundary: the PR diff changes no .refactor-loop/, .refactor-loop/host.env, host tool config, branch topology, machine paths, durable ledger authority, or host artifacts.
  • Regression intent is covered by changed tests: test/Aevatar.Integration.Tests/WorkflowAdditionalModulesCoverageTests.cs:2062-2091 verifies full typed runtime context propagation, and test/Aevatar.Integration.Tests/WorkflowAdditionalModulesCoverageTests.cs:2122-2130 verifies control-only context forwards LlmControl while leaving child ToolContext absent. Test quality is out of scope for this role; this note only supports the architecture mapping.

⟦AI:AUTO-LOOP⟧
REVIEW_DONE:1664:architect:approve

⟦AI:AUTO-LOOP⟧

@jason-aelf
Copy link
Copy Markdown
Collaborator Author

🤖 代码质量审查:通过

TL;DR:从 readability / naming / simplicity 角度看,本 PR 可以通过。
变更集中在 workflow llm_call ToolContext 传播,没有发现死代码、过度抽象或无关清理。
HOST_REFACTOR_COMMENT_POLICY 解析为 none,本轮未因缺失自说明注释扣分。

详细说明

  • WorkflowExecutionRuntimeContext 删除了独立的 LlmOverrides mirror,运行时上下文表面更小,ApplyToolContext 直接保存 ToolContext,语义清楚。
  • LLMCallModule 新增的 ApplyWorkflowToolContext / BuildLlmControlFromToolContext / Has*Context helpers 都从 dispatch 路径可达,命名直接对应业务概念。
  • ToolContext 控制面字段与非控制面上下文的拆分由小函数表达,没有新增单实现接口或未来扩展占位。
  • 新增/调整的测试覆盖 full ToolContext 与 control-only 两条路径,未看到与 PR 目标无关的 fixture 扩张。
Raw artifact
---
pr: 1664
role: quality
verdict: approve
---

## Verdict
Approve: the change is focused, readable, and keeps the ToolContext-to-LLM-control mapping simple without adding dead code or unnecessary abstraction.

## Evidence
- `src/workflow/Aevatar.Workflow.Core/Execution/WorkflowExecutionRuntimeContext.cs:24` keeps the runtime context surface small after removing the separate `LlmOverrides` mirror; `ApplyToolContext` at line 67 now stores the tool context directly with no extra state copy.
- `src/workflow/Aevatar.Workflow.Core/Modules/LLMCallModule.cs:336` uses the intent-revealing `ApplyWorkflowToolContext` entry point, and it is reachable from dispatch at line 655.
- `src/workflow/Aevatar.Workflow.Core/Modules/LLMCallModule.cs:352` through line 402 splits the mapping and presence checks into small, direct helpers; no helper introduces a new abstraction or unused private surface.
- `test/Aevatar.Integration.Tests/WorkflowAdditionalModulesCoverageTests.cs:2001` and line 2095 cover both full ToolContext forwarding and control-only forwarding without adding unrelated fixture complexity.
- `${HOST_REFACTOR_COMMENT_POLICY:-none}` resolved to `none`; the PR does not add new refactor self-doc comments in the changed code and deletes the obsolete `WorkflowLlmRuntimeOverrides` self-doc block with the removed type.

## What would change your verdict (only if comment or reject)
N/A.

⟦AI:AUTO-LOOP⟧
REVIEW_DONE:1664:quality:approve

⟦AI:AUTO-LOOP⟧

@jason-aelf
Copy link
Copy Markdown
Collaborator Author

📊 当前状态 — review-gate 通过, 等 CI 完成(不需要人介入)

维度
阶段 Consensus-rnd Phase ci-watch
PR #1664
Reviewer consensus architect approve · tests approve · quality approve
Merge gate reviewer gate 已通过;仍需 CI 全部完成
当前 CI coverage-quality 仍在运行
是否需要人介入 ❌ 否

下一步自动会做:等待 coverage-quality 完成;若成功则进入 ready/merge 路由,若失败则按 scoped CI fix 路由处理。

🤖 controller status banner

⟦AI:AUTO-LOOP⟧

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

❌ Patch coverage is 93.47826% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (auto-work-dev@2a3aafd). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...low/Aevatar.Workflow.Core/Modules/LLMCallModule.cs 93.47% 0 Missing and 3 partials ⚠️
@@               Coverage Diff                @@
##             auto-work-dev    #1664   +/-   ##
================================================
  Coverage                 ?   83.05%           
================================================
  Files                    ?     1015           
  Lines                    ?    67502           
  Branches                 ?     8746           
================================================
  Hits                     ?    56062           
  Misses                   ?     7635           
  Partials                 ?     3805           
Flag Coverage Δ
ci 83.05% <93.47%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
....Core/Execution/WorkflowExecutionRuntimeContext.cs 86.20% <ø> (ø)
...low/Aevatar.Workflow.Core/Modules/LLMCallModule.cs 82.15% <93.47%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jason-aelf jason-aelf marked this pull request as ready for review June 2, 2026 02:41
@jason-aelf jason-aelf requested a review from louis4li as a code owner June 2, 2026 02:41
@jason-aelf jason-aelf merged commit c215245 into auto-work-dev Jun 2, 2026
12 checks passed
@jason-aelf jason-aelf deleted the refactor/issue-1652-toolcontext branch June 2, 2026 02:41
@louis4li louis4li added the crnd:phase:merged Work has landed. label Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-loop-reviewing Phase 8 reviewer codex round in flight crnd:human:auto Controller may continue without maintainer intervention. crnd:lifecycle:managed Item is managed by codex-refactor-loop. crnd:phase:merged Work has landed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants