fix(state): delegate and branch children no longer inherit a compressed parent's chat route (#116322, salvage #116377) - #116740
Merged
Conversation
… parent's gateway routing _INHERIT_PARENT_ROUTING_SQL copied session_key/chat_id/chat_type/thread_id/user_id/ display_name/origin_json/transport_profile onto ANY child whose parent row ended on 'compression'. A delegate or branch fork of such a parent is not that conversation's continuation, so it must not take over the route: two live rows holding one routing key lets peer recovery repoint gateway traffic into a subagent's transcript (#116322). Exclude children whose `_delegate_from` / `_branched_from` marker names the queried parent id. Value-match rather than presence: a compression continuation inherits model_config verbatim (marker included), so a presence check would misclassify it — the same idiom _NON_CONTINUATION_CHILD_FILTER_SQL already uses. Cherry-picked from #109699 (Lei-k) minus its unrelated tools/delegate_tool_dispatch.py nested-dispatch hunk; test relocated to tests/hermes_state/ where the suite now lives.
…its its route Pins the reason the exclusion matches the marker's VALUE against the parent id instead of its presence: a continuation copies model_config verbatim, so a `_branched_from` marker rides along. A presence check (#116377's variant) would leave the continuation unroutable — exactly the shape this test fails on against that branch. Salvages #109699 (@Lei-k). Supersedes #116377 (@strzhao). Co-authored-by: strzhao <strzhao@users.noreply.github.com>
૮ >ﻌ< ა ci reviewran on 945d95f — test(state): a compression continuation of a branch child st debug infoCI timingsCI timings · View report · View jobWall time 5m31s vs 6m29s (-14.9%). 5 job(s) slower, 5 faster, 2 unchanged.
|
teknium1
deleted the
fix/b0919-L05-sessions-statedb-delegate-inherit
branch
September 20, 2026 07:14
3 tasks done
4 of 6 tasks
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.
A delegate or branch child no longer takes over its parent chat's gateway routing (
session_key/chat_id/chat_type/thread_id/user_id) when that parent row has already ended on compression — only a genuine compression continuation inherits them.hermes_state_sessions.py::_INHERIT_PARENT_ROUTING_SQLnow excludes children whosemodel_config._delegate_from/_branched_fromnames the queried parent (matched by VALUE, like_NON_CONTINUATION_CHILD_FILTER_SQL, because a continuation copiesmodel_configverbatim and would otherwise be misclassified)._inherit_parent_session_metadatastates the rule for both fork kinds.SessionDB, temp db; issue's reproduction)create_session("c", source="subagent", parent_session_id="p", model_config={"_delegate_from": "p"})afterend_session("p", "compression")session_key='agent:main:telegram:dm:42',chat_id='42',user_id='u1'NULLcreate_session("cont", source="telegram", parent_session_id="p")(control)Root cause: the inheritance UPDATE gated only on the parent's
end_reason='compression'and never on the new child's fork provenance, so two live rows ended up holding one routing key (the shape behind #92859).Tests:
tests/hermes_state/test_delegate_child_routing_inheritance.py(2 invariants, both fork markers + the branch-continuation control), red onorigin/main(2 failed), green here. Focused files: that file +tests/hermes_state/test_compression_lineage_guard.py+tests/hermes_state/test_session_md_export.py.Fixes #116322
Salvages #116377 (@strzhao) — cherry-picked with authorship; the branch-continuation control test is a follow-up commit.
Dropped hunks
None.
Infographic