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.

@DeanChensj
Copy link
Collaborator

Hi @triangle-z , now that we support update the state through the AgentRun (see: 3f9f773). You can send state update along with the chat message, do we still need this endpoint?

@DeanChensj DeanChensj self-assigned this Jul 22, 2025
@DeanChensj DeanChensj added the request clarification [Status] The maintainer need clarification or more information from the author label Jul 22, 2025
@srochiramani
Copy link

@DeanChensj we definitely do -- there's times when one might want to update the state without generating a LLM response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
request clarification [Status] The maintainer need clarification or more information from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants