Skip to content

Update agent examples and quickstart to support Lakebase Autoscaling#151

Open
jennsun wants to merge 15 commits intodatabricks:mainfrom
jennsun:lakebase-autoscaling-updates-v2
Open

Update agent examples and quickstart to support Lakebase Autoscaling#151
jennsun wants to merge 15 commits intodatabricks:mainfrom
jennsun:lakebase-autoscaling-updates-v2

Conversation

@jennsun
Copy link
Contributor

@jennsun jennsun commented Mar 4, 2026

updated quickstart experience to select instance:
image
image

examples work
image

image image

ex app: https://dbc-fb904e0e-bca7.staging.cloud.databricks.com/apps/agent-longtermj?o=4146361371977516

@jennsun jennsun changed the title Update agent examples to support Lakebase Autoscaling Update agent examples and quickstart to support Lakebase Autoscaling Mar 4, 2026
@jennsun jennsun marked this pull request as ready for review March 4, 2026 21:44
- Add autoscaling (project/branch) as an alternative to provisioned
  Lakebase instances across all 3 memory templates
- Detect app environment via DATABRICKS_APP_NAME and use PGENDPOINT
  (auto-injected by platform) for autoscaling in deployed apps
- Update quickstart to support creating new Lakebase instances or
  connecting to existing provisioned/autoscaling instances
- Use autoscaling_endpoint parameter (renamed in databricks-ai-bridge)
- Add databricks-ai-bridge git dependency for autoscaling support
- Update tests to remove update_databricks_yml_lakebase references

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jennsun jennsun force-pushed the lakebase-autoscaling-updates-v2 branch from 248b026 to e39267c Compare March 5, 2026 23:21
# Note: Using git reference until official release
"databricks-langchain[memory] @ git+https://github.com/databricks/databricks-ai-bridge@lakebase-autoscaling-support#subdirectory=integrations/langchain",
"databricks-ai-bridge @ git+https://github.com/databricks/databricks-ai-bridge@lakebase-autoscaling-support",
"databricks-agents>=1.9.3",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will remove after release

Copy link
Contributor

@dhruv0811 dhruv0811 left a comment

Choose a reason for hiding this comment

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

Looks good overall!! Left some comments for local testing cleanup and some clarifications on lakebase options.

database:
instance_name: '<your-lakebase-instance-name>'
database_name: 'databricks_postgres'
- name: 'postgres'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: couple comments around here saying this is for autoscaling, see below for provisioned?

# TODO: Update with your Lakebase instance for session storage
# Option 1: Provisioned instance (set instance name)
# LAKEBASE_INSTANCE_NAME=
# Option 2: Autoscaling instance (set project and branch)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we not have a third option with just autoscaling_endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the thinking here is that when users develop locally, they do so via passing in project/branch name. the autoscaling_endpoint is only used when we are in the app environment and we can directly read from PGENDPOINT (since it's not as user friendly to pass in) - hence adding this check: https://github.com/databricks/app-templates/pull/151/changes#diff-1e8ffff9ea9c91fc9dce7d8af129175d1fcfe357eabbcec14705feff13eeacacR53

# Check for Lakebase access/connection errors
if any(keyword in error_msg for keyword in ["permission"]):
logger.error(f"Lakebase access error: {e}")
lakebase_desc = LAKEBASE_INSTANCE_NAME or LAKEBASE_AUTOSCALING_ENDPOINT or f"{LAKEBASE_AUTOSCALING_PROJECT}/{LAKEBASE_AUTOSCALING_BRANCH}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth doing some validation like we did in the SDK to ensure that we only have one valid combination of variables set here? Say a user has project and branch set, but accidentally also set instance name, they should be notified rather than silently picking up instance name and short circuiting here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since the sdk covers all these cases/will throw errors, I think adding validation here would be a bit redundant

@jennsun jennsun requested review from bbqiu and dhruv0811 March 6, 2026 02:36
LAKEBASE_AUTOSCALING_ENDPOINT = os.getenv("PGENDPOINT") if _is_app_env else None
LAKEBASE_AUTOSCALING_PROJECT = os.getenv("LAKEBASE_AUTOSCALING_PROJECT") or None
LAKEBASE_AUTOSCALING_BRANCH = os.getenv("LAKEBASE_AUTOSCALING_BRANCH") or None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bit of a chicken & egg prob here when DABs are not ready -

  • in order for us to be able to pass in PGENDPOINT as a var, we need the autoscaling instance as a resource on the app
  • DAB deployment will overwrite app resources, so it would remove manually-added postgres resource when we deploy
  • we will therefore use LAKEBASE_AUTOSCALING_PROJECT and LAKEBASE_AUTOSCALING_BRANCH as
    static env vars supported by our agent SDK

if we want endpoint extension in future, code will look something like:

# Autoscaling params: in the app environment, PGENDPOINT is provided automatically;
# for local dev, use project/branch names directly.
_is_app_env = bool(os.getenv("DATABRICKS_APP_NAME"))
LAKEBASE_AUTOSCALING_ENDPOINT = os.getenv("PGENDPOINT") if _is_app_env else None
LAKEBASE_AUTOSCALING_PROJECT = os.getenv("LAKEBASE_AUTOSCALING_PROJECT") or None
LAKEBASE_AUTOSCALING_BRANCH = os.getenv("LAKEBASE_AUTOSCALING_BRANCH") or None

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