> For the complete documentation index, see [llms.txt](/llms.txt). Every page on this site is also available as markdown at `<path>.md`.

# Unions

Discriminated-union factory for action and event schemas. `TaggedUnion(...)`
returns a Pydantic discriminated union over the `kind` field by default.

<span id="flowai_harness.unions.TaggedUnion"></span>

## `TaggedUnion`

`TaggedUnion(*models: 'type[BaseModel]', discriminator: 'str' = 'kind') -> 'Any'`

<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>models</code></td>
<td><code>type[BaseModel]</code></td>
<td>required</td>
</tr>
<tr>
<td><code>discriminator</code></td>
<td><code>str</code></td>
<td><code>'kind'</code></td>
</tr>
</tbody>
</table>

<p><strong>Returns:</strong> <code>Any</code></p>

Create a Pydantic discriminated union over `discriminator`.

Models may use either Pydantic's native `Literal[...]` discriminator field
or the public Harness shorthand `kind: str = "some_kind"`.

Python type checkers cannot infer a precise alias from a runtime function
call, so the return annotation is intentionally `Any`. Runtime validation
and JSON schema generation still use Pydantic's discriminated union.
