Skip to content

bug: campaign knowledge records a delivery when all matched skills exceed the context budget #696

Backlog

Description

@fake0fan

During a four-GPU Hy4 serving-capacity experiment, the optimizer searched for guidance on request admission and token delivery. Five skills matched the request closely enough to be selected. All five exceeded the caller's context budget, leaving the optimizer with zero bytes of guidance. The campaign summary still listed one delivered_context entry.

Recorded request

On 2026-11-24 at 10:10:04 UTC, InferRSI 0.2.4.dev3+g61303fa81 recorded this request (optimizer call 39):

inferrsi campaign knowledge --directory campaign \
  --query "serving admission capacity closed-loop TTFT output token delivery TP speculation DFly" \
  --context-bytes 3900 > logs/knowledge.json
head -c 300 logs/knowledge.json

The receipt stored the exact query above in request.relevance, with request.query = "". It used weighted-lexical-v1 over generated-packaged-skills, source package, and an effective limit of 5. The caller supplied no ID, revision, backend, or scenario filter. The 3,900-byte budget applied to UTF-8 resource content.

Recorded response

Of 128 entries considered, 74 matched. The item limit excluded 69. Each of the remaining five received context_limit with all 3,900 bytes still available.

Rank Skill Required bytes
1 assess_serving_preemption 36,807
2 kv_tier_management 10,812
3 calibrate_serving_simulation 37,659
4 inference_benchmark_design 307,396
5 diagnose_vllm_admission_pressure 125,840

The receipt ended with context_bytes_used: 0, contexts: [], and assembled_text: "". The 300-byte preview showed the delivery reference and omitted these fields. The trace records one such request and no retry.

Current reproduction and expected behavior

A read-only check on 0.3.4.dev3+g7bc51f216 also returned five items, zero contexts, and zero content bytes. The current Find ranker selected a different top five. To repeat the check from the repository checkout:

inferrsi collect --relevance "serving admission capacity closed-loop TTFT output token delivery TP speculation DFly" \
  --context-bytes 3900 --limit 5 --json

When every match exceeds the budget, the CLI response and campaign summary should make “5 matches, 0 bytes delivered” visible up front and give the caller a concrete retry option, such as the smallest required budget and its matching skill.

Activity

  1. Dong1017 commented on Nov 25, 2026

    @Dong1017
    Collaborator

    Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model auto-smart).

    When every matched skill exceeds --context-bytes, the campaign receipt still records a delivery with 0 bytes delivered, so the fix should make zero delivery visible and give the caller a retry path; the open design question is whether the byte budget should filter before the 5-item limit.

    What the issue asks: when all matches exceed the budget, the CLI response and campaign summary should show "5 matches, 0 bytes delivered" up front, with a retry option (the smallest required budget and its matching skill).

    Risk: the 300-byte preview shows the delivery reference but hides context_bytes_used: 0, contexts: [] and the empty assembled_text. A reader or the optimizer can treat the call as delivered, and the trace shows no retry happened.

    Next steps:

    • Rerun the exact campaign knowledge command on current main and attach the full JSON receipt, not the preview.
    • Agree the zero-delivery contract (questions in the details below) before any change.
    • Add a regression for the all-over-budget case: zero contexts, an explicit zero-delivery status, and a retry hint.

    Dong-bot cannot write code, and this project has no coding agent, so a human maintainer must take the fix. The body names no owner; the issue owner should assign one.

    Details

    Gaps

    • The failing run used campaign knowledge on 0.2.4.dev3. The suggested repro uses collect on 0.3.4.dev3, and the reporter says the ranker now picks a different top five. The original failing path has not been reproduced on current code.
    • The receipt contract is not defined: should delivered_context be absent, or should it be a non-delivery entry, and which status should a caller read?
    • Ordering: the item limit cut 69 of 74 matches before the byte budget applied. The issue does not say whether any of those fit in 3,900 bytes. The smallest of the top five needs 10,812 bytes.
    • The query sits in request.relevance while request.query is empty. Confirm this is intended, since it is easy to misread.
    • Not stated: whether a zero-delivery result is counted in the campaign's delivery totals, and which downstream consumers read that count.

    Clarifying questions

    1. When nothing fits, should the command exit non-zero, return an empty success with a context_limit-style status, or fall back automatically to the smallest fitting match?
    2. Should the item limit apply after the byte filter?
    3. Should the campaign summary's delivered_context count selected items or delivered bytes?
    4. Can the reporter rerun the exact campaign knowledge command on current main and attach the full JSON?

    Verified and not verified

    • Read issue/meta.json, issue/body.md, decisions.md (no decision recorded on bug: campaign knowledge records a delivery when all matched skills exceed the context budget #696) and skills/review-pr/SKILL.md.
    • Checked the default-branch layout of src/inferrsi/knowledge/ and context_projection.py. That file only projects identity fields and renders text, so I did not locate where delivered_context is written.
    • Nothing was run: no command, test or repro. The facts above come from the issue body.
  2. Bounty-hunter commented on Nov 25, 2026

    @Bounty-hunter
    Collaborator

    Claude Code agent, acting for @Bounty-hunter. Discussion input on scope (not a direction decision; the Issue owner/maintainers decide).

    I read the delivery path on main at 1e565eed. I did not run the reproduction.

    The data for the retry hint already exists; what is missing is a summary of it and the label on the envelope.

    • Both budgeted selection paths already record the size each omitted item needed. src/inferrsi/knowledge/_skill_selection.py returns {"ref": ..., "reason": "context_limit", "required_bytes": required_bytes, "available_bytes": available} from context_view (L161-165) and record_context (L119-121). So "smallest required budget and its skill" can be computed from context_omissions alone, with no ranking change. Note that for skills required_bytes is measured after the skill_procedure projection, so it is the number a retry actually needs, not the raw file size from the table.
    • The service-context path in knowledge_operations.py (around L355-361) appends {"ref": ref, "reason": "context_limit" if ... else "item_limit"} without required_bytes/available_bytes. If the hint is meant to work for every collect source, that omission shape needs the same two fields.
    • The envelope label does not depend on what was delivered. src/inferrsi/apps/views/capture_delivery.py builds {"path": source, "sha256": digest, "kind": "delivered_context"} in managed_envelopes (L78-80) and again at L277, whether contexts is empty or not. I think that is why the campaign summary counts one delivered_context for a 0-byte receipt.

    Smallest change I would suggest: when contexts == [] and at least one omission has context_limit, add a top-level field to the result and capture, for example budget_shortfall: {"matched": 5, "delivered_bytes": 0, "smallest_required_bytes": 10812, "ref": "...kv_tier_management"}. Show it first in the CLI JSON and in the summary entry. Keep the existing receipt fields byte-identical.

    Questions that change the outcome:

    1. Should a zero-delivery capture still count as a delivered_context in the campaign summary (with the shortfall shown), or be counted separately (for example as empty_context)? This affects existing summary consumers and trace verification.
    2. Should collect/campaign knowledge keep exit status 0 in this case? A non-zero exit would make agents retry, but it changes a contract that scripts rely on.

    Not checked: the campaign summary renderer that produces the count, whether verify_capture accepts an empty contexts list unchanged, and the 0.2.4 code path from the original receipt.

  3. zengchuang-hw commented on Nov 25, 2026

    @zengchuang-hw
    Contributor

    PASS
    Dot,代表 zengchuang-hw 独立检视。

    本轮确认问题和修复方向成立,不是修复验收。在 main 1e565eed 的 Campaign 控制器,保留检索回执后会无条件加上 delivered_context,并未检查回执有没有正文。我用该提交的实际函数加检索/存储替身,构造 5 个匹配、0 个正文、0 字节,确认响应和状态仍记录一次 delivered_context。未重跑原 Hy4 会话或实装 CLI。

    建议保留空检索的审计回执,但不要把它计为内容交付,也不要让它当作有正文的 --knowledge-ref。在 CLI 的短摘要和会话摘要都明确显示匹配数、实际交付数和字节数;若给预算提示,用同一路径实际按 UTF-8 计费的最小可装入项,并说明提示只保证能装下该项。回归至少对照全超限、部分交付和无匹配,保证非空交付原行为不变。服务路径也有同名记录,建议单独核对其“已准备但未消费”的计数口径,不以本轮普通 Campaign 替身测试替代服务验证。

  4. david6666666 commented on Nov 25, 2026

    @david6666666
    Collaborator

    Dot, acting for @david6666666 under delegated Issue review.

    Please put the zero-byte regression at the round-admission boundary as well as in the summary. _validate_knowledge_refs checks for delivered resources only on receipt#item; a bare receipt path is accepted from the state list without reading its body. Test both forms against a newly empty capture and an existing empty capture already tagged delivered_context. The old receipt should remain readable for audit without qualifying as adopted evidence; a real delivered item should still work.

  5. added
    area:knowledge
    kind:bug
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:knowledgekind:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions