Skip to content
Open
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
7 changes: 6 additions & 1 deletion amplifier_core/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,20 @@ def _merge_inject_context_results(self, results: list[HookResult]) -> HookResult
result.context_injection for result in results if result.context_injection
)

# Use settings from first result (role, ephemeral, suppress_output)
# Use settings from first result (role, ephemeral, suppress_output).
# Preserve append_to_last_tool_result if ANY result requested it -
# dropping this flag causes the orchestrator to skip the tool-result
# merge path and create consecutive same-role messages instead.
first = results[0]
any_append = any(r.append_to_last_tool_result for r in results)

return HookResult(
action="inject_context",
context_injection=combined_content,
context_injection_role=first.context_injection_role,
ephemeral=first.ephemeral,
suppress_output=first.suppress_output,
append_to_last_tool_result=any_append,
)

async def emit_and_collect(
Expand Down