Skip to content

Conversation

@dsfaccini
Copy link
Collaborator

@dsfaccini dsfaccini commented Dec 9, 2025

Closes #3390

  • adds support for @agent.toolset decorator

assert output == 'Dynamic result received'


# Test with explicit id parameter
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather test the new id arg where we test the @agent.toolset decorator, since this part is not Temporal-specific

pytest.fail('TemporalDynamicToolset not found in toolsets')


async def test_dynamic_toolset_get_tools_outside_workflow():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test this by running the same agent we created earlier outside of a workflow, and checking that we still get the correct result

pytest.fail('TemporalDynamicToolset not found')


async def test_dynamic_toolset_call_tool_outside_workflow():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

pytest.fail('TemporalDynamicToolset not found')


async def test_dynamic_toolset_tool_not_found_in_activity():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with pragma: no cover for this UserError like we have here:

try:
tool = (await toolset.get_tools(ctx))[name]
except KeyError as e: # pragma: no cover
raise UserError(
f'Tool {name!r} not found in toolset {self.id!r}. '
'Removing or renaming tools during an agent run is not supported with Temporal.'
) from e

dsfaccini and others added 3 commits December 10, 2025 17:25
Core changes:
- DynamicToolset: convert to plain class with custom __init__, add copy()
- TemporalDynamicToolset: use _call_tool_in_activity shared method
- TemporalFunctionToolset: use _call_tool_in_activity shared method
- temporalize_toolset: move DynamicToolset import to top

Test changes:
- Add test_fastmcp_dynamic_toolset_in_workflow for MCP lifecycle in DynamicToolset
- Add test_dynamic_toolset_id and test_agent_toolset_decorator_id
- Update test_visit_and_replace for DynamicToolset plain class

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@agent.toolset decorator (DynamicToolset) does not work with Temporal

2 participants