fix(sdk-rust): tolerate public agent payloads#127
Merged
khaliqgant merged 1 commit intomainfrom May 10, 2026
Merged
Conversation
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/sdk-rust/src/relay.rs (1)
545-551:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy liftAvoid using empty-string sentinel for
created_atin reclaim flow.On Line 550, defaulting to
""produces a non-date value in a timestamp field and forces downstream special-casing. This should be represented as optional instead of fabricated.Proposed fix
# packages/sdk-rust/src/relay.rs - created_at: agent.created_at.unwrap_or_default(), + created_at: agent.created_at,# packages/sdk-rust/src/types.rs #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CreateAgentResponse { pub id: String, pub name: String, pub token: String, pub status: String, - pub created_at: String, + #[serde(default)] + pub created_at: Option<String>, }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/sdk-rust/src/relay.rs` around lines 545 - 551, The CreateAgentResponse currently uses agent.created_at.unwrap_or_default() which yields an empty-string sentinel for created_at; instead make created_at an Option/nullable in CreateAgentResponse and propagate the optional value from agent.created_at (do not call unwrap_or_default). Update the CreateAgentResponse struct/type to accept an Option<String>/Option<DateTime> (matching the domain type) and set created_at: agent.created_at so downstream code can handle absence without special-casing an empty string.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/sdk-rust/src/relay.rs`:
- Around line 545-551: The CreateAgentResponse currently uses
agent.created_at.unwrap_or_default() which yields an empty-string sentinel for
created_at; instead make created_at an Option/nullable in CreateAgentResponse
and propagate the optional value from agent.created_at (do not call
unwrap_or_default). Update the CreateAgentResponse struct/type to accept an
Option<String>/Option<DateTime> (matching the domain type) and set created_at:
agent.created_at so downstream code can handle absence without special-casing an
empty string.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 05e43b61-b947-408c-91d1-6dad4bfaf355
📒 Files selected for processing (6)
openapi.yamlpackages/sdk-rust/src/lib.rspackages/sdk-rust/src/relay.rspackages/sdk-rust/src/types.rspackages/sdk-rust/tests/parity.rspackages/server/src/engine/agent.ts
|
Preview deployed!
This preview shares the staging database and will be cleaned up when the PR is merged or closed. Run E2E testsnpm run e2e -- https://pr127-api.relaycast.dev --ciOpen observer dashboard |
a9df731 to
0372c29
Compare
0372c29 to
0198e9d
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fix the upstream Relaycast SDK/API mismatch that forced AgentWorkforce/relay#830 to work around
RelayCast::register_or_get_agent()with raw JSON.The Rust SDK
Agenttype previously modeled internal database fields (workspace_id,token_hash, requiredcreated_at) that are not part of the publicGET /v1/agents/{name}response. When registration hit a 409 andregister_or_get_agent()tried to reclaim the existing agent,get_agent()failed to deserialize the public payload before token rotation could complete.This PR updates the Rust SDK to model the public agent payload, makes optional response fields tolerant during deserialization, and keeps the server/OpenAPI/shared type contract aligned by returning/documenting
created_at,last_seen, and detail-response channel memberships.Changes
workspace_idandtoken_hashrequirements from the Rust SDKAgenttype.metadata,created_at,last_seen, andchannelstolerant of public/deployed payload variance.AgentChannelMembershipand export it from the Rust SDK.register_or_get_agent()reclaim on eitheragent_already_existsor HTTP 409.CreateAgentResponse.created_atfall back tolast_seenwhen the server payload omitscreated_at.GET /v1/agents/{name}payload shape.created_atin public server agent list/get/update responses.openapi.yamlfor agentlast_seen, detail-responsechannels, and channel membership role values.@relaycast/typesasserts the public agent shape instead of internal fields.Validation
cargo testcargo clippy --all-targetsnpm test -w @relaycast/typesnpm run build -w @relaycast/typesnpm test -w @relaycast/sdk -- src/__tests__/relay.test.ts src/__tests__/strict-identity.test.tsnpm run build -w @relaycast/servernpm test -w @relaycast/server -- src/routes/__tests__/agent.test.tsnpm run lint -w @relaycast/server(passes with existing warnings)git diff --checkNote:
cargo fmt --checkstill reports pre-existing formatting drift inpackages/sdk-rust/src/agent.rs, which this PR intentionally leaves untouched.