Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add the /aitasks/prompts endpoint#18464

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
hugodutka wants to merge8 commits intomain
base:main
Choose a base branch
Loading
fromhugodutka/bulk-wb-parameters

Conversation

hugodutka
Copy link
Contributor

@hugodutkahugodutka commentedJun 19, 2025
edited
Loading

Add an endpoint to fetch AI task prompts for multiple workspace builds at the same time. A prompt is the value of the "AI Prompt" workspace build parameter. On main, the only way our API allows fetching workspace build parameters is by using the/workspacebuilds/$build_id/parameters endpoint, requiring a separate API call for every build.

The Tasks dashboard fetches Task workspaces in order to show them in a list, and then needs to fetch the value of theAI Prompt parameter for every task workspace (using its latest build id), requiring an additional API call for each list item. This endpoint will allow the dashboard to make just 2 calls to render the list: one to fetch task workspaces, the other to fetch prompts.

Screenshot 2025-06-20 at 11 33 11

Related tocoder/internal#660.

@hugodutkahugodutkaforce-pushed thehugodutka/bulk-wb-parameters branch 5 times, most recently fromaa79b8d toe9e6341CompareJune 20, 2025 10:01
@hugodutkahugodutka marked this pull request as ready for reviewJune 20, 2025 10:11
@hugodutkahugodutkaforce-pushed thehugodutka/bulk-wb-parameters branch frome9e6341 toe4abd39CompareJune 20, 2025 13:32
@hugodutkahugodutkaforce-pushed thehugodutka/bulk-wb-parameters branch frome4abd39 tod80c61aCompareJune 20, 2025 14:07
@hugodutkahugodutka changed the titlefeat: add the /workspacebuilds/parameters endpointfeat: add the /aitasks/prompts endpointJun 20, 2025
id, err := uuid.Parse(strings.TrimSpace(idStr))
if err != nil {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Message: "Invalid build ID format",
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's include the ID that failed

return
}

promptsByBuildID := make(map[string]string)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
promptsByBuildID:=make(map[string]string)
promptsByBuildID:=make(map[string]string,len(buildIDs))


t.Run("EmptyBuildIDs",func(t*testing.T) {
t.Parallel()
client:=coderdtest.New(t,&coderdtest.Options{IncludeProvisionerDaemon:true})
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this, do we?

Suggested change
client:=coderdtest.New(t,&coderdtest.Options{IncludeProvisionerDaemon:true})
client:=coderdtest.New(t,&coderdtest.Options{})

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

We do. coderdtest.CreateWorkspace spawns provisioner jobs under the hood. We wait for them to complete with coderdtest.AwaitWorkspaceBuildJobCompleted.

DefaultValue:"default1",
},
{
Name:codersdk.AITaskPromptParameterName,
Copy link
Contributor

Choose a reason for hiding this comment

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

The provider exposes this, let's rather use that please.
https://github.com/coder/terraform-provider-coder/blob/main/provider/ai_task.go#L22

// Test parameters endpoint as member
prompts,err:=memberClient.AITaskPrompts(ctx,allBuildIDs)
require.NoError(t,err)
require.Len(t,prompts.Prompts,2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please explain why only 2 are expected here.

// @Security CoderSessionToken
// @Produce json
// @Tags AITasks
// @Param build_ids query string true "Comma-separated workspace build IDs"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// @Param build_ids query string true "Comma-separated workspace build IDs"
// @Param build_ids query string true "Comma-separated workspace build IDs" format(uuid)

See

// @Param workspace path string true "Workspace ID" format(uuid)

@@ -1494,6 +1494,10 @@ func New(options *Options) *API {
r.Use(apiKeyMiddleware)
r.Get("/",api.tailnetRPCConn)
})
r.Route("/aitasks",func(r chi.Router) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Blocker: we need to finalize whether this will be a v2 endpoint or experimental.

}
}

filteredParameters := make([]database.WorkspaceBuildParameter, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious about the 0 length here; what's your intent?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dannykoppingdannykoppingdannykopping left review comments

At least 1 approving review is required to merge this pull request.

Assignees

@hugodutkahugodutka

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@hugodutka@dannykopping

[8]ページ先頭

©2009-2025 Movatter.jp