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 @@ -88,8 +88,17 @@ async def wrapper(self: Any, *args: Any, **kwargs: Any) -> AgentRunResult[Any]:
if tools_ref:
instructions = tools_ref + "\n" + instructions

# Map parameters
all_args = args
# Map parameters — merge kwargs into positional order
if kwargs:
import inspect as _inspect

sig = _inspect.signature(fn)
params = [p for p in sig.parameters if p != "self"]
all_args = tuple(
kwargs.get(p, args[i] if i < len(args) else None) for i, p in enumerate(params)
)
else:
all_args = args
mapped = mapper.map_arguments(all_args)
session = mapper.find_session(all_args)

Expand Down Expand Up @@ -183,8 +192,19 @@ async def wrapper(self: Any, *args: Any, **kwargs: Any) -> ConsensusRunResult[An
if tools_ref:
instructions = tools_ref + "\n" + instructions

mapped = mapper.map_arguments(args)
session = mapper.find_session(args)
# Map parameters — merge kwargs into positional order
if kwargs:
import inspect as _inspect

sig = _inspect.signature(fn)
params = [p for p in sig.parameters if p != "self"]
all_args = tuple(
kwargs.get(p, args[i] if i < len(args) else None) for i, p in enumerate(params)
)
else:
all_args = args
mapped = mapper.map_arguments(all_args)
session = mapper.find_session(all_args)
agent_name = name or f"{self.__class__.__name__}:{fn.__name__}"
effective_max_turns = max_turns or (8 if resolved_tools else 1)

Expand Down
22 changes: 22 additions & 0 deletions packages/agentic-workflows/tests/unit/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,28 @@ async def spy(config: AgentConfig[str], run_config: AgentRunConfig) -> AgentRunR
assert "session" not in input_json
assert input_json["input_text"] == "some text"

async def test_kwargs_are_mapped_to_input_json(self, prompts_dir: str) -> None:
"""When the decorated method is called with keyword arguments, they
should still appear in the input JSON sent to the agent service."""
Cls = _make_workflow_class(prompts_dir)
service = AiAgentServiceLocal.get_instance()

captured: list[AgentRunConfig] = []
original = service.create_and_run

async def spy(config: AgentConfig[str], run_config: AgentRunConfig) -> AgentRunResult[str]:
captured.append(run_config)
return await original(config, run_config)

service.create_and_run = spy # type: ignore[assignment]

wf = Cls(service)
await wf.test_method(input_text="kwarg value")

assert len(captured) == 1
input_json = json.loads(captured[0].input)
assert input_json["input_text"] == "kwarg value"

async def test_passes_model_override(self, prompts_dir: str) -> None:
Cls = _make_workflow_class(prompts_dir)
service = AiAgentServiceLocal.get_instance()
Expand Down
16 changes: 8 additions & 8 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.