feat(lasso): intent double-duty on the classify call - #67
Open
orgersh92 wants to merge 2 commits into
Open
Conversation
Stamp per-turn traceId/eventIndex/eventId + sessionInformation from app-seeded
x-lasso-* headers so the existing /classify call also feeds Lasso's intent pipeline.
Stride-indexed, deterministic ids (idempotent re-sends), reasoning harvested from
reasoning_content/thinking_blocks. Inert without a seeded trace id. Also sends
source={type:litellm}.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
What
Adds intent double-duty to the LiteLLM Lasso custom guardrail. When an app funnels its LLM calls through LiteLLM and seeds per-turn intent headers (via the
lasso-sdkGatewayIntentprimitive), the plugin's existing/classifycall now also carries the per-turn intent signals — so content-safety and intent ride one call, with no separate exporter or second Lasso API key in the app.Inert when no
x-lasso-trace-idis present (a plain guardrail call), so it ships dark until the app starts seeding.Change
On each classify call the plugin reads the app-seeded headers off the proxy request and stamps the classify payload's messages with intent ids:
x-lasso-trace-idx-session-idsessionIdx-lasso-application-intentsessionInformation.applicationIntentx-lasso-application-namesessionInformation.agenticAppName(
x-lasso-encoding: pct→ percent-decode the baseline values.)The server derives the intent signal from role × content-kind, so the plugin sends blocks, not signals — reusing the guardrail's existing tool translation (
tool_useundermodel,tool_resultunderdeveloper,inputas an object). Model reasoning is harvested fromreasoning_content/thinking_blocksinto areasoningblock. Also now sendssource={type:"litellm"}for the "Used By" attribution badge.Ordering + idempotency (the interesting part)
The gateway re-sends the whole conversation history on every turn, so the server dedups on
eventId. Ids must therefore be deterministic — derived from(traceId, eventIndex)— so a re-send at the same position collapses instead of duplicating. Reproducible events (text / tool_use / tool_result) are indexed on a stride (p × 10); COMPLETION-only reasoning (never re-sent in history) fills just above the previous reproducible event, off the stride grid, so it sorts before the answer it explains without shifting the re-sendable events. The PROMPT phase caches its reproducible-event count (keyed bylitellm_call_id) so the COMPLETION phase continues after it. This mirrors the Kongai-lasso-guardrailplugin (the reference intent implementation).Verification
tests/guardrails_tests/test_lasso_guardrails.py(inert-without-header, placeholder-ignored, stride stamping + deterministic ULID ids, pct-decoded session information, completion index continuation + reasoning harvest). Run in CI.🤖 Generated with Claude Code