Cheat sheet
mode_cheatsheet.py
tool_mode.py
Mode types
Cascading
Common patterns
Debugging
inspect_schema.py
Related
Mode— the marker referenceTool.llm_schema— what the debugging call above returns- Mode system — the same rules, explained
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
The Mode cheat sheet: types, cascading, common patterns, and how to inspect a result.
from typing import Annotated
from pydantic import BaseModel, Field
from charter import Mode
# Single mode
field: Annotated[str, Field(...), Mode("A")]
# Multiple modes
field: Annotated[str, Field(...), Mode("A, B, C")]
# Special modes
id: Annotated[str, Field(...), Mode("response_only")]
internal: Annotated[str, Field(...), Mode("disabled")]
tool = factory(
name="my_tool",
args_schema=MySchema,
method="POST",
url_template="v1/thing",
mode="A",
)
| Mode | Meaning | Use case |
|---|---|---|
"response_only" | only in API responses | IDs, timestamps, computed fields |
"request_only" | input-only, always shown | write-only payload fields |
"disabled" | never exposed to the LLM | internal / deprecated fields |
"A", "B", … | custom modes | different operations (send/read) |
"A, B" | multiple modes | fields used in several contexts |
| (no mode) | always included | common fields |
# Parent carries the mode
parent: Annotated[Child, Mode("B")] # Child's fields inherit Mode B
class Child(BaseModel):
inherited: str = Field(...) # gets Mode B from the parent
override: Annotated[str, Mode("A")] # overrides to Mode A
Mode("read") # GET operations
Mode("write") # POST/PUT operations
Mode("v1")
Mode("v2")
Mode("v1, v2") # both versions
print(sorted(tool.llm_schema().model_fields))
from charter.execution.schema import create_llm_schema
schema = create_llm_schema(MyModel, mode="A")
print(f"Fields in mode A: {sorted(schema.model_fields)}")
Mode — the marker referenceTool.llm_schema — what the debugging call above returnsWas this page helpful?