Skip to content

refactor: migrate DirectiveDrafter integrations to 0.2.0dev1 - #64

Merged
rlippmann merged 5 commits into
mainfrom
litellm_drafter_refactor
Aug 10, 2026
Merged

refactor: migrate DirectiveDrafter integrations to 0.2.0dev1#64
rlippmann merged 5 commits into
mainfrom
litellm_drafter_refactor

Conversation

@rlippmann

@rlippmann rlippmann commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • bump context-compiler-directive-drafter to 0.2.0dev1
  • update the LiteLLM proxy DirectiveDrafter integration to consume DirectiveDrafter.draft_directive(...)
  • switch the LiteLLM fallback callback to the new str | None contract and use DirectiveDrafter's shared converter prompt
  • update the OpenWebUI DirectiveDrafter integration to use DirectiveDrafter's shared converter prompt
  • update the LiteLLM prompt-construction example to use the new DirectiveDrafter prompt API
  • update focused tests to match the new consumer boundaries and prompt API usage

Why

DirectiveDrafter 0.2.0dev1 changes the public integration surface in two important ways:

  • fallback callbacks now return str | None
  • prompt consumers should use DirectiveDrafter's shared converter prompt API instead of the removed template-rendering helpers

This PR keeps the existing LiteLLM and OpenWebUI flows intact while aligning them with the new DirectiveDrafter contract.

Example metadata

  • Enforcement point: host-side prompt construction / policy injection in reference integrations and examples
  • Domain: general assistant policy constraints
  • Technology/runtime: Python, LiteLLM Proxy, Open WebUI
  • Example type: reference integration / example compatibility migration
  • Does this use directive drafter? should normally be no: yes
  • Does this derive state from model output? must be no for primary examples: authoritative state mutation still happens only through Context Compiler

Checklist

  • Repository scaffolding / governance change
  • One primary enforcement point
  • Explicit authoritative state
  • No model-derived state mutation
  • Adversarial stub or equivalent test
  • Observable runtime behavior change
  • Domain vocabulary is natural
  • Framework is secondary to the enforcement point
  • Docs updated
  • Tests/smoke checks added where practical

Notes

Focused validation passed for the updated areas:

  • LiteLLM proxy integration:
    • uv run --no-sync ruff check python/reference_integrations/litellm_proxy/context_compiler_precall_hook_with_directive_drafter.py python/tests/test_litellm_proxy_with_directive_drafter.py
    • uv run --no-sync mypy python/reference_integrations/litellm_proxy/context_compiler_precall_hook_with_directive_drafter.py python/tests/test_litellm_proxy_with_directive_drafter.py
    • uv run --no-sync pytest python/tests/test_litellm_proxy_with_directive_drafter.py python/tests/test_litellm_proxy_hooks.py python/tests/test_litellm_proxy_runtime.py
  • OpenWebUI DirectiveDrafter integration:
    • uv run --no-sync pytest python/tests/test_openwebui_pipe_with_directive_drafter.py
    • uv run --no-sync mypy python/reference_integrations/openwebui_pipe/open_webui_pipe_with_directive_drafter.py
    • uv run --no-sync ruff check python/reference_integrations/openwebui_pipe/open_webui_pipe_with_directive_drafter.py
  • LiteLLM prompt-construction example:
    • uv run --no-sync pytest python/tests/test_litellm_with_directive_drafter.py
    • uv run --no-sync mypy python/examples/prompt_construction/litellm/with_directive_drafter.py python/tests/test_litellm_with_directive_drafter.py
    • uv run --no-sync ruff check python/examples/prompt_construction/litellm/with_directive_drafter.py python/tests/test_litellm_with_directive_drafter.py

At the time of the LiteLLM-only migration, repo-wide ./scripts/validate_python.sh was blocked by removed render_prompt imports in the OpenWebUI integration and the LiteLLM example. Those compatibility issues are now included in this branch.

@rlippmann
rlippmann merged commit 4f900fd into main Aug 10, 2026
6 checks passed
@rlippmann
rlippmann deleted the litellm_drafter_refactor branch August 10, 2026 03:25
@rlippmann rlippmann changed the title refactor: migrate LiteLLM integration to DirectiveDrafter API refactor: migrate DirectiveDrafter integrations to 0.2.0dev1 Aug 10, 2026
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