reflect: a single OutputTooLongError re-runs the whole task (local embed+rerank included) up to 3x
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start in engine/memory_engine.py at _is_non_retryable_task_error() around line 1814, then trace the reflect and consolidation retry paths cited in the issue. Check how OutputTooLongError and provider finish_reason="length" are represented, and run the relevant retry tests. Done means deterministic output length failures do not repeat the costly task work, with tests covering reflect and consolidation behavior.
Written by the indexing model from the issue text.
Description
Summary
On hindsight-api 1.3.1 a reflect task that fails with OutputTooLongError (raised at scope=reflect_tool_call by an OpenAI-compatible provider) is classified as retryable, and the worker retries the whole task — not the failed LLM call. Because the reflect agent drives recall / expand / reflect_tool_call and every one of those runs embeddings + a cross-encoder rerank in-process, each retry re-pays the entire local inference cost. With worker_max_retries=3 and a 60 s backoff, one deterministic provider-side token-cap error becomes ~3× the retrieval work.
Observed
Output generation failed: API error: Output generation exceeded token limits: ... (scope=reflect_tool_call)
Retryable error, scheduling retry in 60s (attempt 1/3)
Consolidation shows the same shape with an unbounded budget:
Consolidation failed with transient error; retrying in Ns (indefinite retry)
Cost when the models run locally: py-spy on the same process attributes ~49% of samples to the cross-encoder (ModernBERT) and ~39% to the bi-encoder (BERT) during these windows. A single failed reflect task is roughly a minute of embed+rerank on 12 cores, and it is paid three times.
Why this looks wrong
OutputTooLongErroris a function of (prompt, model), exactly like the cases already treated as deterministic — e.g.ProviderContentPolicyErroratengine/memory_engine.py:1837, justified with "re-running the task feeds the same chunk to the same model and earns the same refusal"._is_non_retryable_task_error()(engine/memory_engine.py:1814) does not includeOutputTooLongError.- Retry granularity is the task. The retrieval half of the task cannot produce a different answer on the second attempt, so re-running it is pure CPU (and, with local models, the dominant cost).
consolidation's indefinite retry (engine/memory_engine.py:5555-5566) has the same property: same unconsolidated rows, same embedding work, per attempt.
Asks
- Classify
OutputTooLongError(and providerfinish_reason="length"mapped onto it) as non-retryable at the task level forreflect/consolidation, or at minimum fail fast after one attempt instead of three. - On retry, reuse the retrieval result — cache the
recall/expandoutput (or at least the query embeddings and rerank order) keyed by(bank, query, filters)for the retry window, so a retry only re-runs the LLM call. - Consider sending an explicit
max_completion_tokensfor reflect tool calls.DEFAULT_REFLECT_MAX_COMPLETION_TOKENSisNone(config.py:2443), so the ceiling is whatever the provider defaults to, which makes the failure mode provider-specific and hard to bound.
Environment
hindsight-api1.3.1 (PyPI), SQLite store- Local embeddings
bge-small-en-v1.5, local rerankerhs-rerank-1 - LLM: DeepSeek v4-flash behind an OpenAI-compatible gateway
HINDSIGHT_API_RERANKER_MAX_CANDIDATES=80,HINDSIGHT_API_REFLECT_WALL_TIMEOUT=1800
- Dominant language
- Python
- Stars
- 45.2k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vectorize-io/hindsight
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vectorize-io/hindsight#7254 ·
-
Control Plane shows different calendar dates for the same occurrence in Constellation and TimelineOpencore
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
vectorize-io/hindsight#7240 · 1 comment ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vectorize-io/hindsight#7233 ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
vectorize-io/hindsight#7231 ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
vectorize-io/hindsight#7228 · 1 comment ·
All issues in vectorize-io/hindsight
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day