Add application-scoped state API (ctx.app_state)#2191
Open
Conversation
Adds server and dataplane support for application-scoped state, enabling functions to share key-value state across request boundaries within the same application. This complements the existing per-request ctx.state. Proto changes: - Add FunctionExecutorMetadata message with app_state_uri_prefix to ContainerDescription in executor_api.proto - Add AllocationAppState operation/result messages to function_executor.proto - Wire into AllocationState and AllocationUpdate Server changes: - Add app_state_key_prefix() to DataPayload for URI computation - Populate FunctionExecutorMetadata on ContainerDescription in both build_full_snapshot() and build_add_container_command() Dataplane changes: - Add AppStateHandler with full reconcile logic in state_ops.rs - Add app_state_uri_prefix to AllocationContext - Read FunctionExecutorMetadata from container description in allocation_lifecycle.rs Integration test: - Add test_app_state.py covering set/get, downstream reads, cross-request persistence, overwrites, and default values Companion PR: tensorlakeai/tensorlake#542 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
72bf048 to
da7bceb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds server and dataplane support for application-scoped state (
ctx.app_state), enabling functions to share key-value state across request boundaries within the same application.Some agents require updating context about users or objects they are managing. Application State is a way for applications to share state across request boundaries as they learn about the problem domain. For example, a fitness tracker agent managing fitness logs of multiple users can store per-user context in
app_stateas a flexible K/V store — much more practical than using rigid database schemas for evolving agent knowledge.Changes
FunctionExecutorMetadatamessage onContainerDescription+ app state operation/result messages infunction_executor.protoapp_state_key_prefix()onDataPayload,FunctionExecutorMetadatapopulated inbuild_full_snapshot()andbuild_add_container_command()AppStateHandlerinstate_ops.rs,app_state_uri_prefixonAllocationContext, wired throughallocation_lifecycle.rstest_app_state.pycovering set/get, downstream reads, cross-request persistence, overwrites, and default valuesCompanion PR
Test plan
cargo build -p indexify-server && cargo build -p indexify-dataplane— compilescargo test -p indexify-server— 268 tests passcargo test -p indexify-dataplane --no-run— compilestest_state.py(request state) — 11 tests pass, no regressionstest_app_state.py— 6 integration tests pass:🤖 Generated with Claude Code