Repository navigation
feat: Add inference-parser plugin for outbound LLM traffic - #365
Conversation
mrsabath
left a comment
There was a problem hiding this comment.
Review Summary
Well-structured plugin that completes the Phase 2 parser triad (inbound: mcp-parser + a2a-parser, outbound: inference-parser). Follows existing plugin patterns, has good test coverage (11 tests), and correctly uses path-based gating so non-LLM traffic is unaffected. The extension struct design is clean with proper use of pointer types for optional fields.
Suggestions (non-blocking)
-
Log level —
slog.Info("inference-parser", "model", ext.Model)fires on every parsed request. Theslog.Debugon the next line already covers the same info with more context. Consider making the Info-level log Debug-level too, to reduce noise in production. -
Legacy
/v1/completionsprompt field — The endpoint uses apromptstring rather thanmessages[]. Currently it's silently ignored (model and max_tokens are captured, which is useful). Fine for MVP — worth a brief comment or TODO if you plan to support it later.
Areas reviewed: Go code, pipeline architecture, security, tests
Commits: 1, DCO signed-off ✓
CI status: All checks pass
LGTM — clean implementation.
Reviewed with Claude Code
Add the inference-parser plugin that parses outbound OpenAI-compatible LLM inference requests (/v1/chat/completions, /v1/completions) and populates pctx.Extensions.Inference for downstream policy plugins (prompt guardrails, audit/observability). Extracted fields: model, messages[], temperature, max_tokens, stream, tool/function names. Path-based detection ensures non-LLM outbound traffic (MCP calls, other APIs) is not parsed. Like mcp-parser, it is NOT added to default pipelines — users opt in via config. This completes the Phase 2 protocol parser triad: - Inbound: mcp-parser (MCP JSON-RPC), a2a-parser (A2A JSON-RPC) - Outbound: inference-parser (OpenAI REST) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Hai Huang <[email protected]>
a6c13fc to
45fe965
Compare
Replace non-existent NeedsResponseBody() with NeedsBody(). Remove unused context and strconv imports in extproc after rebase. Signed-off-by: Hai Huang <[email protected]> Signed-off-by: Hai Huang <[email protected]>
…known, and fix a real regression in the zero-prompt-total gate Two more findings from clawgenti's re-review: - The currency fix only gated PluginSpendMicros (basis usd). PluginSpendUnknownMicros is "not money", but it is still one number, and a USD figure and a differently- priced currency's figure summed into it is just as mixed. Same gate now applies there. - The zero-prompt-total gate in InferenceParser.accountant asked whenever pctx.ReportedOps() was non-empty, reasoning that the pass before any data arrives has no ops either. That was wrong: a structural op (tool-prune's removal, say) reports during OnRequest, before the response exists, so that pass's ops list is not empty either — and asking there calls Host.Compute with an inference extension that is still all zeros, which Compute latches forever, so the real counts that arrive on a later pass are never priced at all. Reproduced by clawgenti; fixed by gating on pctx.StatusCode (set once, when the response is read) instead of on ReportedOps. Added a regression test pinning the exact two-pass sequence. Also dismissed the same 2 alerts' re-raised instances (rossoctl#365, rossoctl#370) after they shifted line following the rebase onto main — the earlier dismissal (rossoctl#372, rossoctl#373) stopped applying once that commit was superseded. Assisted-By: Claude Sonnet 5 <[email protected]> Signed-off-by: DAVID BOAZ <[email protected]>
Summary
inference-parserplugin that parses outbound OpenAI-compatible LLM requests (/v1/chat/completions,/v1/completions)pctx.Extensions.Inferencewith model, messages, temperature, max_tokens, stream, and tool names"inference"extension slot indefaultSlotsand factory in plugin registryCompletes the Phase 2 protocol parser triad:
mcp-parser(MCP JSON-RPC),a2a-parser(A2A JSON-RPC)inference-parser(OpenAI REST)Motivation
Kagenti agents call LLMs (Ollama, vLLM) via the OpenAI-compatible
/v1/chat/completionsendpoint. This plugin gives the outbound pipeline visibility into inference request content, enabling future downstream plugins for:Pipeline Placement
Not added to default pipelines — users opt in via config.
Test plan
go test ./plugins/... -run Inference -v— 11 tests passgo test ./...— all authlib tests passgo build ./...— binary builds cleanlyinference-parserin outbound pipeline, send chat through UI, verifyinference-parser model=llama3.1in logsAssisted-By: Claude (Anthropic AI) [email protected]