Skip to content

Commit 7a11b50

Browse files
akshay-kumar-bmDeanChensj
authored andcommitted
docs(openapi): improve docs for session model
Merge google#5031 ### Description This PR improves the generated OpenAPI/Swagger documentation for session management by adding clearer metadata and richer schema docs for the Session model (descriptions + examples). ### What changed - Session model docs: add field descriptions/examples for so the API schema is self-explanatory. ### Why The OpenAPI output was correct but lacked enough context (field meanings and examples) for users reading Swagger UI or generating clients. ### Testing Documentation-only change (OpenAPI metadata / schema docs). - Unit tests: Not run. Co-authored-by: Shangjie Chen <deanchen@google.com> COPYBARA_INTEGRATE_REVIEW=google#5031 from akshay-kumar-bm:docs/openapi-session-endpoint-docs-update 04ea27e PiperOrigin-RevId: 932788042
1 parent 24a1b26 commit 7a11b50

1 file changed

Lines changed: 33 additions & 14 deletions

File tree

src/google/adk/sessions/session.py

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,45 @@ class Session(BaseModel):
2929
"""Represents a series of interactions between a user and agents."""
3030

3131
model_config = ConfigDict(
32-
extra='forbid',
32+
extra="forbid",
3333
arbitrary_types_allowed=True,
3434
alias_generator=alias_generators.to_camel,
3535
populate_by_name=True,
3636
)
3737
"""The pydantic model config."""
3838

39-
id: str
40-
"""The unique identifier of the session."""
41-
app_name: str
42-
"""The name of the app."""
43-
user_id: str
44-
"""The id of the user."""
45-
state: dict[str, Any] = Field(default_factory=dict)
46-
"""The state of the session."""
47-
events: list[Event] = Field(default_factory=list)
48-
"""The events of the session, e.g. user input, model response, function
49-
call/response, etc."""
50-
last_update_time: float = 0.0
51-
"""The last update time of the session."""
39+
id: str = Field(
40+
description="Unique identifier of the session.",
41+
examples=["session-abc123"],
42+
)
43+
app_name: str = Field(
44+
description="Application name that owns the session.",
45+
examples=["hello_world"],
46+
)
47+
user_id: str = Field(
48+
description="User ID that owns the session.",
49+
examples=["user-123"],
50+
)
51+
state: dict[str, Any] = Field(
52+
default_factory=dict,
53+
description="Current persisted session state.",
54+
examples=[{"locale": "en-US"}],
55+
)
56+
events: list[Event] = Field(
57+
default_factory=list,
58+
description=(
59+
"Ordered event history for the session, including user, model, and"
60+
" tool events (e.g. user input, model response, function"
61+
" call/response)."
62+
),
63+
)
64+
last_update_time: float = Field(
65+
default=0.0,
66+
description=(
67+
"Unix timestamp in seconds for the most recent session update."
68+
),
69+
examples=[1_742_000_000.0],
70+
)
5271

5372
_storage_update_marker: str | None = PrivateAttr(default=None)
5473
"""Internal storage revision marker used for stale-session detection."""

0 commit comments

Comments
 (0)