Skip to content

feat(coderd): generate task names based on their prompt #19335

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

Merged
merged 13 commits into from
Aug 19, 2025

Conversation

DanielleMaywood
Copy link
Contributor

@DanielleMaywood DanielleMaywood commented Aug 13, 2025

Closes #18159

If an Anthropic API key is available, we call out to Claude to generate a task name based on the user-provided prompt instead of our random name generator.

A question I have: Should we have an option to disable this even with an API key present? Or should we make this feature opt in even with an API key being present?

@DanielleMaywood DanielleMaywood changed the title Danielle/tasks/generate task name on coderd feat(coderd): generate task names based on their prompt Aug 13, 2025
@DanielleMaywood DanielleMaywood marked this pull request as ready for review August 19, 2025 10:42
}

return aisdk.AnthropicToDataStream(client.Messages.NewStreaming(ctx, anthropic.MessageNewParams{
Model: anthropic.ModelClaude3_5HaikuLatest,
Copy link
Member

Choose a reason for hiding this comment

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

This may be deprecated at some point in future based on https://docs.anthropic.com/en/docs/about-claude/model-deprecations#deprecation-history

I would suggest we allow reading from ANTHROPIC_MODEL. This will also allow administrators to choose a different model if they prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me 👍 In that case, we should probably default to a newer model then.

Copy link
Member

Choose a reason for hiding this comment

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

Haiku is cheap though! For something like this it seems to be "good enough"

},
}

if apiKey := os.Getenv("ANTHROPIC_API_KEY"); apiKey == "" {
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: allow passing in func(key string) string for testing / mocking

Copy link
Member

Choose a reason for hiding this comment

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

Rather than using an env, should we provide API key as argument to the function? Would solve the testing aspect.

Fine to have another exported function like GetAnthropicAPIKeyFromEnv in this package too that can be used at the call-site to avoid magic strings and os.Getenv.


stream, err := anthropicDataStream(ctx, anthropicClient, conversation)
if err != nil {
return fallback, xerrors.Errorf("create anthropic data stream: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Returning a value and error is not common practice and may be surprising to the reader. The way fallback is used here it would make sense to either return error or provide the fallback, but not both. Perhaps returning empty strings in all fallback cases and handling it at the call-site would be preferable?

- "Set up CI/CD pipeline" → "task-setup-cicd-44"

If you cannot create a suitable name:
- Respond with "task-workspace"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Respond with "task-workspace"
- Respond with "task-unnamed"

Suggestion to decouple this from workspaces, if possible.

},
}

if apiKey := os.Getenv("ANTHROPIC_API_KEY"); apiKey == "" {
Copy link
Member

Choose a reason for hiding this comment

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

Rather than using an env, should we provide API key as argument to the function? Would solve the testing aspect.

Fine to have another exported function like GetAnthropicAPIKeyFromEnv in this package too that can be used at the call-site to avoid magic strings and os.Getenv.

@DanielleMaywood DanielleMaywood merged commit 6553771 into main Aug 19, 2025
31 checks passed
@DanielleMaywood DanielleMaywood deleted the danielle/tasks/generate-task-name-on-coderd branch August 19, 2025 13:56
@github-actions github-actions bot locked and limited conversation to collaborators Aug 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tasks: name the workspace/task based on a summary
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy