Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Price a request from plain values instead of the plugin request context

未关闭
#1,501 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
backend

调研方向

Read core/cost/settle/settle.go and core/cost/settle/avoided.go, then inspect core/plugins/inferenceparser/cost.go for the current callers. Add table tests for plain Input pricing, LiteLLM cost headers, and Comparable discount and margin checks. Done means Settle and Comparable accept plain values, their context forms wrap them, and existing cost tests pass unchanged.

由索引模型根据 Issue 内容生成。

描述

enhancement laptop

Part of #1437 (assessment: laptop data plane on Praxis) · prep work, useful to Cortex on its own

Status: there is no shipped Cortex–Praxis integration today (the paused cmd/cortex-praxis converter is not one), and the interim path is not decided (LLM traffic to praxis-ai as an inference server, or all traffic through Praxis via #1491). Nothing here depends on that choice: each item is useful to Cortex now, and would make a possible move to Praxis easier whichever path is taken.

Problem

Pricing a request needs the whole plugin request context.

  • settle.Settle(pctx, rates) reads pctx.Host, pctx.Extensions.Inference and pctx.ResponseHeaders (LiteLLM cost headers, and Content-Type via IsEventStream); pctx.Path only in log lines.
  • Avoided reads pctx.Extensions.Custom (tool-prune's record), the request body and BodyMutated().
  • Publish writes the result back into pctx under two keys; Store keeps it in pipeline state, which litellm-budget-track reads with Load and rewrites with Amend.

Eight exported functions take *pipeline.Context: Settle, Avoided, IsEventStream, Comparable, Store, Load, Publish, Amend.

Settle is called only from inside the inference-parser plugin (cost.go:72-112), which also calls Store, Avoided and IsEventStream; litellm-budget-track calls Comparable, Load and Amend. So pricing can run only inside Cortex's Go pipeline: not from a recorded event, not in a test without building a pctx, not from another proxy.

Proposal

This issue owns settle's input. #1497 item 3 owns recording the cost-relevant headers on the event, and #1503 depends on this one.

  • Settle(in Input, rates) Settled with Input{Host, Inference, ResponseHeaders}. IsEventStream is derived from ResponseHeaders; Path is only for logging and can be passed separately or dropped.
  • Comparable(in Input) the same way.
  • Avoided keeps a pctx form for now: it needs tool-prune's record, the forwarded body and BodyMutated(), none of which belong in a pricing input.
  • Store, Load, Publish and Amend are how plugins exchange the result; they stay on pctx (their serialization is #1499 item 4).
  • Keep Settle(pctx, rates) as a thin wrapper over the new form, so existing callers and tests don't change. No behaviour change.
  • Where the wrapper lives (the inference-parser plugin, or a separate cost step) is decided in #1503.

Done when

  • Settle and Comparable have plain-value forms, and the pctx versions are wrappers over them.
  • A table test prices from plain Input values, including the LiteLLM cost-header cases and the Comparable checks on the discount and margin headers. (Gateway multipliers are on the rates side, pricing/multiplier.go, and are unaffected.)
  • Existing cost tests pass unchanged (about 43 test calls use Settle(pctx, …)).

Evidence read at main @ e455a04 (2026-10-25); not built.

主要语言
Go
星标
21
派生
43
平均合并
13 小时 8 分钟
30 天内合并 PR
267

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rossoctl/cortex 的其他 Issue

查看 rossoctl/cortex 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。