Pin Pi defaultProvider/defaultModel in settings.json#69
Open
JamesHWade wants to merge 1 commit into
Open
Conversation
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]>
There was a problem hiding this comment.
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.jsongeneration to pindefaultProvider/defaultModelderived 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.jsonis 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 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) |
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
pi-aipackage recognizes as auth for a built-in provider (e.g.HF_TOKEN→huggingface) makes that built-in look auth-configured. Pi'sfindInitialModelthen picks the built-in before reaching ourdatabricks-claudeprovider, routes to the wrong host, and validation 401s withInvalid username or password.~/.pi/agent/settings.jsonnext tomodels.jsonwithdefaultProvider/defaultModelset 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 pion a workspace withHF_TOKENset in the environment — validation now passes and Pi launches with the configured Databricks Claude model