fix: avoid re-using AuthInstanceID for sub agents#22196
Merged
DanielleMaywood merged 2 commits intomainfrom Feb 19, 2026
Merged
fix: avoid re-using AuthInstanceID for sub agents#22196DanielleMaywood merged 2 commits intomainfrom
AuthInstanceID for sub agents#22196DanielleMaywood merged 2 commits intomainfrom
Conversation
When creating child agents, we re-used `AuthInstanceID`. Unfortunately this causes an issue when the parent agents disconnect. Our `GetWorkspaceAgentByInstanceID` query is defined as follows: ```sql -- name: GetWorkspaceAgentByInstanceID :one SELECT * FROM workspace_agents WHERE auth_instance_id = @auth_instance_id :: TEXT -- Filter out deleted sub agents. AND deleted = FALSE ORDER BY created_at DESC; ``` When the parent agent attempts to refetch its manifest via its `auth_instance_id`, it will fetch the _last created agent with this instance ID_. This will be the last created sub agent, meaning the parent will fetch the manifest for a child, instead of itself.
mafredri
reviewed
Feb 19, 2026
Member
mafredri
left a comment
There was a problem hiding this comment.
I would suggest filtering out sub agents from the aforementioned query as well, should guard us against sub agents ever trying to use the parent auth.
johnstcn
reviewed
Feb 19, 2026
| } | ||
| }) | ||
|
|
||
| t.Run("CreateSubAgentDoesNotInheritAuthInstanceID", func(t *testing.T) { |
Member
There was a problem hiding this comment.
Fails when I revert the change in subagent.go 👍
AuthInstanceIDAuthInstanceID
AuthInstanceIDAuthInstanceID for sub agents
AuthInstanceID for sub agentsAuthInstanceID for sub agents
johnstcn
approved these changes
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
When creating child agents, we re-used
AuthInstanceID. Unfortunately this causes an issue when the parent agents disconnect.Our
GetWorkspaceAgentByInstanceIDquery is defined as follows:When the parent agent attempts to refetch its manifest via its
auth_instance_id, it will fetch the last created agent with this instance ID. This will be the last created sub agent, meaning the parent will fetch the manifest for a child, instead of itself.Solution
AuthInstanceIDfor sub agents.GetWorkspaceAgentByInstanceIDto filter out sub agents.We only need a single approach, but we're going with both to minimize future risk.