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

fix(coderd/agentapi): make sub agent slugs more unique#18581

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

Merged
DanielleMaywood merged 2 commits intomainfromdm-subagent-slugs
Jun 25, 2025

Conversation

DanielleMaywood
Copy link
Contributor

The incorrect assumption that slugs were unique per-agent was made when the subagent API was implemented. Whilst this PR doesn't completely enforce that, we instead compute a stable hash to prefix the slug that should provide a reasonable level of probability that the slug will be unique.

The incorrect assumption that slugs were unique per-agent was made whenthe subagent API was implemented. Whilst this PR doesn't completelyenforce that, we instead compute a stable hash to prefix the slug thatshould provide a reasonable level of probability that the slug will beunique.
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses the incorrect assumption of unique subagent slugs per agent by prefixing each slug with a stable CRC32 hash computed from the subagent name and original slug.

  • Updated test expectations in subagent_test.go to check for the new hash-prefixed slug format.
  • Modified the slug generation in subagent.go to compute and append a CRC32 hash to the original slug.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

FileDescription
coderd/agentapi/subagent_test.goUpdated test cases to expect new hash-prefixed slugs.
coderd/agentapi/subagent.goAdded CRC32-based hash computation to generate unique slugs.

@DanielleMaywoodDanielleMaywood marked this pull request as ready for reviewJune 25, 2025 15:42
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

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

Except for my confidence in crc32, otherwise LGTM 👍

// there is no database-layer enforcement of this constraint.
// We can get around this by creating a slug that *should* be
// unique (at least highly probable).
slugHash := fmt.Sprintf("%08x", crc32.ChecksumIEEE([]byte(subAgent.Name+"/"+app.Slug)))
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should use crypto/sha256 or hash/fnv instead? Crc32 isn’t particularly good for collision prevention.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sounds good! I've made the change in3e9f2f3.

Now we use a sha256 hash, encode it with base32 encoding, truncate it to 8 characters, then lower case it.

@DanielleMaywoodDanielleMaywood merged commit6c713d5 intomainJun 25, 2025
34 checks passed
@DanielleMaywoodDanielleMaywood deleted the dm-subagent-slugs branchJune 25, 2025 16:36
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 25, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

Copilot code reviewCopilotCopilot left review comments

@mafredrimafredrimafredri approved these changes

@deansheatherdeansheatherAwaiting requested review from deansheather

Assignees

@DanielleMaywoodDanielleMaywood

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@DanielleMaywood@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp