Skip to content

Enable persistent sessions - #394

Merged
EItanya merged 28 commits into
mainfrom
persistent-sessions
May 18, 2025
Merged

EItanya merged 28 commits into
mainfrom
persistent-sessions

Conversation

@EItanya

@EItanya EItanya commented May 15, 2025 •

Copy link
Copy Markdown
Contributor

This PR moves away from the previous websocket invocation approach to a req-resp style which supports either standard or streaming. Async will come in the future. This change allows for much simpler session management and retention of messages throughout a given session.

@EItanya
EItanya marked this pull request as ready for review May 15, 2025 19:22
@EItanya
EItanya requested review from ilackarms and peterj as code owners May 15, 2025 19:22
EItanya and others added 12 commits May 15, 2025 19:25
Signed-off-by: Peter Jausovec <[email protected]>
…to persistent-sessions

* 'persistent-sessions' of github.com:kagent-dev/kagent:
  Docker - improve slow CI multi arch build (#398)
  added bug_report and version
  invoke with/without session works properly
  eitanya/fix-name-template (#399)
  add non-interactive CLI commands
  add an option to not set the api key (#389)
Signed-off-by: Peter Jausovec <[email protected]>
@EItanya
EItanya merged commit cb49773 into main May 18, 2025
@EItanya
EItanya deleted the persistent-sessions branch May 19, 2025 02:28
Raghavendiran-2002 pushed a commit to Raghavendiran-2002/kagent that referenced this pull request Apr 30, 2026
* start persistent session work

* add streaming option to API

* basic streaming working

* sessionmanager

* non-streaming works

* cli chat is working

* remove websocket client; add handle session endpoints

* e2e test compile

* skip saving streaming messages

* oops

* add endpoints for the sessions

* add release for agent charts

* combine stream logic

* add non-interactive CLI commands

* invoke with/without session works properly

* added bug_report and version

* wip

Signed-off-by: Peter Jausovec <[email protected]>

* switch UI chat to new streaming endpoint

Signed-off-by: Peter Jausovec <[email protected]>

* update tests + fix ruff warning

Signed-off-by: Peter Jausovec <[email protected]>

---------

Signed-off-by: Peter Jausovec <[email protected]>
Co-authored-by: Peter Jausovec <[email protected]>
krisztianfekete pushed a commit to krisztianfekete/kagent that referenced this pull request Nov 13, 2026
Builds on kagent-dev#3395, now merged; rebased onto main.

Recover crashed runtimes during A2A sends when
`config.sessions.automaticRecovery: true`. The setting defaults to
`false`. The chart only mentions it in a comment, so a default install
renders the same `controller.yaml` as before and a rollback to v1.0.0
can still read it.

The flag controls joining an admitted recovery, recovering a send
refused for an open turn, recovering a send blocked by a suspension
whose worker was lost (the Actor crashed during the post-turn suspend),
and reverting after a proven unaccepted send. A send waits at most 10
seconds for recovery; a recovery still running is answered
`KAGENT_SEND_NOT_ACCEPTED` with `state: RECOVERING`, and the client's
retry continues it. If recovery can't run, the send keeps the answer it
gives without recovery. With the flag off, sends keep their existing
refusals. Explicit `RevertSession` calls remain available.

Missing or replaced runtimes are recorded as FAILED/NONE with reason
`RuntimeLost`. These persistence changes apply with either flag value.
The flag does not control migrations, schema, or stored data.

Chat reads recovery status from stored Session state. It retries
`KAGENT_SEND_NOT_ACCEPTED` before the first stream frame, with the same
message ID. The wait doubles from `retryAfterMs` up to 2 seconds, within
a 30-second window. Chat offers Recover, which calls `RevertSession`, in
three cases: when the window runs out; when a send is refused for an
open turn (`KAGENT_TURN_ACTIVE`), which is what a mid-turn crash
produces with the flag off while the Session still reads READY; and
while a recovery is pending. A recovery whose attempt failed stays
FAILED/REVERT until a client retries it. Recover returns a healthy
runtime unchanged and records a lost one. Session reads do not query
Substrate.

Validation:

- Gateway tests cover all three disabled paths and the existing enabled
paths.
- Config tests cover the default, both values, Helm rendering, and the
deployment checksum. A helm-unittest asserts the default render omits
the flag.
- PostgreSQL-backed Session, database, gRPC, and scheduled-run
controller tests pass.
- UI tests cover the backoff, both refusal tags, and every Recover path,
including a revert that records a lost runtime.
- Vitest workers are capped at eight (`min(cores - 1, 8)`); the default
oversubscribed large machines and made heavy page tests time out. Three
consecutive full runs pass, 846/846.
- On kind, flag off: deleting the worker mid-turn reproduces kagent-dev#394. The
refused send offers Recover, Recover restores the runtime, and the next
message is answered. Recover during a healthy running turn leaves it
running. Screenshots and logs: [evidence
gist](https://gist.github.com/adalundhe/533ce0841c58cdea0018bcc62058dccb).
- On kind, flag on: a worker deleted while the Actor suspends after a
turn leaves the Session stuck before this change, and the next send
recovers it after. Logs: [suspension-crash
gist](https://gist.github.com/adalundhe/426f7e31388b2a59df517572788e9e2c).
- Protobuf, Go and UI lint pass. Live crash-recovery E2E explicitly
enables the flag in CI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Ada Lundhe <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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