Files
openrouter-python-sdk-retry…/src/openrouter/components/subagentservertoolconfig.py
T

80 lines
4.5 KiB
Python

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .subagentnestedtool import SubagentNestedTool, SubagentNestedToolTypedDict
from .subagentreasoning import SubagentReasoning, SubagentReasoningTypedDict
from openrouter.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
class SubagentServerToolConfigTypedDict(TypedDict):
r"""Configuration for the openrouter:subagent server tool."""
instructions: NotRequired[str]
r"""System instructions for the subagent. When omitted, the subagent responds with no system prompt of its own."""
max_completion_tokens: NotRequired[int]
r"""Maximum number of output tokens (including reasoning) the subagent may produce. When omitted, the provider's default applies."""
max_tool_calls: NotRequired[int]
r"""Maximum number of tool-calling steps the subagent may take during its agentic loop. Capped at 25. Only relevant when the subagent is given tools. Accepted and validated but not yet enforced on the subagent call."""
model: NotRequired[str]
r"""Slug of the model that executes delegated tasks (any OpenRouter model). Typically a smaller, cheaper, faster model than the one delegating. When omitted, the model from the outer API request is used. The subagent tool itself cannot be the subagent model."""
reasoning: NotRequired[SubagentReasoningTypedDict]
r"""Reasoning configuration forwarded to the subagent call. Use this to control reasoning effort and token budget for models that support extended thinking."""
temperature: NotRequired[float]
r"""Sampling temperature forwarded to the subagent call. When omitted, the provider's default applies."""
tools: NotRequired[List[SubagentNestedToolTypedDict]]
r"""Tools the subagent may use while executing a delegated task. The subagent runs as an agentic sub-agent over these tools, then returns its outcome. Only OpenRouter server tools are supported — function tools are rejected — and the list must not include the subagent tool itself."""
class SubagentServerToolConfig(BaseModel):
r"""Configuration for the openrouter:subagent server tool."""
instructions: Optional[str] = None
r"""System instructions for the subagent. When omitted, the subagent responds with no system prompt of its own."""
max_completion_tokens: Optional[int] = None
r"""Maximum number of output tokens (including reasoning) the subagent may produce. When omitted, the provider's default applies."""
max_tool_calls: Optional[int] = None
r"""Maximum number of tool-calling steps the subagent may take during its agentic loop. Capped at 25. Only relevant when the subagent is given tools. Accepted and validated but not yet enforced on the subagent call."""
model: Optional[str] = None
r"""Slug of the model that executes delegated tasks (any OpenRouter model). Typically a smaller, cheaper, faster model than the one delegating. When omitted, the model from the outer API request is used. The subagent tool itself cannot be the subagent model."""
reasoning: Optional[SubagentReasoning] = None
r"""Reasoning configuration forwarded to the subagent call. Use this to control reasoning effort and token budget for models that support extended thinking."""
temperature: Optional[float] = None
r"""Sampling temperature forwarded to the subagent call. When omitted, the provider's default applies."""
tools: Optional[List[SubagentNestedTool]] = None
r"""Tools the subagent may use while executing a delegated task. The subagent runs as an agentic sub-agent over these tools, then returns its outcome. Only OpenRouter server tools are supported — function tools are rejected — and the list must not include the subagent tool itself."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(
[
"instructions",
"max_completion_tokens",
"max_tool_calls",
"model",
"reasoning",
"temperature",
"tools",
]
)
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k, serialized.get(n))
if val != UNSET_SENTINEL:
if val is not None or k not in optional_fields:
m[k] = val
return m