Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two separate commits address embedded daemon reliability:
1. Avoid restarts from generated profile metadata
hindsight-embedpersists the resolved listener port asHINDSIGHT_API_PORTin the profile.env. Hermes compares that file with_build_embedded_profile_env(), which does not emit the assigned port. The extra key makes subsequent startup look like configuration drift, triggering a profile rewrite and daemon stop.Ignore only
HINDSIGHT_API_PORTin the in-memory comparison. Leave the profile file untouched when all managed settings match. Genuine model/provider/endpoint/key/idle-timeout changes still rewrite and restart; the existing unsafe-rewrite guard is unchanged.This targets the maintained integration here rather than restoring the removed bundled provider in Hermes Agent. It is independent of #4655 and does not change dependency versions.
2. Restore missing or closed stdin in the daemon child
_redirect_stdio_to_log()assumessys.stdin.fileno()is usable. Detached launchers can leave stdin unset or fd 0 closed, producingAttributeError/ValueErrorduring startup. When opening/dev/nullreuses fd 0, the old context manager also closes it again, allowing the write-only log to reuse fd 0.Restore descriptor 0 directly from
/dev/null, leave it open ifos.openreturns 0, and recreate the Python stream when missing/closed. Both branches leave fd 0 inheritable. stdout/stderr still redirect to the daemon log.Related: #4464 fixes the embed launcher by explicitly supplying
stdin=DEVNULL. This commit repairs the API child redirection itself and does not copy or replace that launcher change. It also handles closed Python streams and descriptor reuse.Verification
stop('test-daemon').uv run --frozen pytest tests -qinhindsight-integrations/hermes.test_daemonize.pytests.--noconftestto avoid unrelated database/ML fixtures; this is focused validation, not the full API suite:PYTHONPATH=hindsight-api-slim uv run --no-project \ --with pytest --with pytest-asyncio --with python-dotenv \ --with pydantic --with sqlalchemy python -m pytest \ --noconftest -o addopts='' \ hindsight-api-slim/tests/test_daemon_stdio.py \ hindsight-api-slim/tests/test_daemonize.py -qgit diff --checkpass.UV_OFFLINE=1 ./scripts/hooks/lint.sh, but stopped during dependency sync because the cache lacksrignore==0.7.6. Full monorepo lint, the full API suite, and live-daemon integration were not run for this branch.