Skip to content
Open
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
1 change: 1 addition & 0 deletions mellea/stdlib/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ async def aact(
pre_exec_payload = ComponentPreExecutePayload(
component_type=_component_type_name,
action=action,
context_view=context.view_for_generation(),
requirements=requirements or [],
model_options=model_options or {},
format=format,
Expand Down
23 changes: 23 additions & 0 deletions test/plugins/test_hook_call_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,29 @@ async def recorder(payload: Any, ctx: Any) -> Any:
await aact(action, ctx, backend, strategy=None)
assert observed[0].component_type == "Instruction"

async def test_component_pre_execute_has_context_view(self) -> None:
"""COMPONENT_PRE_EXECUTE payload.context_view is populated."""
from mellea.stdlib.components import Instruction
from mellea.stdlib.context import ChatContext
from mellea.stdlib.functional import aact

observed: list[Any] = []

@hook("component_pre_execute")
async def recorder(payload: Any, ctx: Any) -> Any:
observed.append(payload)
return None

register(recorder)
backend = _MockBackend()
ctx = ChatContext().add(CBlock("previous turn"))
action = Instruction("Context check")

await aact(action, ctx, backend, strategy=None)
assert observed[0].context_view is not None
assert len(observed[0].context_view) == 1
assert observed[0].context_view[0].value == "previous turn"

async def test_component_post_success_fires_in_aact(self) -> None:
"""COMPONENT_POST_SUCCESS fires in aact() after successful generation."""
from mellea.stdlib.components import Instruction
Expand Down
Loading