Skip to content

Runtime/unify invocation context - #39

Merged
likun666661 merged 2 commits into
apache:mainfrom
YayoiNanoka:runtime/unify-invocation-context
Jun 18, 2026
Merged

likun666661 merged 2 commits into
apache:mainfrom
YayoiNanoka:runtime/unify-invocation-context

Conversation

@YayoiNanoka

Copy link
Copy Markdown
Contributor

Summary

本 PR 主要完成 Runtime 中 InvocationContext 的类型收敛,并补充相关测试与文档更新。

主要改动:

  • 将 AgentFlow 使用的 InvocationContext 统一到 runtime canonical InvocationContext。
  • 移除 / 避免 agent-flow.ts 中重复维护一套较窄的 InvocationContext 定义。
  • 调整 AiSdkFlow,使其直接从 invocation-context 引入 canonical context。
  • 更新相关测试 fixture,使测试使用完整的 canonical context shape。
  • 增加类型层面的 contract 测试,防止后续重新出现两套 context 定义。
  • 更新 Runtime V2 文档中关于“两套 InvocationContext”的过期说明。
  • 对 proxy timeout 相关测试做了一个小的健壮性修复,允许不同运行环境下返回 fetch failed,同时保留快速失败的断言。

Why

之前 Runtime 中存在两套结构兼容但定义重复的 InvocationContext:

  • runner 侧使用较完整的 canonical context。
  • flow 侧存在一套较窄的重复定义。

虽然 TypeScript 的结构类型让当前代码可以正常工作,但这种重复定义容易造成后续维护中的语义漂移,也会让 RuntimeRunner 与 AgentFlow 的边界变得不够清晰。

本 PR 将 AgentFlow 统一到 canonical InvocationContext,让 runner / flow 边界只依赖同一套 context contract,降低后续重构和扩展时的歧义。

Validation

已执行:

  • npm --workspace @maka/runtime run test

    • 538 passing
    • 0 failing
  • git diff --check

    • passed

Notes

  • InvocationContext 相关修改主要是类型/API 边界收敛,预期不改变运行时行为。
  • proxy 测试修改是一个测试健壮性修复,用于兼容不同平台 / undici 行为下 hung-proxy 场景可能返回 fetch failed 而不是显式 timeout message 的情况。

@likun666661
likun666661 merged commit a46c06c into apache:main Jun 18, 2026
jackwener pushed a commit that referenced this pull request Jun 21, 2026
jackwener pushed a commit that referenced this pull request Jun 21, 2026
jackwener pushed a commit that referenced this pull request Jun 21, 2026
jackwener pushed a commit that referenced this pull request Jun 21, 2026
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