AI / Apache Burr Interview questions
How does Burr’s state persistence resume an application at the point it left off?
You call initialize_from(persister, resume_at_next_action=True, default_entrypoint=..., default_state=...) on the ApplicationBuilder instead of with_state/with_entrypoint (those are mutually exclusive with initialize_from).
state_persister = SQLLitePersister.from_values(db_path=".sqllite.db", table_name="burr_state") app = ( ApplicationBuilder() .with_actions(ai_converse=ai_converse, human_converse=human_converse, terminal=Result("chat_history")) .with_transitions( ("ai_converse", "human_converse", default), ("human_converse", "terminal", expr("'exit' in question")), ("human_converse", "ai_converse", default), ) .initialize_from( state_persister, resume_at_next_action=True, default_state={"chat_history": []}, default_entrypoint="human_converse", ) .with_state_persister(state_persister) .with_identifiers(app_id=app_id) .build() )
Behind the scenes, the loader queries the persister for state matching the app_id/partition_key set via with_identifiers(). If it finds a prior run, resume_at_next_action=True picks up right after the last completed action instead of restarting at default_entrypoint. If nothing is found, it silently falls back to default_state and default_entrypoint — it never raises just because there was no prior state.
More Related questions...