Repository navigation
Ground ids the application wrote into a chat's opening message - #4269
Merged
Merged
Conversation
Contributor
Author
|
Correction to the limits note: the full-run failure of |
Contributor
Author
|
Merge queue: #4269 was taken out of the queue — the merge gate failed on it, on top of main. Reproduce by merging or rebasing |
The fabricated-id guard grounds ids from tool results and system records only, so a reply linking a type the bound chat's own opening message linked (for example the type a custom type extends, named by its hyphenated id) was replaced by the confirmation request. The daemon now passes the application-written opening (the assistant messages before the user's first) to the session, which grounds the ids in it. Assistant messages after the user's first stay ungrounded. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mstomar125
force-pushed
the
fix/4245-opening-ids-grounded
branch
from
November 13, 2026 08:04
3945549 to
a61f4e5
Compare
3 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.
Refs #4245
Root cause
The fabricated-id guard (
agent_loop.rs, final-reply path) replaces a reply with the confirmation request when it names anodespace://id that is not insession.grounded_node_uris. That set is fed by tool results, system records, resolved entities, and the pinned-nodes record (which grounds the chat's own node). It is not fed by the message a bound chat is opened with (bound_chat.rs, an Assistant-role message the application writes). That opening links the node itself and, for a type, the type it extends and the types that declare inherited fields. Only the chat's own node is covered, via the pinned-nodes record. A parent/owner type named by a hyphenated id (for examplenodespace://software-project) is not grounded and the plain-type-name unlink repair does not cover it, so a correct reply linking it became "I'd like to help with that. Could you confirm...".How app-written is told apart from model-written
ChatMessagecarries no provenance, so the history alone cannot say. The daemon reads the stored chat, where order does: a model reply answers a user message, so no model message can precede the user's first. The assistant messages before the user's first message are the application's opening (ADR-090 section 3;prior_turns_from_historyalready uses the same rule to leave it out).application_opening_texttakes exactly those messages and nothing later; the daemon passes the text to the session viaground_session_opening_message, which grounds only the ids in it.with_historyis unchanged: an Assistant message in a starting history is still not grounded by being there.Fix
AgentSession::ground_app_written_text+LocalAgentService::ground_session_opening_message(agent).application_opening_textand the call in the ai-chat turn path (daemon).Tests (all deterministic, stub/mock engines)
a_reply_linking_the_id_the_opening_message_linked_is_kepta_fabricated_id_is_still_refused_after_the_opening_is_grounded(invented id in the same reply as a real opening link is still refused)an_id_the_model_wrote_earlier_is_not_grounded_by_the_history(guard regression)a_type_chats_reply_may_link_the_parent_its_opening_message_linked(real bound type chat throughmaybe_handle_ai_chat_node)only_messages_before_the_users_first_are_the_applications_openingMutation results (each reverted afterwards)
ground_app_written_textmade a no-op: the "kept" test fails (reply replaced); the daemon e2e also fails (reply is the canned confirmation).if false &&): the e2e test fails with the canned confirmation.with_historyalso grounds Assistant messages:an_id_the_model_wrote_earlier...fails.ground_app_written_textalso grounds an invented id: the fabricated-id test fails.application_opening_textwithout the take_while (all assistant messages): the unit test fails.Honest limits
tests/it/live_typed_question_routing.rs) builds its session without the pinned-nodes record, so the type's own linknodespace://software-projectis ungrounded there but IS grounded in the app. The live Q1 canned reply is therefore partly a harness artefact; in the app the real gap is links to other ids the opening wrote (parent/owner types). This PR fixes that gap; the harness mismatch is not changed here.cargo test -p nodespace-agent --libonce faileda_held_update_nodes_schema_decision_is_the_nodes_type_and_enforcedin the full run; it passes alone on this branch and on main (looks order/flake dependent, untouched code). Daemon lib: 496 passed. fmt and clippy -D warnings clean. The pre-push hook is lint-only.🤖 Generated with Claude Code