Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions docs/resources/agents_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ page_title: "coderd_agents_model Resource - terraform-provider-coderd"
subcategory: ""
description: |-
~> This resource is experimental. Changes are to be expected, and we recommend using it with caution in production environments.
Configures an admin-managed chat model for Coder Agents, binding a model identifier to a configured AI provider (see coderd_ai_provider) along with context, compression, and optional JSON tuning settings.
~> Warning
This resource is only compatible with Coder version 2.37.0 https://github.com/coder/coder/releases/tag/v2.37.0 and later.
Configures an organization-scoped, admin-managed chat model for Coder Agents, binding a model identifier to a configured AI provider (see coderd_ai_provider) along with context, compression, and optional JSON tuning settings. Import IDs use <organization-name>/<id>.
---

# coderd_agents_model (Resource)

~> This resource is experimental. Changes are to be expected, and we recommend using it with caution in production environments.

Configures an admin-managed chat model for Coder Agents, binding a model identifier to a configured AI provider (see `coderd_ai_provider`) along with context, compression, and optional JSON tuning settings.
~> **Warning**
This resource is only compatible with Coder version [2.37.0](https://github.com/coder/coder/releases/tag/v2.37.0) and later.

Configures an organization-scoped, admin-managed chat model for Coder Agents, binding a model identifier to a configured AI provider (see `coderd_ai_provider`) along with context, compression, and optional JSON tuning settings. Import IDs use `<organization-name>/<id>`.

## Example Usage

Expand Down Expand Up @@ -68,6 +73,7 @@ resource "coderd_agents_model" "sonnet" {
- `display_name` (String) Display name shown in Coder.
- `enabled` (Boolean) Whether this model configuration is enabled. Defaults to true.
- `model_config` (String) Optional JSON blob of per-call tuning for the model, such as `max_output_tokens`, `temperature`, `top_p`, and `provider_options`. See the field reference (including per-provider `provider_options`) at https://pkg.go.dev/github.com/coder/coder/v2/codersdk#ChatModelCallConfig.
- `organization_id` (String) Organization ID that owns the Agents model configuration. Defaults to the provider default organization ID.

### Read-Only

Expand All @@ -83,14 +89,14 @@ 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 must be the Agents model configuration UUID returned by Coder.
$ terraform import coderd_agents_model.sonnet <model-config-id>
# The ID supplied must be the organization name and the Agents model configuration UUID returned by Coder.
$ terraform import coderd_agents_model.sonnet <organization-name>/<model-config-id>
```
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_model.sonnet
id = "<model-config-id>"
id = "<organization-name>/<model-config-id>"
}
```
4 changes: 2 additions & 2 deletions docs/resources/agents_system_prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: |-
~> Warning
terraform destroy resets the prompt to empty and include_default_system_prompt to true, the defaults of a never-configured deployment. The API has no delete operation for this setting.
~> Warning
This resource requires Coder version 2.32.0 https://github.com/coder/coder/releases/tag/v2.32.0 or later, and a token with site-wide owner permissions.
This resource requires Coder version 2.37.0 https://github.com/coder/coder/releases/tag/v2.37.0 or later, and a token with site-wide owner permissions.
---

# coderd_agents_system_prompt (Resource)
Expand All @@ -32,7 +32,7 @@ If a system prompt was configured out of band, `terraform import` this resource
`terraform destroy` resets the prompt to empty and `include_default_system_prompt` to `true`, the defaults of a never-configured deployment. The API has no delete operation for this setting.

~> **Warning**
This resource requires Coder version [2.32.0](https://github.com/coder/coder/releases/tag/v2.32.0) or later, and a token with site-wide `owner` permissions.
This resource requires Coder version [2.37.0](https://github.com/coder/coder/releases/tag/v2.37.0) or later, and a token with site-wide `owner` permissions.

## Example Usage

Expand Down
6 changes: 3 additions & 3 deletions examples/resources/coderd_agents_model/import.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# The ID supplied must be the Agents model configuration UUID returned by Coder.
$ terraform import coderd_agents_model.sonnet <model-config-id>
# The ID supplied must be the organization name and the Agents model configuration UUID returned by Coder.
$ terraform import coderd_agents_model.sonnet <organization-name>/<model-config-id>
```
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_model.sonnet
id = "<model-config-id>"
id = "<organization-name>/<model-config-id>"
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.26.5

require (
cdr.dev/slog/v3 v3.1.0
github.com/coder/coder/v2 v2.34.0-rc.0.0.20260819194623-24b83dc727e8
github.com/coder/coder/v2 v2.34.0-rc.0.0.20260827091847-26b9c8764f91
github.com/coder/retry v1.5.1
github.com/coder/serpent v0.15.0
github.com/coder/websocket v1.8.15
Expand Down Expand Up @@ -67,7 +67,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.2.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect
github.com/brianvoe/gofakeit/v7 v7.15.0 // indirect
github.com/brianvoe/gofakeit/v7 v7.16.0 // indirect
github.com/buger/jsonparser v1.1.2 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6
github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E=
github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs=
github.com/brianvoe/gofakeit/v7 v7.15.0 h1:kGLYAWN8tnmxq2PelKVK6zwpM7kMxdz9SGPH31mFkNs=
github.com/brianvoe/gofakeit/v7 v7.15.0/go.mod h1:QXuPeBw164PJCzCUZVmgpgHJ3Llj49jSLVkKPMtxtxA=
github.com/brianvoe/gofakeit/v7 v7.16.0 h1:LXNcvT4Klw72/hqpLNNdEWFIcP7G0VFPNsqvEIGONBE=
github.com/brianvoe/gofakeit/v7 v7.16.0/go.mod h1:QXuPeBw164PJCzCUZVmgpgHJ3Llj49jSLVkKPMtxtxA=
github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw=
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
github.com/buger/jsonparser v1.1.2 h1:frqHqw7otoVbk5M8LlE/L7HTnIq2v9RX6EJ48i9AxJk=
Expand Down Expand Up @@ -136,8 +136,8 @@ github.com/clipperhouse/uax29/v2 v2.6.0 h1:z0cDbUV+aPASdFb2/ndFnS9ts/WNXgTNNGFoK
github.com/clipperhouse/uax29/v2 v2.6.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
github.com/coder/coder/v2 v2.34.0-rc.0.0.20260819194623-24b83dc727e8 h1:mLAxnd8iaIvQm43EfILFLvIyCRnHILQskGgnkj6V/P8=
github.com/coder/coder/v2 v2.34.0-rc.0.0.20260819194623-24b83dc727e8/go.mod h1:pZvSpxDWkuVFXq6X/JvnW+BHPuEr1hc5VkwrJ8aJJng=
github.com/coder/coder/v2 v2.34.0-rc.0.0.20260827091847-26b9c8764f91 h1:J8Niy9QDHfWBcaH4gSAKulKhmOmKYbMJw+tVNx9CAm0=
github.com/coder/coder/v2 v2.34.0-rc.0.0.20260827091847-26b9c8764f91/go.mod h1:1meIub5i3H2wb2Vz1g61w0bvVHqDCFVAAOl6xGhfaWg=
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 h1:3A0ES21Ke+FxEM8CXx9n47SZOKOpgSE1bbJzlE4qPVs=
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0/go.mod h1:5UuS2Ts+nTToAMeOjNlnHFkPahrtDkmpydBen/3wgZc=
github.com/coder/quartz v0.3.0 h1:bUoSEJ77NBfKtUqv6CPSC0AS8dsjqAqqAv7bN02m1mg=
Expand Down
4 changes: 2 additions & 2 deletions integration/headers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestHeadersBypassRateLimit(t *testing.T) {

t.Run("WithoutBypass", func(t *testing.T) {
t.Parallel()
subCtx, subCancel := context.WithTimeout(context.Background(), 2*time.Minute)
subCtx, subCancel := context.WithTimeout(t.Context(), 2*time.Minute)
defer subCancel()

got429 := false
Expand All @@ -90,7 +90,7 @@ func TestHeadersBypassRateLimit(t *testing.T) {

t.Run("WithBypass", func(t *testing.T) {
t.Parallel()
subCtx, subCancel := context.WithTimeout(context.Background(), 2*time.Minute)
subCtx, subCancel := context.WithTimeout(t.Context(), 2*time.Minute)
defer subCancel()

// Create a new client with the bypass header set.
Expand Down
2 changes: 1 addition & 1 deletion integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func dumpContainerLogs(t *testing.T, ctr testcontainers.Container) {
if ctr == nil {
return
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
ctx, cancel := context.WithTimeout(context.WithoutCancel(t.Context()), 30*time.Second)
defer cancel()
logs, err := ctr.Logs(ctx)
if err != nil {
Expand Down
15 changes: 10 additions & 5 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,20 @@ func TestIntegration(t *testing.T) {
},
},
{
name: "agents-model-test",
preF: func(t testing.TB, c *codersdk.Client) {},
name: "agents-model-test",
minVersion: "v2.37.0",
preF: func(t testing.TB, c *codersdk.Client) {},
assertF: func(t testing.TB, c *codersdk.Client) {
providers, err := c.AIProviders(ctx)
require.NoError(t, err)
require.Len(t, providers, 2)

organizations, err := c.Organizations(ctx)
require.NoError(t, err)
require.NotEmpty(t, organizations)

exp := codersdk.NewExperimentalClient(c)
configs, err := exp.ListChatModelConfigs(ctx)
configs, err := exp.ChatModels(ctx, organizations[0].ID)
Comment thread
ethanndickson marked this conversation as resolved.
require.NoError(t, err)

providerTypeByID := make(map[uuid.UUID]string, len(providers))
Expand Down Expand Up @@ -267,10 +272,10 @@ func TestIntegration(t *testing.T) {
}
}`},
}
require.Len(t, configs, len(want))
require.Len(t, configs.Models, len(want))

var defaults []string
for _, m := range configs {
for _, m := range configs.Models {
if m.IsDefault {
defaults = append(defaults, m.Model)
}
Expand Down
Loading