Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4116,6 +4116,29 @@ async def test_coordinator_auto_reject_answers_in_one_envelope(
await c.stop()


@pytest.mark.asyncio
async def test_a_padded_target_agent_reaches_its_handler(session_dir):
"""PolicyGate admits the stripped target, so the router has to route on the same name it admitted."""
c = Coordinator(session_dir, backends=_backends_silent())
try:
c.shared_state.kernel_enabled = True
await c.router.handle_intent(
"orchestration",
Intent(
type=IntentType.REQUEST,
payload={"target_agent": " kernel_agent ", "kind": "invent_brand_new_kind"},
),
)

responses = await c.bus.tail(topic="response", to_agent="orchestration")
assert responses, "the request must be answered"
# It reaches the kernel_agent arm, so it is refused for its kind rather than for its target.
assert responses[0].payload["result"]["error_class"] == "unknown_kernel_kind"
assert responses[0].from_agent == "kernel_agent"
finally:
await c.stop()


@pytest.mark.asyncio
async def test_coordinator_request_handler_exception_recorded(session_dir):
"""Handler crashes → RESPONSE.status='failed' + error_class set."""
Expand Down
2 changes: 1 addition & 1 deletion src/hyperloom/orchestrator/loop/intent_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ async def _auto_reject(self, request_msg: Message, result: dict[str, Any]) -> No

async def _handle_request(self, source: str, intent: Intent) -> None:
"""Route a REQUEST intent to its programmatic handler."""
target_agent = intent.payload["target_agent"]
target_agent = str(intent.payload["target_agent"]).strip()
kind = intent.payload["kind"]
denied = self._coord.dispatcher.sequence_denial_for_request(target_agent, kind)
if denied is not None:
Expand Down
Loading