fleet-memory/hindsight-docs
Nicolò Boschi 77defd96e9
fix(reflect): prevent context_length_exceeded on large memory banks (#462)
* fix(reflect): prevent context_length_exceeded on large memory banks (#457)

The reflect agent's agentic loop accumulated tool-call messages across
iterations with no upper bound on token count, causing
context_length_exceeded errors on banks with 19K+ nodes.

Changes:
- Add proactive token-budget guard: before each call_with_tools, count
  accumulated message tokens via tiktoken; if >= max_context_tokens and
  evidence has been gathered, immediately synthesize from what was found
- Detect context-overflow errors specifically (_is_context_overflow_error)
  and skip the retry path — retrying after overflow only makes it worse
- Truncate context_history in build_final_prompt to a 60K-token budget
  so the fallback synthesis prompt itself cannot overflow
- Add HINDSIGHT_API_REFLECT_MAX_CONTEXT_TOKENS config (default 100000)
  wired through config.py → main.py → memory_engine → run_reflect_agent
- Tests: unit tests for helpers + mock-LLM behavior tests + an
  end-to-end integration test using a real LLM with max_context_tokens=1

* fix(reflect): derive final prompt context budget from max_context_tokens

Replace the hardcoded _FINAL_PROMPT_CONTEXT_BUDGET (60K tokens) with
a fraction of max_context_tokens (80%), so the fallback synthesis prompt
automatically scales with whatever context window is configured.
2026-03-02 12:03:12 +01:00
..
blog doc: 0.4.14 (#449) 2026-02-27 15:41:08 +01:00
docs fix(reflect): prevent context_length_exceeded on large memory banks (#462) 2026-03-02 12:03:12 +01:00
examples doc: fix build 2026-02-25 16:58:06 +01:00
src doc: improvements (#448) 2026-02-27 14:59:11 +01:00
static feat: observation_scopes field to drive observations granularity (#447) 2026-02-28 10:46:21 +01:00
versioned_docs doc: improvements (#448) 2026-02-27 14:59:11 +01:00
versioned_sidebars doc: improvements (#448) 2026-02-27 14:59:11 +01:00
.gitignore rename to hindsight (#2) 2025-11-25 19:28:26 +01:00
docusaurus.config.ts doc: improvements (#448) 2026-02-27 14:59:11 +01:00
package.json doc: hide next version (#226) 2026-01-29 08:46:21 +01:00
README.md rename to hindsight (#2) 2025-11-25 19:28:26 +01:00
sidebars.ts doc: improvements (#448) 2026-02-27 14:59:11 +01:00
tsconfig.json rename to hindsight (#2) 2025-11-25 19:28:26 +01:00
versions.json doc: release notes for 0.4.0 (#217) 2026-01-28 16:54:05 +01:00

Website

This website is built using Docusaurus, a modern static website generator.

Installation

npm install

Local Development

npm start

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

Build

npm run build

This command generates static content into the build directory and can be served using any static contents hosting service.

Deployment

Using SSH:

USE_SSH=true npm run deploy

Not using SSH:

GIT_USER=<Your GitHub username> npm run deploy

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the gh-pages branch.