feat(operations): pre-turn ContextProvider injection seam (ADR-0100)#1886
Merged
Conversation
Adds the seam-only PR 1 from the signed injection design: an ordered ContextProvider registry on Branch, a per-turn injection slot read by the chat guidance fold, and budget/failure containment. Pure lionagi, no khive dependency. - lionagi/protocols/context_providers.py: ContextProvider protocol, ProviderReport, ContextProviderRegistry (budget enforcement drops lowest-priority providers first; provider exceptions are contained and reported, never raised). - Branch.providers: lazily-created registry (manager-property pattern mirroring msgs/acts/mdls/memory); zero-cost when unused. - operations/chat/_prepare.py: extracts _build_instruction so the Middle can build the Instruction once and reuse it for both provider gather and prepare (avoids double-applying context updates); extends the guidance fold to system.rendered + injected blocks + guidance; adds _apply_context_providers helper. - operations/chat/chat.py and operations/run/run.py: gather providers before _prepare_run_kwargs, clear the slot right after. Injected text never enters the durable message record. - docs/adrs/ADR-0100-context-injection-providers.md: the public contract, copied verbatim from the signed design workspace. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
…eport Providers render into the system-guidance fold; a branch with no system message has no render target. Previously providers were still gathered (spending retrieval + tokens) and their output silently dropped, with the ProviderReport discarded on every turn path. Now: systemless turns skip gathering entirely and record every registered provider as skipped; all turns expose the report via branch.last_context_report. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
oceanwaves630
approved these changes
Jul 8, 2026
oceanwaves630
left a comment
Collaborator
There was a problem hiding this comment.
Approved per fleet merge flow v2 (design signed at comm gate; codex R2 APPROVE; R1 observable-report fix aligns with the signed rider).
This was referenced Jul 8, 2026
This was referenced Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(operations): pre-turn ContextProvider injection seam (ADR-0100)
Adds the pre-turn context injection seam: a
ContextProviderprotocol +ContextProviderRegistryonBranch, folded into the system-guidance render in_prepare.py. Providers run once per turn before prompt assembly; their blocks render into the system message for that turn only and are cleared afterward — the message record is never polluted.What's in here
lionagi/protocols/context_providers.py—ContextProviderprotocol,ProviderReport(per-provider fired flag + token counts),ContextProviderRegistrywith a total token budget and per-provider error containment (a raising provider is skipped and reported, never breaks the turn).Branch.providersproperty backed by private attrs; zero cost when unused._prepare.py—_build_instruction()extracted; injection folds assystem.rendered + injected + guidance. Prebuiltins=threading avoids double-applying context (create_instructionmutates an already-built Instruction in place).chat.py/run.py— providers applied before prepare; per-turn slot cleared infinally.docs/adrs/ADR-0100-context-injection-providers.md.Notes for review
_prepare.pyrather than inventing a new system-message-creation path.🤖 Generated with Claude Code