Skip to content

feat(api): add POST /state endpoint to update session state #1127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

triangle-z
Copy link

@triangle-z triangle-z commented Jun 3, 2025

This PR introduces a new endpoint as described in #1117 :

POST /apps/{app_name}/users/{user_id}/sessions/{session_id}/state

It allows external tools, UIs, or services to update session state via the API programmatically, without needing to send a user message.

I added:

  • New FastAPI route update_session_state
  • Support for append_event in MockSessionService
  • Tests

Example usage:

curl -X POST http://localhost:8080/apps/my_app/users/u1/sessions/s1/state \
     -H 'Content-Type: application/json' \
     -d '{"foo": "bar"}'

Pytest Comparison:

Main Branch (Before PR)

Capture d'écran 2025-06-03 224909

Feature Branch (This PR)

Capture d'écran 2025-06-03 224837

All new tests passed, and no test failed that didn't fail in the main branch.

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.

1 participant