Skip to main content
Glama

Etuki FinOps & LLM Pricing Oracle

optimize_prompt_cache_layout

Read-onlyIdempotent

Reorders a single prompt's dynamic mid-turn tokens after static prefix tokens to prevent 1.25x cold-cache invalidation and restore 0.1x warm cache reads. Advisory in-memory simulation that mutates no live prompts and requires no authentication; zero-token inputs return 0 USD cost without error. Sums static_prefix_tokens and dynamic_mid_tokens to compare before_layout_cost_usd against after_layout_cost_usd and net_savings_pct (0-100). Use this tool when diagnosing mid-prompt timestamps or tool outputs that break cache breakpoints; use pin_single_model_prefix_cache instead to project 10-turn session economics for a target model ID.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "optimize_prompt_cache_layout"
  }
}

Input Schema

NameRequiredDescriptionDefault
completion_tokensNoOutput completion token count for the turn.
dynamic_mid_tokensNoToken count of volatile per-turn context that invalidates downstream cache breakpoints.
static_prefix_tokensNoToken count of invariant system instructions and repository context.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • addedInput schema / properties / completion_tokens / minimum
      Added value: +0
    • changedInput schema / properties / dynamic_mid_tokens / description
      Previous value: -"Token count of volatile per-turn context that previously invalidated the cache."New value: +"Token count of volatile per-turn context that invalidates downstream cache breakpoints."
    • addedInput schema / properties / dynamic_mid_tokens / minimum
      Added value: +0
    • addedInput schema / properties / static_prefix_tokens / minimum
      Added value: +0
  2. Changed3 schema fields changed
    • changedInput schema / properties / completion_tokens / description
      Previous value: -"Completion token count"New value: +"Output completion token count for the turn."
    • changedInput schema / properties / dynamic_mid_tokens / description
      Previous value: -"Dynamic mid-prompt token count"New value: +"Token count of volatile per-turn context that previously invalidated the cache."
    • changedInput schema / properties / static_prefix_tokens / description
      Previous value: -"Static prefix token count"New value: +"Token count of invariant system instructions and repository context."
  3. Changed3 schema fields changed
    • addedInput schema / properties / completion_tokens / description
      Added value: +"Completion token count"
    • addedInput schema / properties / dynamic_mid_tokens / description
      Added value: +"Dynamic mid-prompt token count"
    • addedInput schema / properties / static_prefix_tokens / description
      Added value: +"Static prefix token count"
  4. Added

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already mark this as read-only, idempotent, non-destructive, and not open-world. The description adds useful behavioral context beyond those annotations, stating that this is an advisory in-memory simulation, mutates no live prompts, requires no authentication, and returns 0 USD cost for zero-token inputs without error. This directly addresses safety, side effects, and edge-case behavior.

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?

The description is dense but front-loaded, leading with the action and outcome before covering simulation behavior and routing guidance. The cost comparison and sibling distinction are useful, though the opening sentence is quite long with technical jargon.

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

Completeness5/5

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

Although there is no output schema, the description names the key outputs: before_layout_cost_usd, after_layout_cost_usd, and net_savings_pct. It also covers non-mutation, authentication, zero-token behavior, and sibling-tool routing. This is complete enough for an agent to invoke the tool correctly.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3. The description adds meaningful semantics by explaining that static_prefix_tokens and dynamic_mid_tokens are summed and used to compare before_layout_cost_usd, after_layout_cost_usd, and net_savings_pct. It does not add much about completion_tokens beyond what the schema already documents.

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

Purpose5/5

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

The description opens with a specific verb and resource: reordering a prompt's dynamic mid-turn tokens after static prefix tokens. It clearly states the outcome of preventing cold-cache invalidation and restoring warm cache reads. It also distinguishes itself from the sibling tool pin_single_model_prefix_cache, which handles a different projection task.

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

Usage Guidelines5/5

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

The description explicitly says when to use the tool: diagnosing mid-prompt timestamps or tool outputs that break cache breakpoints. It also names the alternative pin_single_model_prefix_cache and states the condition for choosing it: projecting 10-turn session economics for a target model ID. This gives clear routing guidance.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.