Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
fix(sdk-swift): decode action invocations by invocation_id#335
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1178,14 +1178,56 @@ public struct CompleteInvocationRequest: Codable, Equatable, Sendable { | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| public struct ActionInvocation: Codable, Equatable, Sendable { | ||||||||||||||||||||||||||||||
| public let id: String | ||||||||||||||||||||||||||||||
| /// The hosted API identifies an invocation as `invocation_id` on every | ||||||||||||||||||||||||||||||
| /// route that returns this record (invoke ack, status poll, completion), | ||||||||||||||||||||||||||||||
| /// matching ``InvokeActionResult``. A plain `id` is accepted as an alias so | ||||||||||||||||||||||||||||||
| /// a record echoed by another surface still decodes. | ||||||||||||||||||||||||||||||
| public let invocationId: String | ||||||||||||||||||||||||||||||
| public let actionName: String? | ||||||||||||||||||||||||||||||
| public let status: String | ||||||||||||||||||||||||||||||
| public let input: [String: JSONValue]? | ||||||||||||||||||||||||||||||
| public let output: [String: JSONValue]? | ||||||||||||||||||||||||||||||
| public let error: String? | ||||||||||||||||||||||||||||||
| public let createdAt: String? | ||||||||||||||||||||||||||||||
| public let updatedAt: String? | ||||||||||||||||||||||||||||||
| public let completedAt: String? | ||||||||||||||||||||||||||||||
| public let durationMs: Int? | ||||||||||||||||||||||||||||||
| private enum CodingKeys: String, CodingKey { | ||||||||||||||||||||||||||||||
| case invocationId, id, actionName, status, input, output, error, createdAt, updatedAt, completedAt, durationMs | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| public init(from decoder: Decoder) throws { | ||||||||||||||||||||||||||||||
| let container = try decoder.container(keyedBy: CodingKeys.self) | ||||||||||||||||||||||||||||||
| if let invocationId = try container.decodeIfPresent(String.self, forKey: .invocationId) { | ||||||||||||||||||||||||||||||
| self.invocationId = invocationId | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| self.invocationId = try container.decode(String.self, forKey: .id) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| actionName = try container.decodeIfPresent(String.self, forKey: .actionName) | ||||||||||||||||||||||||||||||
| status = try container.decode(String.self, forKey: .status) | ||||||||||||||||||||||||||||||
| input = try container.decodeIfPresent([String: JSONValue].self, forKey: .input) | ||||||||||||||||||||||||||||||
| output = try container.decodeIfPresent([String: JSONValue].self, forKey: .output) | ||||||||||||||||||||||||||||||
| error = try container.decodeIfPresent(String.self, forKey: .error) | ||||||||||||||||||||||||||||||
| createdAt = try container.decodeIfPresent(String.self, forKey: .createdAt) | ||||||||||||||||||||||||||||||
| updatedAt = try container.decodeIfPresent(String.self, forKey: .updatedAt) | ||||||||||||||||||||||||||||||
| completedAt = try container.decodeIfPresent(String.self, forKey: .completedAt) | ||||||||||||||||||||||||||||||
| durationMs = try container.decodeIfPresent(Int.self, forKey: .durationMs) | ||||||||||||||||||||||||||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: When the API returns a negative (Based on your team's feedback about nonnegative Prompt for AI agents
Suggested change
| ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| public func encode(to encoder: Encoder) throws { | ||||||||||||||||||||||||||||||
| var container = encoder.container(keyedBy: CodingKeys.self) | ||||||||||||||||||||||||||||||
| try container.encode(invocationId, forKey: .invocationId) | ||||||||||||||||||||||||||||||
| try container.encodeIfPresent(actionName, forKey: .actionName) | ||||||||||||||||||||||||||||||
| try container.encode(status, forKey: .status) | ||||||||||||||||||||||||||||||
| try container.encodeIfPresent(input, forKey: .input) | ||||||||||||||||||||||||||||||
| try container.encodeIfPresent(output, forKey: .output) | ||||||||||||||||||||||||||||||
| try container.encodeIfPresent(error, forKey: .error) | ||||||||||||||||||||||||||||||
| try container.encodeIfPresent(createdAt, forKey: .createdAt) | ||||||||||||||||||||||||||||||
| try container.encodeIfPresent(updatedAt, forKey: .updatedAt) | ||||||||||||||||||||||||||||||
| try container.encodeIfPresent(completedAt, forKey: .completedAt) | ||||||||||||||||||||||||||||||
| try container.encodeIfPresent(durationMs, forKey: .durationMs) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| // MARK: - Directory, routing, A2A, certification, console | ||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idaccessorWhen an existing Swift consumer upgrades and accesses the documented public model as
invocation.id, replacing that property withinvocationIdmakes the consumer fail to compile even though decodinginvocation_iddoes not require removing the old API. Keep a deprecated computedidalias forwarding toinvocationId; otherwise this must be staged and documented as a major migration rather than shipped as an unrecorded fix.AGENTS.md reference: AGENTS.md:L40-L44
Useful? React with 👍 / 👎.