Reuse token and better relaycast SDK usage#59
Conversation
| function registrationCacheKey(baseUrl: string | undefined, apiKey: string, agentName: string): string { | ||
| return `${baseUrl ?? ''}|${apiKey}|${agentName.toLowerCase()}`; | ||
| } |
There was a problem hiding this comment.
🟡 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 createRelaycastClient → registerAgentToken) and then as 'human' (via getDashboardAgentToken → registerAgentToken), 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.
| 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}`; |
Was this helpful? React with 👍 or 👎 to provide feedback.
Uh oh!
There was an error while loading. Please reload this page.