Skip to content

Add budgeted wrappers to shared context output - #26

Merged
aakashH242 merged 1 commit into
mainfrom
feat/budget-context-wrappers
Sep 5, 2026
Merged

aakashH242 merged 1 commit into
mainfrom
feat/budget-context-wrappers

Conversation

@aakashH242

Copy link
Copy Markdown
Collaborator

Summary

  • add frozen ContextSource(text, prefix="") inputs for output-only source prefixes
  • add an optional separator to trim_context() and atrim_context()
  • return exactly measured prompt-ready text for wrapper-aware calls while preserving legacy plain-string accounting
  • keep prefixes and separators out of segmentation, ranking, embedding callbacks, and source spans
  • prepare the additive API as v0.5.0 and update end-user documentation and wheel smoke coverage

Classification and root cause

This is an enhancement, not a regression. The v0.4 context API deliberately measured only returned source rows; labels and separators added afterward were outside its limit. Conditional prefixes cannot be reserved accurately as one fixed allowance because they cost space only when their source contributes. This change charges that cost during selection and remeasures the complete rendered string.

Verification

  • 256 non-integration tests passed with 97.24% coverage
  • 1 real CPU FastEmbed integration test passed
  • Ruff check and format passed
  • strict mypy passed
  • strict MkDocs build passed
  • 1,600 randomized wrapper/custom-counter cases passed
  • clean v0.5.0 sdist and wheel built
  • clean Python 3.12 wheel install, pip check, API smoke, metadata, and embedded README checks passed

Closes #25

Add opt-in per-source prefixes and separators that are charged against the complete rendered context while preserving legacy plain-string accounting. Return prompt-ready context text, keep wrappers out of ranking and spans, document the API, and prepare v0.5.0.
@aakashH242
aakashH242 merged commit d1ac54e into main Sep 5, 2026
16 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.

Support budgeted per-source wrappers in shared context output

1 participant