-
Notifications
You must be signed in to change notification settings - Fork 12
feat!: add organization-scoped coderd_agents_default_model #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ethanndickson
wants to merge
12
commits into
org-chat-models/agents-model
from
org-chat-models/default-model
+1,236
−591
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e20d0c0
feat!: make coderd_default_agents_model per-organization
ethanndickson 4db76bc
fix(coderd_default_agents_model): migrate legacy state
ethanndickson 6d05654
feat!: rename default Agents model resource
ethanndickson 5a8b990
fix(coderd_agents_default_model): handle replacement 404s
ethanndickson bf911cf
fix(coderd_agents_default_model): remove missing organizations
ethanndickson 33e17a9
fix(coderd_agents_default_model): remove default org fallback
ethanndickson 24c8288
fix(coderd_agents_default_model): detect unsupported endpoints
ethanndickson c183730
fix(coderd_agents_default_model): handle alternate not-found responses
ethanndickson 8240663
fix(coderd_agents_default_model): migrate renamed state
ethanndickson 11f499c
docs(coderd_agents_default_model): omit migration guidance
ethanndickson e9f01cf
feat(coderd_agents_default_model)!: import by organization name
ethanndickson d54038a
feat(coderd_agents_mcp_server)!: import by organization name and slug
ethanndickson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| --- | ||
| # generated by https://github.com/hashicorp/terraform-plugin-docs | ||
| page_title: "coderd_agents_default_model Resource - terraform-provider-coderd" | ||
| subcategory: "" | ||
| description: |- | ||
| ~> This resource is experimental. Changes are expected, and it is not recommended for production use. | ||
| ~> Warning | ||
| This resource is only compatible with Coder version 2.37.0 https://github.com/coder/coder/releases/tag/v2.37.0 and later. | ||
| Selects which coderd_agents_model is the default chat model for Coder Agents in an organization. | ||
| Coder enforces a single default model per organization: marking a model as default automatically demotes the previous default in the same operation. Only one coderd_agents_default_model resource should exist per organization. | ||
| Destroying this resource does not clear the default server-side. Coder requires a default once models exist and promotes a replacement when the current default is removed, so deleting this resource only stops Terraform from managing which model is default. | ||
| --- | ||
|
|
||
| # coderd_agents_default_model (Resource) | ||
|
|
||
| ~> This resource is experimental. Changes are expected, and it is not recommended for production use. | ||
|
|
||
| ~> **Warning** | ||
| This resource is only compatible with Coder version [2.37.0](https://github.com/coder/coder/releases/tag/v2.37.0) and later. | ||
|
|
||
| Selects which `coderd_agents_model` is the default chat model for Coder Agents in an organization. | ||
|
|
||
| Coder enforces a single default model per organization: marking a model as default automatically demotes the previous default in the same operation. Only one `coderd_agents_default_model` resource should exist per organization. | ||
|
|
||
| Destroying this resource does not clear the default server-side. Coder requires a default once models exist and promotes a replacement when the current default is removed, so deleting this resource only stops Terraform from managing which model is default. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```terraform | ||
| variable "anthropic_api_key" { | ||
| type = string | ||
| sensitive = true | ||
| } | ||
|
|
||
| resource "coderd_ai_provider" "anthropic" { | ||
| type = "anthropic" | ||
| name = "anthropic" | ||
| base_url = "https://api.anthropic.com" | ||
|
|
||
| api_key_wo = var.anthropic_api_key | ||
| api_key_wo_version = 1 | ||
| } | ||
|
|
||
| resource "coderd_agents_model" "sonnet" { | ||
| ai_provider_id = coderd_ai_provider.anthropic.id | ||
| model = "claude-3-5-sonnet-20241022" | ||
| display_name = "Claude 3.5 Sonnet" | ||
| context_limit = 200000 | ||
| } | ||
|
|
||
| # Mark the Sonnet model as the default for Coder Agents in its organization. | ||
| # Setting a new default automatically demotes the previous one in that | ||
| # organization, so use one resource per organization. | ||
| resource "coderd_agents_default_model" "default" { | ||
| organization_id = coderd_agents_model.sonnet.organization_id | ||
| model_id = coderd_agents_model.sonnet.id | ||
| } | ||
| ``` | ||
|
|
||
| <!-- schema generated by tfplugindocs --> | ||
| ## Schema | ||
|
|
||
| ### Required | ||
|
|
||
| - `model_id` (String) ID of the `coderd_agents_model` to mark as the organization's default. Usually this is `coderd_agents_model.<name>.id`. | ||
| - `organization_id` (String) Organization ID whose default Agents model is managed. | ||
|
|
||
| ### Read-Only | ||
|
|
||
| - `id` (String) Organization ID that identifies this organization's default Agents model selection. | ||
|
|
||
| ## Import | ||
|
|
||
| Import is supported using the following syntax: | ||
|
|
||
| The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: | ||
|
|
||
| ```shell | ||
| # The ID supplied is the name of the organization whose default model should be imported. | ||
| $ terraform import coderd_agents_default_model.default <organization-name> | ||
| ``` | ||
| Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used: | ||
|
|
||
| ```terraform | ||
| import { | ||
| to = coderd_agents_default_model.default | ||
| id = "<organization-name>" | ||
| } | ||
| ``` |
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # The ID supplied is the name of the organization whose default model should be imported. | ||
| $ terraform import coderd_agents_default_model.default <organization-name> | ||
| ``` | ||
| Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used: | ||
|
|
||
| ```terraform | ||
| import { | ||
| to = coderd_agents_default_model.default | ||
| id = "<organization-name>" | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| # The ID must contain the organization UUID and MCP server configuration UUID. | ||
| $ terraform import coderd_agents_mcp_server.example <organization-id>/<mcp-server-id> | ||
| # The ID must contain the organization name and the MCP server slug. | ||
| $ terraform import coderd_agents_mcp_server.example <organization-name>/<slug> | ||
| ``` | ||
| Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used: | ||
|
|
||
| ```terraform | ||
| import { | ||
| to = coderd_agents_mcp_server.example | ||
| id = "<organization-id>/<mcp-server-id>" | ||
| id = "<organization-name>/<slug>" | ||
| } |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.