Skip to content

refactor(context): decouple provider execution from context collector#49

Merged
ztygod merged 2 commits into
mainfrom
refactor/context-pipeline
Jul 19, 2026
Merged

refactor(context): decouple provider execution from context collector#49
ztygod merged 2 commits into
mainfrom
refactor/context-pipeline

Conversation

@ztygod

@ztygod ztygod commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

Extract context provider execution logic from ContextCollector into a dedicated ContextProviderExecutor.

This change is part of the Context Pipeline refactoring effort. The goal is to separate context collection responsibilities from provider lifecycle management, making the context system easier to extend and maintain.

Motivation

Previously, ContextCollector was responsible for both:

  • collecting built-in context sources (Memory, Workspace, User Context)
  • executing external ContextProviders

This caused several issues:

  • Provider execution logic was coupled with context construction.
  • A single provider failure could interrupt the entire context collection process.
  • Provider execution policies (timeout, isolation, metrics, concurrency) could not evolve independently.
  • Adding new provider behaviors required modifying ContextCollector.

Changes

Added ContextProviderExecutor

Introduced a dedicated executor responsible for provider execution lifecycle.

Responsibilities:

  • Execute context providers independently.
  • Run providers concurrently.
  • Isolate provider failures.
  • Collect provider execution duration.
  • Support provider-level timeout configuration.

Updated ContextCollector

ContextCollector now focuses only on:

  • Loading memory context.
  • Collecting workspace and user-provided context.
  • Converting provider execution results into ContextSection.
  • Building ContextDocument.

Provider execution details are delegated to ContextProviderExecutor.

Design

Before:

ContextCollector

 ├── Load Memory
 ├── Load Workspace
 ├── Execute Provider
 ├── Handle Provider Error
 └── Build ContextDocument

After:

ContextCollector

 ├── Load Memory
 ├── Load Workspace
 ├── Build ContextDocument
 |
 └── ContextProviderExecutor
          |
          ├── Execute Provider
          ├── Handle Failure
          ├── Apply Timeout
          └── Collect Metrics

Behavior Changes

No changes to the external Context API.

ContextManager and existing Agent execution flow continue to use the same context building interface.

The main behavioral improvements are:

  • Provider failures no longer directly break context collection.
  • Independent providers can execute concurrently.
  • Provider execution becomes independently testable.

Follow-up

Future improvements planned:

  • Add AbortSignal support for provider cancellation.
  • Add provider dependency management.
  • Add provider refresh strategy handling (once, each_iteration, on_demand).
  • Add provider token/output size limits.
  • Integrate provider execution metrics into context diagnostics.

@ztygod
ztygod merged commit 1b6b66e into main Jul 19, 2026
2 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.

1 participant