Skip to content

Pin Pi defaultProvider/defaultModel in settings.json#69

Open
JamesHWade wants to merge 1 commit into
databricks:mainfrom
JamesHWade:fix/pi-pin-default-model
Open

Pin Pi defaultProvider/defaultModel in settings.json#69
JamesHWade wants to merge 1 commit into
databricks:mainfrom
JamesHWade:fix/pi-pin-default-model

Conversation

@JamesHWade
Copy link
Copy Markdown

Summary

  • Pi inherits the full environment from ucode, so any env var its pi-ai package recognizes as auth for a built-in provider (e.g. HF_TOKENhuggingface) makes that built-in look auth-configured. Pi's findInitialModel then picks the built-in before reaching our databricks-claude provider, routes to the wrong host, and validation 401s with Invalid username or password.
  • Fix: also write ~/.pi/agent/settings.json next to models.json with defaultProvider/defaultModel set to our chosen Databricks model. Pi reads these before falling through to env-keyed built-ins.

Fixes #68.

Test plan

  • uv run pytest tests/test_agent_pi.py (added a focused test for the settings write)
  • uv run ruff check .
  • ucode pi on a workspace with HF_TOKEN set in the environment — validation now passes and Pi launches with the configured Databricks Claude model

Pi inherits the full environment from ucode, including any env vars that
its pi-ai package recognizes as auth for a built-in provider (e.g.
HF_TOKEN → huggingface). Pi's findInitialModel then picks the built-in
before reaching our databricks-claude provider, routes to the wrong host,
and validation 401s.

Write settings.json alongside models.json so findInitialModel uses our
provider/model directly. Fixes databricks#68.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 22, 2026 12:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Pins Pi’s startup selection to the ucode-managed Databricks provider/model by writing ~/.pi/agent/settings.json alongside models.json, preventing Pi from incorrectly selecting an env-authenticated built-in provider (e.g. huggingface via HF_TOKEN) and failing validation.

Changes:

  • Add settings.json generation to pin defaultProvider/defaultModel derived from the configured model selector.
  • Introduce _write_settings() in the Pi agent to persist these defaults with a safe merge.
  • Add a focused pytest asserting settings.json is written with the expected pinned defaults.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/ucode/agents/pi.py Writes settings.json with pinned defaults derived from the resolved <provider>/<model> selector.
tests/test_agent_pi.py Extends Pi config tests to cover writing and contents of settings.json.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ucode/agents/pi.py
Comment on lines 184 to 187
merged = deep_merge_dict(existing, overlay)
write_json_file(PI_CONFIG_PATH, merged)
_write_settings(overlay["model"])
state = mark_tool_managed(state, "pi", managed_keys)
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.

Pi 401s on first request — Pi picks an env-backed built-in provider (e.g. huggingface via HF_TOKEN) instead of our configured Databricks provider

2 participants