Skip to content

Claude Opus 5.5 (effort default (no --effort flag) · thinking on) on Fix five behavioural bugs in an LRU cache with per-entry TTL

AClaude Opus 5.5default · thinking on · Claude Code 2.1.299 (headless -p) · cloud · 2026-10-17 · by @bobsiopener

Trust 80%Fully autonomoussuccess · first try
Estimated cost
$0.16
Wall time
40s
Human step-ins
0
Outcome
Pass

Compare with other models on this task →

Summary

Exact prompt

# Task: fix the TTL cache `ttlcache.py` is an LRU cache with per-entry TTL. Users report: recently-read keys get evicted, expired keys are still counted in `len()`/`in`, entries that expire exactly at their deadline are still returned, overwriting a key does not refresh its LRU position, and `purge()` crashes. Intended behaviour: - `get` on a live key marks it most-recently-used; when the cache exceeds `maxsize` the **least**-recently-used entry is evicted. - An entry is expired when `clock() >= expires_at` (an entry with ttl=10 set at t=0 is gone at t=10). Expired entries are removed when touched by `get`, and are never visible via `len()` or `in`. - `set` on an existing key replaces the value, resets its TTL and makes it most-recently-used. - `ttl` of 0 or negative means "do not store" (and removes any existing entry for that key). - `purge()` removes all expired entries and returns how many were removed. - `hits`/`misses` count `get` outcomes. Keep the public API (constructor signature, method names). Add your own tests if you like. No network.

Bugs are spread over eviction order, LRU refresh on get/overwrite, an exact expiry boundary, expired-entry visibility, zero TTL and a dict-mutation crash; hidden tests use an injected clock. Original benchmark task written for usecaserank.com (not based on a specific public post). Headless, offline run on a reproducible fixture. Each run's notes say how its cost was measured (estimates are marked).

Success criteria: 1. All 11 hidden unittest cases pass against the agent's ttlcache.py (60 s timeout): LRU eviction of least-recently-used, get/overwrite refresh recency, expiry at clock() >= expires_at, expired entries invisible to len/in, overwrite resets TTL, ttl<=0 not stored, purge() returns count without crashing, hits/misses counted, constructor API kept.

Setup notes: Use Case Scout batch 5 case e01-ttl-cache-bugs (offline fixture). Prepared with batch5/prepare.sh; hidden key/tests kept outside the agent's work dir. Prompt = TASK.md verbatim. Scored with the scout's scorer: `python score.py WORKDIR KEYDIR`. Tools: Read/Write/Edit/Glob/Grep/Bash, web disabled. Single run, no retries. Claude Code's own reported cost for claude-opus-5.5: $0.156047. Score: 11/11. Cost is an ESTIMATE: measured tokens x pricing.json list price (Claude Pro subscription, nothing billed); input_tokens include cache reads and writes. Single run.

Estimated cost List-price estimate; not actually billed.

Metrics

Estimated cost
$0.16
Wall time
40s
Human step-ins
0
Turns
5
Model usage
ModelInput tokOutput tokCost
AClaude Opus 5.5anthropic/claude-opus-5.5effort default (no --effort flag) · thinking on99,5783,212$0.16

Reproduce this run

  1. Use the use case prompt on the use case page.
  2. Same setup: Claude Opus 5.5 (anthropic/claude-opus-5.5, effort default (no --effort flag) · thinking on) via Claude Code 2.1.299 (headless -p), cloud.
  3. It counts as a success only if it meets every success criterion: 1. All 11 hidden unittest cases pass against the agent's ttlcache.py (60 s timeout): LRU eviction of least-recently-used, get/overwrite refresh recency, expiry at clock() >= expires_at, expired entries invisible to len/in, overwrite resets TTL, ttl<=0 not stored, purge() returns count without crashing, hits/misses counted, constructor API kept.
  4. Log model, tokens, wall time, human step-ins and the evidence log, then submit it as a reproduction. A different model? Submit a head-to-head rerun.

How runs are scored: Methodology.

Was this useful?

⇄ Rerun on another model

Automated checks

Trust 80% comes from these checks (how Trust % works).

Evidence log
[
 {
  "duration_api_ms": 38793,
  "stop_reason": "end_turn",
  "session_id": "[REDACTED]",
  "total_cost_usd": 0.1560472,
  "usage": {
   "input_tokens": 10,
   "cache_creation_input_tokens": 9212,
   "cache_read_input_tokens": 90356,
   "output_tokens": 3212,
   "output_tokens_details": {
    "thinking_tokens": 239
   },
   "server_tool_use": {
    "web_search_requests": 0,
    "web_fetch_requests": 0
   },
   "service_tier": "standard",
   "cache_creation": {
    "ephemeral_1h_input_tokens": 9212,
    "ephemeral_5m_input_tokens": 0
   },
   "inference_geo": "global",
   "iterations": [
    {
     "input_tokens": 2,
     "output_tokens": 709,
     "cache_read_input_tokens": 20981,
     "cache_creation_input_tokens": 377,
     "cache_creation": {
      "ephemeral_5m_input_tokens": 0,
      "ephemeral_1h_input_tokens": 377
     },
     "type": "message"
    }
   ],
   "speed": "standard",
   "fallback_credit": null
  },
  "modelUsage": {
   "claude-opus-5-5": {
    "inputTokens": 10,
    "outputTokens": 3212,
    "cacheReadInputTokens": 90356,
    "cacheCreationInputTokens": 9212,
    "webSearchRequests": 0,
    "costUSD": 0.1560472,
    "contextWindow": 1000000,
    "maxOutputTokens": 128000,
    "thinkingTokens": 239,
    "canonicalModel": "claude-opus-5-5",
    "provider": "firstParty",
    "costBasis": "list"
   }
  },
  "permission_denials": [],
  "terminal_reason": "completed",
  "fast_mode_state": "off",
  "fast_mode_disabled_reason": "sdk_opt_in_required",
  "subagent_stats": {
   "spawned": 0,
   "requested": {
    "background": 0,
    "foreground": 0,
    "unset": 0
   },
   "started_in_background": 0,
   "max_depth": 0,
   "spawned_by_subagents": 0,
   "completed": 0,
   "failed": 0,
   "killed": {
    "parent": 0,
    "user": 0,
    "system": 0
   },
   "refused": {
    "depth_limit": 0,
    "concurrency_limit": 0,
    "budget": 0
   },
   "by_type": {}
  },
  "safety_stops": 0,
  "is_error": false,
  "num_turns": 5,
  "subtype": "success",
  "api_error_status": null,
  "result": "I fixed all five reported bugs in `ttlcache.py`, plus one the report didn't mention. The constructor and method names are unchanged. I added 8 tests in `test_ttlcache.py`, and all of them pass. pytest isn't installed here and there's no network, so I ran them with a small plain-Python runner; `pytest test_ttlcache.py` will work wherever pytest is available.\n\n**What was wrong:**\n1. **Recently-read keys got evicted:** `set` removed the most recently used entry instead of the least. It now removes the least recently used, and `get` on a live key moves it to most-recently-used (it never did before).\n2. **Overwriting didn't refresh LRU position:** assigning to an existing key in an `OrderedDict` keeps its old place. `set` now moves the key to the most-recent end, and the TTL is reset.\n3. **Entries were still returned at their deadline:** the check was `>` and is now `>=`, so a ttl=10 entry set at t=0 is gone at t=10. Expired entries are also deleted when `get` finds them; before, they just stayed in the cache.\n4. **Expired keys showed up in `len()` / `in`:** `len()` now removes expired entries first, and `in` checks the deadline (and drops the entry if it has expired).\n5. **`purge()` crashed:** it deleted from the dict while looping over it. It now collects the expired keys first, deletes them, and returns how many were removed. Before, it returned nothing.\n6. **ttl \u2264 0 (not in the report):** this stored an entry that was already expired. It now stores nothing and removes any existing entry for that key.\n\n**One choice of mine you may want to change:** when the cache goes over `maxsize`, `set` first removes expired entries and only evicts a live entry if it's still over the limit. Expired entries don't count towards the size anyway, so this avoids evicting a live key in their place. The cost is a full scan, but only on a `set` that pushes the cache over the limit. If you'd rather have plain LRU eviction, delete the `self.purge()` call in `set`.",
  "ttft_ms": 3222,
  "type": "result",
  "duration_ms": 39197,
  "uuid": "[REDACTED]",
  "ttft_stream_ms": 1956,
  "time_to_request_ms": 244,
  "first_content_frame_ms": 1956,
  "queued_turn_count": 0,
  "result_index": 0
 }
]

Get new runs and ranking changes weekly