Skip to content

ToolRequestUserInputQuestion

Base classes

Name Children Inherits
CodexBaseModel
codexed.models.base
Base model for all Codex API models.

⋔ Inheritance diagram

graph TD
  2312573922["misc.ToolRequestUserInputQuestion"]
  3116041069["base.CodexBaseModel"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  3116041069 --> 2312573922
  3879467795 --> 3116041069
  2751680898 --> 3879467795

🛈 DocStrings

Bases: CodexBaseModel

A question in a tool request for user input.

Source code in src/codexed/models/misc.py
class ToolRequestUserInputQuestion(CodexBaseModel):
    """A question in a tool request for user input."""

    id: str
    header: str
    question: str
    is_other: bool = False
    is_secret: bool = False
    options: list[ToolRequestUserInputOption] | None = None

    def to_schema_property(self) -> dict[str, Any]:
        """Convert a Codex user input question to a JSON Schema property.

        Maps question options to enum values, and handles secret/free-text questions.

        Args:
            question: Codex question with optional options list

        Returns:
            JSON Schema property definition
        """
        prop: dict[str, Any] = {"title": self.header or self.id}
        if self.question:
            prop["description"] = self.question

        if self.options and not self.is_other:
            # Question with fixed options -> enum
            prop["type"] = "string"
            prop["enum"] = [opt.label for opt in self.options]
        elif self.options and self.is_other:
            # Options with an "other" free-text fallback -> enum + freeform
            prop["type"] = "string"
            prop["enum"] = [opt.label for opt in self.options]
        else:
            # Free-text question
            prop["type"] = "string"

        if self.is_secret:
            prop["writeOnly"] = True

        return prop

to_schema_property

to_schema_property() -> dict[str, Any]

Convert a Codex user input question to a JSON Schema property.

Maps question options to enum values, and handles secret/free-text questions.

Parameters:

Name Type Description Default
question

Codex question with optional options list

required

Returns:

Type Description
dict[str, Any]

JSON Schema property definition

Source code in src/codexed/models/misc.py
def to_schema_property(self) -> dict[str, Any]:
    """Convert a Codex user input question to a JSON Schema property.

    Maps question options to enum values, and handles secret/free-text questions.

    Args:
        question: Codex question with optional options list

    Returns:
        JSON Schema property definition
    """
    prop: dict[str, Any] = {"title": self.header or self.id}
    if self.question:
        prop["description"] = self.question

    if self.options and not self.is_other:
        # Question with fixed options -> enum
        prop["type"] = "string"
        prop["enum"] = [opt.label for opt in self.options]
    elif self.options and self.is_other:
        # Options with an "other" free-text fallback -> enum + freeform
        prop["type"] = "string"
        prop["enum"] = [opt.label for opt in self.options]
    else:
        # Free-text question
        prop["type"] = "string"

    if self.is_secret:
        prop["writeOnly"] = True

    return prop

:fa-brands-github: Show source on GitHub