The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): preserve eventless follow-up channel prompt
JoaoMarcos445646c1090add
diff --git a/gateway/run_turn.py b/gateway/run_turn.pyindex b0efe8d0a68..2cf5c672d78 100644--- a/gateway/run_turn.py+++ b/gateway/run_turn.py@@ -3830,7 +3830,10 @@ class GatewayTurnMixin:updated_history = result.get("messages", history)next_source, next_message, next_session_key = source, pending, session_key# message_type is carried into the recursive call so queued voice turns can stream TTS.- next_message_id = next_channel_prompt = next_message_type = None+ next_message_id = next_message_type = None+ # Plain-text interrupt/steer follow-ups have no MessageEvent of their own,+ # so they continue with the effective channel prompt of the turn they follow.+ next_channel_prompt = turn_ctx.channel_prompt# The raw inbound id keys the delivery-ledger obligation for the follow-up's own final send,# distinct from the reply anchor above (None in forum topics). Carry it or two chained# topic turns with the same text would collide on one obligation id (queued-final-ledger).diff --git a/tests/gateway/test_internal_event_pin_wiring.py b/tests/gateway/test_internal_event_pin_wiring.pyindex fc4f966955a..c65b84963e0 100644--- a/tests/gateway/test_internal_event_pin_wiring.py+++ b/tests/gateway/test_internal_event_pin_wiring.py@@ -207,3 +207,50 @@ async def test_internal_event_keeps_channel_prompt_and_parent_override(monkeypateph = [_effective_ephemeral(runner, kw) for kw in calls]assert "Channel hint." in eph[0] and "Parent persona." in eph[0]assert eph[0] == eph[1] == eph[2], "internal event toggled the channel ephemeral components"+++async def test_eventless_followup_inherits_effective_channel_prompt(monkeypatch):+ runner = _make_runner(monkeypatch)+ calls: list[dict] = []+ _capture(runner, calls)+ runner._run_agent_deliver_first_response = AsyncMock()+ runner._refresh_agent_cache_message_count = AsyncMock()++ adapter = MagicMock()+ adapter.get_pending_message.return_value = None+ adapter._active_sessions = {}+ source = _human_source()+ baseline = {"source": source, "context_prompt": "ctx", "channel_prompt": "Channel hint."}++ cases = (+ {"final_response": "done", "messages": [], "pending_steer": "follow up"},+ {+ "final_response": "done",+ "messages": [],+ "interrupt_message": "follow up",+ "interrupted": True,+ },+ )+ for result in cases:+ pending_event, pending = await runner._run_agent_drain_pending(result, adapter, source, KEY)+ assert pending_event is None+ assert pending == "follow up"++ turn_ctx = TurnContext(+ source=source,+ context_prompt="ctx",+ channel_prompt="Channel hint.",+ session_key=KEY,+ session_id="sess-wiring",+ run_generation=1,+ history=[],+ )+ await runner._run_agent_queued_followup(+ turn_ctx, adapter, pending, pending_event, "done", result, None+ )++ assert [call["channel_prompt"] for call in calls] == ["Channel hint.", "Channel hint."]+ expected = _effective_ephemeral(runner, baseline)+ assert all(_effective_ephemeral(runner, call) == expected for call in calls)+