Skip to content

feat(hindsight): add configurable HINDSIGHT_TIMEOUT env var#13067

Closed
tekgnosis-net wants to merge 2 commits into
NousResearch:mainfrom
tekgnosis-net:feat/hindsight-timeout-config
Closed

feat(hindsight): add configurable HINDSIGHT_TIMEOUT env var#13067
tekgnosis-net wants to merge 2 commits into
NousResearch:mainfrom
tekgnosis-net:feat/hindsight-timeout-config

Conversation

@tekgnosis-net

@tekgnosis-net tekgnosis-net commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a configurable HINDSIGHT_TIMEOUT environment variable to the Hindsight memory provider, replacing the previously hardcoded client timeout behavior.

What Changed

Initial commit (6741b6c)

  • Introduces _DEFAULT_TIMEOUT = 120 and documents HINDSIGHT_TIMEOUT
  • Persists a timeout value in Hindsight provider config and exposes it via get_config_schema()
  • Applies the configured timeout when constructing the Hindsight cloud client

Fix commit (0660c8f)

  • The initial fix only configured the HTTP client timeout. The _run_sync() coroutine wrapper was still hardcoded to _DEFAULT_TIMEOUT (120s).
  • Added HindsightMemoryProvider._run_sync(coro) instance method that delegates to the module-level function with timeout=self._timeout
  • All 9 call sites updated from _run_sync(...) to self._run_sync(...)
  • Both the HTTP client timeout AND the coroutine execution timeout now use the configured HINDSIGHT_TIMEOUT value

Related Issues

How to Test

  1. Set HINDSIGHT_TIMEOUT=180 in ~/.hermes/.env
  2. Run hindsight_reflect with a query that takes >120s — it should now use the configured timeout
  3. Run the test suite: pytest tests/plugins/memory/test_hindsight_provider.py -v (all 46 tests pass)

Platforms Tested

  • Linux (Ubuntu 24.04)

Notes

  • Default is 120s (up from the previous hardcoded 30s)
  • The timeout is written to ~/.hermes/hindsight/config.json and read on initialization
  • This survives upgrades because the env var is external to source code

The Hindsight Cloud API can take 30-40 seconds per request. The
hardcoded 30s timeout was too aggressive and caused frequent
timeout errors. This patch:

1. Adds HINDSIGHT_TIMEOUT environment variable (default: 120s)
2. Adds timeout to the config schema for setup wizard visibility
3. Uses the configurable timeout in both _run_sync() and client creation
4. Reads from config.json or env var, falling back to 120s default

This makes the timeout upgrade-proof — users can set it via env var
or config without patching source code.

Signed-off-by: Kumar <kumar@tekgnosis.net>
Copilot AI review requested due to automatic review settings April 20, 2026 14:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a configurable timeout for the Hindsight memory provider to better accommodate slower Hindsight Cloud API operations, replacing the previously hardcoded client timeout behavior.

Changes:

  • Introduces _DEFAULT_TIMEOUT = 120 and documents HINDSIGHT_TIMEOUT.
  • Persists a timeout value in Hindsight provider config and exposes it via get_config_schema().
  • Applies the configured timeout when constructing the Hindsight cloud client.
Comments suppressed due to low confidence (1)

plugins/memory/hindsight/init.py:88

  • The coroutine execution timeout is still fixed to _DEFAULT_TIMEOUT because all call sites use _run_sync(...) without passing a timeout. This means users who set HINDSIGHT_TIMEOUT higher can still hit future.result(timeout=...) timeouts even if the HTTP client's request timeout is increased. Consider plumbing the configured provider timeout into these _run_sync calls (or making _run_sync derive its default from the provider’s resolved timeout) so both layers are consistent.
def _run_sync(coro, timeout: float = _DEFAULT_TIMEOUT):
    """Schedule *coro* on the shared loop and block until done."""
    loop = _get_loop()
    future = asyncio.run_coroutine_threadsafe(coro, loop)
    return future.result(timeout=timeout)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/memory/hindsight/__init__.py
Comment thread plugins/memory/hindsight/__init__.py
Comment thread plugins/memory/hindsight/__init__.py
…rations

The previous commit added HINDSIGHT_TIMEOUT as a configurable env var,
but _run_sync still used the hardcoded _DEFAULT_TIMEOUT (120s). All
async operations (recall, retain, reflect, aclose) now go through an
instance method that uses self._timeout, so the configured value is
actually applied.

Also: added backward-compatible alias comment for the module-level
function.
@tekgnosis-net

Copy link
Copy Markdown
Contributor Author

The coroutine execution timeout issue is now fixed.

What changed:

  • Added HindsightMemoryProvider._run_sync() instance method that delegates to the module-level function with timeout=self._timeout
  • All call sites updated from _run_sync(...) to self._run_sync(...)
  • Both the HTTP client timeout AND the coroutine execution timeout now use the configured HINDSIGHT_TIMEOUT value

Files changed:

  • plugins/memory/hindsight/init.py - instance method + 9 call site updates

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/plugins Plugin system and bundled plugins labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #10045 — both add configurable HINDSIGHT_TIMEOUT env var to the Hindsight memory provider.

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #10045 — both add configurable HINDSIGHT_TIMEOUT env var to the Hindsight memory provider.

@nicoloboschi nicoloboschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Hindsight plugin hardcoded 30s timeout causes hindsight_reflect to fail

4 participants