Skip to content

feat(agent-runtime): add provider hook contextRequestId and getContextUsage().autoCompactAt - #2451

Merged
vastsa merged 2 commits into
vastsa:mainfrom
sedirk:feat/extension-provider-request-id
Nov 20, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
sedirk:feat/extension-provider-request-id

Conversation

@sedirk

@sedirk sedirk commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary / 概要

按最小改动原则为受信任扩展(Trusted Extensions)补充两项纯进程内的只读观测元数据:

  • 请求/响应钩子本地关联 ID(contextRequestId):在 DesktopAgentRuntime.withExtensionProviderHooks 中为每次底层模型调用分配单调递增的进程内 contextRequestId,透传给 before_provider_request 与 after_provider_response 事件,方便异步通知乱序返回时准确配对,且不触碰任何外发请求头或请求载荷。
  • 自动压缩阈值只读字段(autoCompactAt):在 ctx.getContextUsage() 返回结构中补充 autoCompactAt(启用自动压缩时为 automaticCompactionThresholdFor(budget),禁用时为 null)。
  • 零默认影响:仅涉及 packages/agent-runtime 约 17 行实现代码及对应单测与规范说明;未加载相关扩展时行为无任何变化。

Adds a monotonic in-process contextRequestId to before_provider_request and after_provider_response hook events (never sent over the wire) and exposes autoCompactAt: number | null on ctx.getContextUsage().

说明:注意到 CONTRIBUTING.md 中关于外部 feat PR 窗口期的约定,这里仅将已基于最新 main(95df2e0)通过本地检查的最小改动一并附上,方便维护者审阅参考;若团队倾向于先仅保留 Issue 讨论或希望调整实现方式,随时关闭或指正即可,完全理解与尊重。

Requirement link / 需求关联

  • Linked requirement issue / 已关联对应的需求 Issue:Closes #2449
  • Issue explains the background and the expected outcome / Issue 已说明需求背景和期望效果
  • UI changes carry a fitting reference: screenshot, sketch, or demo / 涉及 UI 的改动已提供合适的截图、设计参考或 Demo(纯 agent-runtime 与规范文档改动,不涉及 UI 变更)
  • UI changes include before / after screenshots, uploaded to the PR (not committed to the repo) / UI 变更已附修改前后截图(不涉及 UI 变更)

Copilot AI balanced review requested due to automatic review settings November 19, 2026 15:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@vastsa
vastsa merged commit acf652e into vastsa:main Nov 20, 2026
6 checks passed
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.

3 participants