Reflect done tool schema emits unbounded maxItems for cited-id fields; local grammar engines reject it

Open Beginner friendly
#7,254 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
ai

Research direction

Start in engine/reflect/agent.py and read _with_cited_handles, which sets maxItems on the done tool's cited ID fields. Check how the schema is built for large handle lists and how the existing tests cover those fields. Done means a retrieval with more than 256 handles no longer produces a schema rejected by the reported local grammar engine, while cited IDs remain constrained.

Written by the indexing model from the issue text.

Description

core

Since #6164 removed the llm_supports_max_items gate, _with_cited_handles in engine/reflect/agent.py always sets "maxItems": len(handles) on the done tool's cited-id fields (e.g. memory_ids). The comment says providers that reject the keyword strip it themselves. That holds for Anthropic, but not for OpenAI-compatible local servers that compile the schema into a constrained-decoding grammar and refuse it above a size limit.

With a large retrieval, the reflect request fails at the done step. Example from 1.2.1 against a local OpenAI-compatible server (Splash/oMLX):

HTTP 400: unsupported output schema: maxItems 983 at #/properties/memory_ids is above 256, the largest the output grammar enforces

The reflect then falls through to the fallback provider. In our case it also completed via split synthesis, but the primary local model never gets the final step once a bank is large enough. It happens on every run where retrieval yields more than 256 handles, so it grows with the bank.

Suggested fix (either):

  • Clamp the bound: "maxItems": min(len(handles), MAX_CITED_IDS) with a configurable cap (default 256). No realistic answer cites more than that, and the enum still constrains values.
  • Or restore a per-provider switch to omit maxItems.

We're running the clamp as a local one-line patch and it resolves the 400.

Environment: hindsight 1.2.1 (ghcr image), provider openai pointed at a local OpenAI-compatible endpoint with structured-output grammar enforcement.

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vectorize-io/hindsight

All issues in vectorize-io/hindsight

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.