We should take advantage of the type inference engine in internals/unification.py to allow Templates and Tools to be polymorphic:
@Template.define
def generate_similar[T](examples: Sequence[T]) -> T:
"""Generate another instance of the items in {examples}"""
...
@Tool.define
def extend_sequence[T](examples: Sequence[T], new_example: T) -> Sequence[T]:
"""Extends the input sequence with a new example"""
...
Here generate_similar can infer its type variable and enforce the resulting concrete type constraint, and extend_sequence can similarly have the type constraint on its arguments enforced immediately when a tool call to extend_sequence is generated.