Skip to content

Task-scoped cache keys exceed prompt_cache_key maximum length #1007

Description

@cristeaadrian

OpenCodeReview Version

open-code-review v1.9.7 (f269d0ce0) darwin/arm64

Operating System

macOS (Apple Silicon)

Installation Method

npm (global)

LLM Provider

Other OpenAI-compatible endpoint

Bug Description

SessionTaskKey builds prompt-cache affinity keys in this format:

<session UUID>-<task type>-<scope hash>

When {ocr_session_key} is mapped to OpenAI's prompt_cache_key, some task names produce keys longer than the API's 64-character maximum.

plan_task and main_task happen to fit. Later phases such as review_filter_task, memory_compression_task, and re_location_task exceed the limit. A review can therefore complete its main analysis and then fail during filtering, relocation, compression, or summary work.

This behavior was introduced by the task-scoped session-affinity implementation in #332.

Steps to Reproduce

  1. Configure an OpenAI-compatible provider with:
{
  "extra_body": {
    "prompt_cache_key": "{ocr_session_key}"
  }
}
  1. Run a review that produces at least one comment, causing review_filter_task to execute.
  2. Observe the provider reject the generated cache key.

A UUID session identifier, review_filter_task, and the current 16-character scope hash produce a 72-character key.

Expected Behavior

Every generated prompt-cache affinity key should satisfy OpenAI's 64-character limit while remaining deterministic and unique per task conversation.

One option is to preserve readable short keys and return a SHA-256 hex digest whenever a derived key would exceed the limit.

Tests should cover every OCR task type and assert that generated keys never exceed the provider-safe maximum.

Logs / Error Output

Invalid 'prompt_cache_key': string too long.
Expected a string with maximum length 64,
but got a string with length 72 instead.

Additional Context

The provider retries this validation failure, then marks the review-filter task and review item as failed. There were no matching open issues for this failure mode when this report was created.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions