Skip to content

Conversation

dbschmigelski
Copy link
Member

@dbschmigelski dbschmigelski commented Oct 6, 2025

Description

In our docs we call out a Custom Node Type which can be used to implement deterministic nodes. But this requires customers to know about stop_reason and construct the DEEPLY nested return type of MultiAgentResult which uses NodeResult which uses AgentResult - this is too in the weeds in my opinion.

To improve developer experience, we will vend a FunctionNode which handles the hard part.

new DX

def deterministic_function(task, invocation_state=None, **kwargs):
    ...



# Create nodes
agent = Agent()
function_node = FunctionNode(deterministic_function, "deterministic_function")
# Build graph
builder = GraphBuilder()
builder.add_node(agent, "agent")
builder.add_node(function_node, "deterministic_function")

The alternative here is to vend an abstract class. I am on the fence about this. An abstract class feels more "correct" but the DX of simply providing the method feels easiest to me. Very open to discussing.

Related Issues

N/A

Documentation PR

pending

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dbschmigelski dbschmigelski marked this pull request as ready for review October 6, 2025 22:49
Copy link
Member

@Unshure Unshure left a comment

Choose a reason for hiding this comment

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

Agree with the devex of this approach, it is very clean. As for a abstract class, I think we can migrate to that if customers want it in the future, but good with this for now.

pgrayy
pgrayy previously approved these changes Oct 9, 2025
JackYPCOnline
JackYPCOnline previously approved these changes Oct 9, 2025
zastrowm
zastrowm previously approved these changes Oct 9, 2025
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

❌ Patch coverage is 97.87234% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strands/multiagent/function_node.py 97.82% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants