You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ComponentTool(component=AnswerJoiner()) fails at construction with SchemaGenerationError. The cause is an unresolved forward reference to the nested class ExtractedAnswer.Span on ExtractedAnswer.document_offset / context_offset.
AnswerJoiner is the standard multi-branch answer merge component, so the documented ComponentTool → Agent path cannot expose answer joining to an LLM.
Environment
haystack-ai==3.2.0
Python 3.13 / pydantic v2
Minimal repro
fromhaystack.components.joinersimportAnswerJoinerfromhaystack.toolsimportComponentToolfromhaystack.tools.errorsimportSchemaGenerationErrortry:
ComponentTool(component=AnswerJoiner())
print("UNEXPECTED: schema built")
exceptSchemaGenerationErrorase:
print(type(e).__name__, e)
# Failed to create JSON schema for the run method of Component 'AnswerJoiner'# underlying: PydanticUserError … define Span, then call run.model_rebuild()
Expected
ComponentTool(AnswerJoiner()) succeeds (or skips unschematizable nested fields with a clear warning), matching other joiners that can be wrapped.
Actual
SchemaGenerationError("Failed to create JSON schema for the run method of Component 'AnswerJoiner'") caused by unresolved Span.
Root cause (pointer)
AnswerJoiner.run takes Variadic[list[GeneratedAnswer | ExtractedAnswer]]. ExtractedAnswer annotates offsets as Optional["Span"] where Span is the nested class ExtractedAnswer.Span. Pydantic schema generation for the tool wrapper does not rebuild / resolve that forward ref.
Suggested fix direction
Ensure ExtractedAnswer / nested Span is fully defined before schema generation (model_rebuild()), or qualify the annotation as Optional[ExtractedAnswer.Span] / a module-level Span type so tool wrapping succeeds.
@michaelkillgta thanks for opening! I wanted to ask could you tell a use case where you wanted to use the AnswerJoiner as a ComponentTool in the Agent? I can't currently think of a good use case for this as a tool.
Thanks @sjrl — fair question. I don’t have a strong production case for exposing AnswerJoiner itself as an Agent tool. I hit this while checking which built-in components fail under ComponentTool, and AnswerJoiner is the obvious multi-branch answer merge.
So the report is really about schema generation (ExtractedAnswer.Span forward ref), not a product need for “join answers as a tool.” Happy to close this as not-a-priority for Agent tooling if you’d rather keep Joiners pipeline-only — or I can leave it open as a ComponentTool footgun for anyone who wraps answer types. Prefer which?
Thanks @sjrl — fair question. I don’t have a strong production case for exposing AnswerJoiner itself as an Agent tool. I hit this while checking which built-in components fail under ComponentTool, and AnswerJoiner is the obvious multi-branch answer merge.
So the report is really about schema generation (ExtractedAnswer.Span forward ref), not a product need for “join answers as a tool.” Happy to close this as not-a-priority for Agent tooling if you’d rather keep Joiners pipeline-only — or I can leave it open as a ComponentTool footgun for anyone who wraps answer types. Prefer which?
Thanks for the extra context. Given that there isn’t a clear Agent use case for AnswerJoiner at the moment, I’d prefer to close the issue for now rather than treat this as a priority for ComponentTool.
The schema-generation issue is still useful to have identified though, especially if similar answer types show up in more relevant tooling paths later. We can always revisit it if that happens.
Activity
sjrl commentedon Sep 25, 2026
@michaelkillgta thanks for opening! I wanted to ask could you tell a use case where you wanted to use the AnswerJoiner as a ComponentTool in the Agent? I can't currently think of a good use case for this as a tool.
testbeeai-ui commentedon Sep 25, 2026
Thanks @sjrl — fair question. I don’t have a strong production case for exposing
AnswerJoineritself as an Agent tool. I hit this while checking which built-in components fail underComponentTool, andAnswerJoineris the obvious multi-branch answer merge.So the report is really about schema generation (
ExtractedAnswer.Spanforward ref), not a product need for “join answers as a tool.” Happy to close this as not-a-priority for Agent tooling if you’d rather keep Joiners pipeline-only — or I can leave it open as a ComponentTool footgun for anyone who wraps answer types. Prefer which?michaelkillgta commentedon Sep 25, 2026
Thanks @sjrl — fair question. I don’t have a strong production case for exposing
AnswerJoineritself as an Agent tool. I hit this while checking which built-in components fail underComponentTool, andAnswerJoineris the obvious multi-branch answer merge.So the report is really about schema generation (
ExtractedAnswer.Spanforward ref), not a product need for “join answers as a tool.” Happy to close this as not-a-priority for Agent tooling if you’d rather keep Joiners pipeline-only — or I can leave it open as a ComponentTool footgun for anyone who wraps answer types. Prefer which?sjrl commentedon Sep 25, 2026
Thanks for the extra context. Given that there isn’t a clear Agent use case for
AnswerJoinerat the moment, I’d prefer to close the issue for now rather than treat this as a priority forComponentTool.The schema-generation issue is still useful to have identified though, especially if similar answer types show up in more relevant tooling paths later. We can always revisit it if that happens.
michaelkillgta commentedon Sep 25, 2026
Thanks @sjrl — agreed on closing for now. Glad the schema-generation footgun is on the record if similar types show up on a hotter path later.