Skip to content

Conversation

@kiranandcode
Copy link
Contributor

@kiranandcode kiranandcode commented Dec 26, 2025

Fixes #447
On the meeting on Tuesday we discussed a few solutions, I believe this was the one we agreed would be the minimal fix?

#447 (comment)

Adds optional parameter recursive (default value is False) to Template.define and field is_recursive to Templates.

When constructing tools, if the Template is not recursive, then it removes itself from the tuple of tools.

This restores previous functionality, and in cases where users require direct recursive calls, they can call Template.define(recursive=True)

Copy link
Contributor

@eb8680 eb8680 left a comment

Choose a reason for hiding this comment

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

Rather than adding a recursive parameter to Template.define, can we expose this behavior via a special effectful.ops.types.Annotation that is applied to a return type and could in principle desugar to a more verbose but equivalent effect type, even if it's not (yet?) implemented that way?

class _IsRecursiveAnnotation(effectful.ops.types.Annotation): ...

IsRecursive = _IsRecursiveAnnotation()

...

@Tool.define
def search_web(query: str) -> str: ...

@Template.define
def research(topic: str) -> typing.Annotated[str, IsRecursive]: ...

@eb8680
Copy link
Contributor

eb8680 commented Dec 29, 2025

Also needs to be updated following #424

@kiranandcode
Copy link
Contributor Author

Rather than adding a recursive parameter to Template.define, can we expose this behavior via a special effectful.ops.types.Annotation that is applied to a return type and could in principle desugar to a more verbose but equivalent effect type, even if it's not (yet?) implemented that way?

class _IsRecursiveAnnotation(effectful.ops.types.Annotation): ...

IsRecursive = _IsRecursiveAnnotation()

...

@Tool.define
def search_web(query: str) -> str: ...

@Template.define
def research(topic: str) -> typing.Annotated[str, IsRecursive]: ...

gotcha, can do!

Also needs to be updated following #424

gotcha! rebasing.

@kiranandcode
Copy link
Contributor Author

Done!

Copy link
Contributor

@eb8680 eb8680 left a comment

Choose a reason for hiding this comment

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

Thanks, just a couple nits

@eb8680 eb8680 merged commit 05b28ef into staging-llm Dec 31, 2025
6 checks passed
@eb8680 eb8680 deleted the kg-recursive-calls branch December 31, 2025 15:59
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.

Template.define context inclusion includes method leading to infinite tool calls

4 participants