Conversation
kotlin rizzcharts updates
There was a problem hiding this comment.
Code Review
This pull request introduces a new Kotlin SDK for A2UI, providing core utilities for schema management, validation, and A2A protocol handling, along with a Kotlin implementation of the Rizzcharts sample agent. The review identifies a critical Kotlin version mismatch between the SDK and the sample project that causes build failures. Additionally, the agent's system prompt configuration incorrectly excludes the A2UI schema and examples, which are necessary for generating valid payloads. Further improvements suggested include using stable raw URLs for schema references and adding logging for JSON parsing failures in the A2A handler to improve debuggability.
| kotlin("jvm") version "2.1.10" | ||
| kotlin("plugin.serialization") version "2.1.10" |
There was a problem hiding this comment.
The agent_sdks/kotlin project specifies Kotlin version 2.1.10, but the samples/agent/adk/rizzcharts/kotlin project, which depends on it, specifies 2.3.0. This version mismatch leads to compilation errors, as indicated in compile_output.txt. For consistent builds and to avoid binary incompatibility issues, both projects should use the same Kotlin version.
plugins {
kotlin("jvm") version "2.3.0"
kotlin("plugin.serialization") version "2.3.0"| @@ -0,0 +1,49 @@ | |||
| plugins { | |||
| kotlin("jvm") version "2.3.0" | |||
There was a problem hiding this comment.
The samples/agent/adk/rizzcharts/kotlin project specifies Kotlin version 2.3.0, but the agent_sdks/kotlin project, which it depends on, specifies 2.1.10. This version mismatch leads to compilation errors, as indicated in compile_output.txt. For consistent builds and to avoid binary incompatibility issues, both projects should use the same Kotlin version. It is recommended to align the agent_sdks/kotlin project to 2.3.0.
plugins {
kotlin("jvm") version "2.3.0"| ROLE_DESCRIPTION, | ||
| WORKFLOW_DESCRIPTION, | ||
| UI_DESCRIPTION, |
There was a problem hiding this comment.
The generateSystemPrompt call sets includeSchema, includeExamples, and validateExamples to false. This prevents the A2UI JSON schema and examples from being included in the agent's system prompt. The WORKFLOW_DESCRIPTION explicitly states that the agent "MUST use the send_a2ui_json_to_client tool" and that the generated JSON "will be validated against the json_schema". Without the schema and examples in the prompt, the agent will struggle to generate valid A2UI JSON payloads, making it ineffective.
| ROLE_DESCRIPTION, | |
| WORKFLOW_DESCRIPTION, | |
| UI_DESCRIPTION, | |
| true, | |
| true, | |
| true, |
| "http://localhost:10002", | ||
| listOf( | ||
| "https://a2ui.org/specification/v0_8/standard_catalog_definition.json", | ||
| "https://github.com/google/A2UI/blob/main/samples/agent/adk/rizzcharts/rizzcharts_catalog_definition.json", |
There was a problem hiding this comment.
Referencing a GitHub blob URL for a schema (https://github.com/google/A2UI/blob/main/samples/agent/adk/rizzcharts/rizzcharts_catalog_definition.json) is not ideal. Blob URLs are meant for viewing files in the repository and are not stable or reliable for programmatic access, as their content type might not be application/json and they can change or become inaccessible. It's best practice to use a raw content URL or a properly hosted schema URL.
| "https://github.com/google/A2UI/blob/main/samples/agent/adk/rizzcharts/rizzcharts_catalog_definition.json", | |
| "https://raw.githubusercontent.com/google/A2UI/main/samples/agent/adk/rizzcharts/rizzcharts_catalog_definition.json", |
| parsedParts.add(dataPart) | ||
| } | ||
| } catch (e: Exception) { | ||
| // Parse error handled silently, might add error part |
There was a problem hiding this comment.
The comment indicates that JSON parsing errors are handled silently. While the code catches the exception, it doesn't log the error or propagate it in a way that would be visible to the caller or for debugging. Silent failures can make it difficult to diagnose issues when the LLM generates malformed JSON. It's better to log the exception at a warning or error level.
} catch (e: Exception) {
logger.warning("Failed to parse A2UI JSON from function call: ${e.message}")
}| } | ||
| return@flatMap parsedParts | ||
| } catch (e: Exception) { | ||
| // Parse error handled silently, fallback to standard raw text propagation |
There was a problem hiding this comment.
Similar to the previous point, JSON parsing errors are handled silently here. This can obscure problems with the LLM's output or the parsing logic. Logging the error would greatly assist in debugging.
} catch (e: Exception) {
logger.warning("Failed to parse A2UI JSON from text: ${e.message}")
// Fallback to standard raw text propagation
}Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Decompose the `handleA2aPost` method into smaller ones. Also, fix the previous commit, which Github messed up.
Directly ported from the Python sample.
a3a64de to
1ebd6d5
Compare
Description
New Kotlin version of the rizzcharts sample using the Kotlin version of the A2UI SDK.
Pre-launch Checklist