Skip to content

feat(coderd/x/chatd): limit chat template tools to project templates - #30755

Draft
jaaydenh wants to merge 12 commits into
chat-project-templates/apifrom
chat-project-templates/chatd
Draft

jaaydenh wants to merge 12 commits into
chat-project-templates/apifrom
chat-project-templates/chatd

Conversation

@jaaydenh

@jaaydenh jaaydenh commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Makes the chat template tools follow the chat project's template list from the previous PR.

  • list_templates only lists the project's templates and returns NextStepNoTemplates for a project without any. The project's default template becomes recommended_template_id.
  • read_template and create_workspace reject templates outside the list. read_template includes project_defaults for the default template.
  • create_workspace fills in the project's default preset or parameter values that the model did not pass. Values the model passes win, and a default preset that no longer belongs to the template's active version is skipped and logged rather than failing the build.
  • The policy is read on every tool call, so edits apply to running chats. Chats outside projects are unchanged.

Stack (merge top to bottom):

list_templates, read_template and create_workspace only use the chat
project's templates, list_templates recommends the project's default
template, and create_workspace applies the project's default preset or
parameter values when the model leaves them out.
@jaaydenh

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T12:27:24.661048Z 2c4c0c3 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e47e1b179

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/chattool/projecttemplates.go Outdated
@jaaydenh

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 67d1f82444

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/chattool/projecttemplates.go
Comment on lines +99 to +106
for _, name := range slices.Sorted(maps.Keys(project.defaultParameters)) {
if _, ok := args.Parameters[name]; ok {
continue
}
req.RichParameterValues = append(req.RichParameterValues, codersdk.WorkspaceBuildParameter{
Name: name,
Value: project.defaultParameters[name],
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Revalidate defaults against the current active version

When a project's default template activates a new version after the project was saved, an existing default parameter can become invalid under the new version's type, options, or validation rules. These lines still send the stale value unconditionally, so every create_workspace call that omits that parameter can fail build validation until the project is edited; the neighboring preset path already handles this same active-version drift by checking and skipping stale presets. Validate or safely skip stale parameter defaults before adding them.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same as the thread on #30754: defaults are resolved against the current active version at use time. A stale preset is skipped, and an invalid parameter value fails the build with an error returned to the model, so it can retry without the value.

@jaaydenh

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2d4d5dac4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/chattool/createworkspace.go
@jaaydenh
jaaydenh added this pull request to stack #30892 October 16, 2026 12:17
…ctive version

create_workspace passed an explicit preset_id through unchecked. Workspace
creation claims prebuilds by preset ID alone, so a preset from another
template could bind a workspace outside the project's templates.
@jaaydenh

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2c4c0c3561

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +89 to +90
case err != nil:
logger.Warn(ctx, "failed to load presets for project default preset", slog.Error(err))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Propagate default-preset lookup failures

When GetPresetsByTemplateVersionID fails due to a transient database error, this branch logs the error and continues creating and binding the workspace without the project's configured default preset. Since later create_workspace calls return the already-bound workspace, the model cannot retry and may be left with permanently incorrect parameters or resources. Return a tool error instead of treating lookup failures like stale presets; the parameter lookup failure in presetSetsParameter should be handled similarly.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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.

1 participant