"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations from .stopservertoolswhenfinishreasonis import ( StopServerToolsWhenFinishReasonIs, StopServerToolsWhenFinishReasonIsTypedDict, ) from .stopservertoolswhenhastoolcall import ( StopServerToolsWhenHasToolCall, StopServerToolsWhenHasToolCallTypedDict, ) from .stopservertoolswhenmaxcost import ( StopServerToolsWhenMaxCost, StopServerToolsWhenMaxCostTypedDict, ) from .stopservertoolswhenmaxtokensused import ( StopServerToolsWhenMaxTokensUsed, StopServerToolsWhenMaxTokensUsedTypedDict, ) from .stopservertoolswhenstepcountis import ( StopServerToolsWhenStepCountIs, StopServerToolsWhenStepCountIsTypedDict, ) from openrouter.utils import get_discriminator from pydantic import Discriminator, Tag from typing import Union from typing_extensions import Annotated, TypeAliasType StopServerToolsWhenConditionTypedDict = TypeAliasType( "StopServerToolsWhenConditionTypedDict", Union[ StopServerToolsWhenStepCountIsTypedDict, StopServerToolsWhenHasToolCallTypedDict, StopServerToolsWhenMaxTokensUsedTypedDict, StopServerToolsWhenMaxCostTypedDict, StopServerToolsWhenFinishReasonIsTypedDict, ], ) r"""A single condition that, when met, halts the server-tool agent loop.""" StopServerToolsWhenCondition = Annotated[ Union[ Annotated[StopServerToolsWhenFinishReasonIs, Tag("finish_reason_is")], Annotated[StopServerToolsWhenHasToolCall, Tag("has_tool_call")], Annotated[StopServerToolsWhenMaxCost, Tag("max_cost")], Annotated[StopServerToolsWhenMaxTokensUsed, Tag("max_tokens_used")], Annotated[StopServerToolsWhenStepCountIs, Tag("step_count_is")], ], Discriminator(lambda m: get_discriminator(m, "type", "type")), ] r"""A single condition that, when met, halts the server-tool agent loop."""