Skip to content

Reuse token and better relaycast SDK usage#59

Merged
khaliqgant merged 3 commits intomainfrom
better-relaycast-usage
Mar 6, 2026
Merged

Reuse token and better relaycast SDK usage#59
khaliqgant merged 3 commits intomainfrom
better-relaycast-usage

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Mar 4, 2026

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

Comment on lines +56 to +58
function registrationCacheKey(baseUrl: string | undefined, apiKey: string, agentName: string): string {
return `${baseUrl ?? ''}|${apiKey}|${agentName.toLowerCase()}`;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 registrationCacheKey omits agentType, causing cross-type cache collisions

The registrationCacheKey at relaycast-provider-helpers.ts:56-58 builds the cache key from baseUrl|apiKey|agentName but does NOT include agentType. This means if the same agent name is registered first as 'agent' (via createRelaycastClientregisterAgentToken) and then as 'human' (via getDashboardAgentTokenregisterAgentToken), the second call returns the cached result from the first registration, silently ignoring the different agentType.

This is reachable when config.agentToken is missing (the exact scenario this PR targets): a message sent via getWriterClient as the project name without a matching projectIdentity will register with type 'agent' (senderRegistrationType returns 'agent' at relaycast-provider-helpers.ts:190), and a subsequent GET /api/relay-config call will invoke getDashboardAgentToken with agentType: 'human' (relaycast-provider-helpers.ts:355) but receive the previously cached 'agent' registration.

Suggested change
function registrationCacheKey(baseUrl: string | undefined, apiKey: string, agentName: string): string {
return `${baseUrl ?? ''}|${apiKey}|${agentName.toLowerCase()}`;
}
function registrationCacheKey(baseUrl: string | undefined, apiKey: string, agentName: string, agentType: string): string {
return `${baseUrl ?? ''}|${apiKey}|${agentName.toLowerCase()}|${agentType}`;
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@khaliqgant khaliqgant merged commit dd39cb8 into main Mar 6, 2026
1 check passed
@khaliqgant khaliqgant deleted the better-relaycast-usage branch March 6, 2026 17:10
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