Skip to content

Conversation

@ashenfad
Copy link
Owner

@ashenfad ashenfad commented Jan 1, 2026

No description provided.

@ashenfad ashenfad requested a review from Copilot January 1, 2026 18:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for initializing state variables when a session is first created, through a new init parameter on connect_state(). The feature allows passing either a callable or a dict to populate initial state values, with a sentinel mechanism (__agex_init__) to ensure initialization runs only once per session.

  • Added init parameter to connect_state() accepting a callable, dict, or None
  • Implemented apply_init_if_fresh() helper function to handle initialization logic with sentinel-based tracking
  • Added comprehensive test coverage for various initialization scenarios

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/agex/state/test_init.py New test suite validating init functionality across different scenarios (fresh state, existing state, different storage backends)
docs/api/state.md Documentation for the new init parameter with usage examples
agex/state/config.py Added InitVars type alias and init field to StateConfig dataclass
agex/state/init.py Added init parameter to connect_state() function signature and documentation
agex/host/modal.py Integration of apply_init_if_fresh() for Modal host's versioned state paths
agex/host/local.py Integration of apply_init_if_fresh() for Local host's state creation
agex/host/base.py New apply_init_if_fresh() helper function implementing initialization logic
Comments suppressed due to low confidence (1)

docs/api/state.md:1

  • The example uses load_cal() function which is not defined or imported in the example. This could confuse users trying to understand the feature. Consider using a more complete example or referencing a placeholder like load_calendar() that matches the function name used in the earlier complete example.
# State Configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ashenfad ashenfad merged commit effea0e into main Jan 1, 2026
7 checks passed
@ashenfad ashenfad deleted the init branch January 1, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants