Skip to content

Conversation

@longcw
Copy link
Contributor

@longcw longcw commented Feb 4, 2026

cloud to worker:

  • version: require worker to have the same version of state
  • version + empty snapshot: new session
  • version + snapshot: cold start

worker to cloud:

  • version + delta: update the cloud state to new version

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2026

⚠️ No Changeset found

Latest commit: 0084227

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "github.com/livekit/protocol" specified in the `fixed` option does not match any package in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.

@longcw longcw requested a review from a team February 4, 2026 07:10
Copy link
Contributor

@paulwe paulwe left a comment

Choose a reason for hiding this comment

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

it will always be one or the other so maybe oneof?

@paulwe
Copy link
Contributor

paulwe commented Feb 4, 2026

the new session state should be a db with empty tables. if the schema the sdk needs changes in later versions this avoids ongoing maintenance to keep them synced

@longcw
Copy link
Contributor Author

longcw commented Feb 4, 2026

it will always be one or the other

when cloud thinks the work has the full state, it should only set the version but not snapshot and delta?

@paulwe
Copy link
Contributor

paulwe commented Feb 4, 2026

oh, right... undefined is a valid oneof state (optional is syntactic sugar over oneof { T })

@longcw
Copy link
Contributor Author

longcw commented Feb 4, 2026

we will have a schema version in the db, if the schema version from the snapshot is not matched to the one in agent sdk, either we raise an error or automatically convert it to the new schema and sync a new snapshot to the cloud. so the cloud doesn't need to care about the schema of the db.

@longcw
Copy link
Contributor Author

longcw commented Feb 4, 2026

so the new session state can be an empty byte? it make the sdk easier to determine it's a new session

@paulwe
Copy link
Contributor

paulwe commented Feb 4, 2026

no, it can't be empty bytes... that's what i wanted to clarify since you were disambiguating the zero and undefined states

@longcw
Copy link
Contributor Author

longcw commented Feb 4, 2026

why it cannot be empty bytes... can we distinguish "not set" and empty value if we check the field with HasField or WhichOneof before accessing it? or you mean by design you don't want it to be empty bytes?

@paulwe
Copy link
Contributor

paulwe commented Feb 4, 2026

cloud to worker:

  • version - undefined oneof indicates new session
  • version + snapshot - cold start from ongoing session

worker to cloud

  • version + snapshot - new session / new schema
  • version + delta - update to version-1

@longcw
Copy link
Contributor Author

longcw commented Feb 4, 2026

I was thinking "version - undefined oneof" means the hot sync that only a version is sent to the worker and "version + empty snapshot" means a new session (or discard previous data if any)

@paulwe
Copy link
Contributor

paulwe commented Feb 4, 2026

we would only need this if we planned to reuse session ids but they should always be distinct right?

@paulwe
Copy link
Contributor

paulwe commented Feb 4, 2026

you're right. maybe this? - cloud to worker:

  • undefined (no state) - new session
  • version - resume ongoing session
  • version + snapshot - cold start from ongoing session

string agent_name = 3;
string metadata = 4;
AgentSessionState session_state = 5;
optional AgentSessionState session_state = 5;
Copy link
Contributor

Choose a reason for hiding this comment

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

messages are always optional it doesn't have to be explicitly optional

@longcw longcw merged commit 2bb10a5 into main Feb 4, 2026
6 checks passed
@longcw longcw deleted the longc/optional-agent-session-snapshot branch February 4, 2026 08:36
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