Skip to main content
Glama

cf_inject

Injects a stable, versioned prompt prefix and appends only new request content to the tail, reusing the frozen prefix per session to improve cache hits.

Instructions

会话增量注入:固定版本化前缀(规则块+分级片段+固定补充块)逐字节不变,新内容(本次请求+易变内容)只追加到尾部 tail;同一 sessionId 自动冻结前缀支持跨请求复用;前缀不足最小有效长度时自动补高价值片段/固定文档块过门槛。【何时调】发请求前需要稳定前缀时:同一会话首次 reset=true,之后同一 sessionId 增量追加;短对话、一次性提问不必调用。

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "request": "<request>",
      "fragments": "<fragments>"
    },
    "name": "cf_inject"
  }
}

Input Schema

NameRequiredDescriptionDefault
resetNo重置该会话冻结前缀,重新冻结
requestYes当前请求文本(动态增量 tail)
align128No128-token 对齐开关(默认开启;false 恢复原行为)
scenarioNo显式指定约束场景(默认按缓存充足度自动选择)
volatileNo显式易变内容(时间戳/会话标记等),强制进 tail
fragmentsYes已分级准入片段(首次请求时冻结,后续请求复用)
hitTokensNo本次请求的厂商 usage 命中 tokens(prompt_cache_hit_tokens),供 cf_meter 计费相对值曲线累计;必须 ≥ 0
maxTokensNo注入后 token 上限;必须为 ≥ 1 的整数(不传则用内置默认值)
sessionIdNo会话标识;同一会话冻结前缀,跨请求复用
missTokensNo本次请求的厂商 usage 未命中 tokens(prompt_cache_miss_tokens),供 cf_meter 计费相对值曲线累计;必须 ≥ 0
strictnessNo约束强度(v0.4.2):strict 完整硬约束(默认)/ balanced 平衡(允许自身知识补充并标注)/ loose 自由放行;仅影响 full 场景;同一会话冻结后以冻结值为准
alignFillTextNo128 对齐填充块(默认固定 ASCII 注释块)
freezeFragmentsNo是否冻结片段用于跨请求前缀复用(v0.4.2,默认 true;false 时冷启动不锁死占位片段,允许随请求重建前缀)
minPrefixTokensNo最小有效前缀长度门槛(token),默认 200;必须 ≥ 0
minPrefixDocBlocksNo过门槛用的固定版本文档块
previousPrefixHashNo上一次请求返回的 prefixHash;一致则标记前缀复用(兼容无冻结信息场景)
minPrefixSafetyFactorNo最小前缀门槛安全余量(v0.4.2,默认 1.15):实际门槛 = ceil(minPrefixTokens × factor);必须 ≥ 1(< 1 会让门槛低于厂商最小值,缓存必然不生效)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.2

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only say readOnlyHint=false, idempotentHint=false, destructiveHint=false. The description adds what those hints cannot: the prefix is frozen per sessionId and reused across requests, the prefix is byte-identical, padding fragments or document blocks are auto-inserted when the prefix falls under the minimum effective length, and state persists between calls (consistent with idempotentHint=false). What is missing is any statement of the return payload, even though the previousPrefixHash parameter refers to a prefixHash returned by a prior call.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Structure is front-loaded and purposeful: mechanism first, then a clearly delimited 【何时调】 section. The prose is dense with domain jargon (分级片段, 过门槛) and packs several ideas per clause, but every sentence carries information for a 17-parameter stateful tool, so there is little waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 17-parameter, stateful, non-idempotent tool with no output schema, the description covers the core mechanism and call sequencing well. However, it never describes what the call returns (prefixHash, token accounting) despite the schema depending on a prior return value, and it omits the accounting and scenario parameters almost entirely, so an agent still needs the schema to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description does add some relational meaning beyond the schema – that request plus volatile content go to the tail while fragments are frozen into the prefix, and that reset governs the first call – but it says nothing about hitTokens/missTokens accounting, strictness scenarios, alignment, or the safety-factor threshold, leaving those entirely to the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a concrete operation (session incremental injection) and explains the mechanism: a versioned prefix (rule block + tiered fragments + fixed supplement block) held byte-identical, with new content (this request + volatile content) appended only to the tail. That is far more specific than restating the name, though it never contrasts itself by name with siblings such as cf_tier or cf_normalize, so the agent must infer the boundary.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The 【何时调】 block gives an explicit trigger (before a request that needs a stable prefix), an explicit sequencing rule (reset=true on the first call per session, then incrementally append under the same sessionId), and an explicit exclusion (short conversations and one-off questions need not call it). It stops short of naming an alternative tool to use instead when injection is not wanted, which is why it is not a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.