Skip to content

Repository files navigation

Context Compiler Python Example Integrations

What runtime behavior changes when authoritative state exists?

These examples show how authoritative state changes application behavior at runtime.

Each example demonstrates a single enforcement point where premise and policy influence what a host allows, routes, retrieves, builds, or executes.

Prompt reinjection influences model behavior.

Context Compiler influences runtime behavior.

Each example:

  • demonstrates a single runtime enforcement point
  • uses explicit authoritative state
  • remains meaningful with an adversarial model stub
  • focuses on the enforcement point rather than the framework

This repository contains the Python examples and reference integrations. Use the enforcement-point catalog below to find the runtime behavior you want to inspect.

Ecosystem map

Project Question
context-compiler What is the authority contract?
context-compiler-directive-drafter How is authority acquired?
context-compiler-example-integrations Where can authority be enforced?

Enforcement-point catalog

Enforcement Point Domain Technology
Gateway middleware Customer support routing Python, LiteLLM Proxy
Schema selection Order / incident intake Python, Ollama, LiteLLM
Checkpoint continuation Travel booking Python, FastAPI
Execution authorization Expense approval Python
Retrieval filtering HR policy lookup Python, ChromaDB
Request construction / context assembly Writing assistant Python, LiteLLM, Open WebUI
Tool gating Calendar / email / admin Python, MCP

Install

Install the package from PyPI for the shared examples and core dependency:

pip install "context-compiler-example-integrations"

Add an extra for the examples you want to run locally:

  • pip install "context-compiler-example-integrations[drafter]" for Directive Drafter examples
  • pip install "context-compiler-example-integrations[retrieval]" for ChromaDB retrieval examples
  • pip install "context-compiler-example-integrations[fastapi]" for FastAPI variants
  • pip install "context-compiler-example-integrations[litellm]" for LiteLLM examples and reference integrations
  • pip install "context-compiler-example-integrations[all]" for all package-managed optional dependencies

Open WebUI is not installed by this package. Its reference integration assumes that Open WebUI is already installed and configured as the host runtime.

Reference integrations

The repository also includes runtime-specific integrations for:

Run an example

Use a repository checkout to explore an example:

  1. Choose an enforcement point from the catalog above.
  2. Open its README for setup, runtime, and validation instructions.
  3. Run the example from the repository root as documented.

Adding examples

Examples in this repo should:

  • use explicit authoritative state
  • avoid deriving Context Compiler state from model output
  • remain meaningful with an adversarial stub
  • demonstrate observable runtime behavior changes

See CONTRIBUTING.md and AGENTS.md for more detail.

Validation

Canonical repo-level validation commands:

uv sync --group dev --no-editable
uv run pre-commit run --all-files
npx --yes markdownlint-cli2

Contributors may install and run local pre-commit hooks:

uv run pre-commit install
uv run pre-commit run --all-files

CI runs pre-commit and Markdown lint separately.

License

Apache-2.0

Releases

Packages

Contributors

Languages