Repository navigation
fix(gateway): stop synthetic goal/heartbeat turns from stomping channel_pin #126155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
abe539a
0340700
10df6fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2076,7 +2076,8 @@ async def _hmwa_prepare_turn(self, event, source, session_entry, session_key, _q | |
| # The context prompt render is pinned per session, keyed by a hash of the renderer inputs, so | ||
| # the system prompt cannot drift turn-over-turn; a miss (thread rename, /sethome) re-renders. | ||
| context_prompt = self._pinned_session_context_prompt( | ||
| context, _redact_pii, session_key, internal=event.internal, | ||
| context, _redact_pii, session_key, | ||
| internal=event.internal or getattr(event, "inherit_channel_pin", False), | ||
| ) | ||
|
|
||
| # Per-turn notes ride the user message via the api_content sidecar, NOT context_prompt | ||
|
|
@@ -2195,9 +2196,11 @@ async def _handle_message_with_agent(self, event, source, _quick_key: str, run_g | |
| # Admission/typing is not execution. All routing, authorization and | ||
| # turn preparation gates have passed when the agent runner is entered. | ||
| event._heartbeat_execution_started = True | ||
| # Internal events reuse the last human turn's channel inputs (see _pinned_channel_inputs). | ||
| # Internal and pin-inheriting synthetic events reuse the last human turn's channel | ||
| # inputs (see _pinned_channel_inputs). | ||
| _turn_channel_prompt, _turn_source = self._pinned_channel_inputs( | ||
| session_key, event.channel_prompt, source, internal=event.internal, | ||
| session_key, event.channel_prompt, source, | ||
| reuse_pin=event.internal or getattr(event, "inherit_channel_pin", False), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocking: this reuses only the channel pin. Earlier in the same handler, |
||
| ) | ||
| agent_result = await self._run_agent( | ||
| message=message_text, context_prompt=prepared.context_prompt, history=history, source=_turn_source, | ||
|
|
@@ -3867,7 +3870,8 @@ async def _run_agent_queued_followup( | |
| next_message_id = self._reply_anchor_for_event(pending_event) | ||
| next_inbound_id = str(pending_event.message_id) if getattr(pending_event, "message_id", None) else None | ||
| next_channel_prompt, next_source = self._pinned_channel_inputs( | ||
| next_session_key, pending_event.channel_prompt, next_source, internal=pending_event.internal, | ||
| next_session_key, pending_event.channel_prompt, next_source, | ||
| reuse_pin=pending_event.internal or getattr(pending_event, "inherit_channel_pin", False), | ||
| ) | ||
| next_message_type = getattr(pending_event, "message_type", None) | ||
| else: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the channel half only.
_hmwa_prepare_turnstill calls_pinned_session_context_prompt(..., internal=event.internal), and because_synthetic_prompt_eventstripsmessage_id(a_ephemeral_change_keyinput on Discord), the session-context pin still flips. Live on this head merged onto main: context bytes1238 → 1122 → 1238across human → synthetic → human whilechannel_promptstays'Channel hint.'. Pass the sameinternal or inherit_channel_pindecision to_pinned_session_context_prompt, and assert full ephemeral byte-equality in the test.