-
Notifications
You must be signed in to change notification settings - Fork 138
docs(sdk): add docs for client SDK #1867
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?
Conversation
Signed-off-by: Petr Bulánek <[email protected]>
Signed-off-by: Petr Bulánek <[email protected]>
Signed-off-by: Petr Bulánek <[email protected]>
Signed-off-by: Petr Bulánek <[email protected]>
Signed-off-by: Petr Bulánek <[email protected]>
Summary of ChangesHello @PetrBulanek, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly updates and expands the documentation for the AgentStack Client SDK. The primary goal is to provide developers with clearer, more detailed guidance on integrating the SDK, particularly concerning the Agent-to-Agent (A2A) protocol, managing extensions, handling API responses and errors, and constructing messages. The changes aim to streamline the developer experience by offering practical examples and structured explanations of core workflows. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
The pull request significantly enhances the client SDK documentation by providing a more structured overview, detailed guides for A2A integration, error handling, message building, and message part rendering. The new sections on core APIs, extensions, and error helpers are very valuable. However, many of the code examples within the documentation are not self-contained, as they rely on undeclared variables or types. For a better user experience, especially in quickstart and example sections, these snippets should be runnable independently or clearly indicate where the missing variables/types originate.
tomkis
left a comment
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.
Overall good progress, lets fix some naunces.
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Agent Stack API Client | ||
| ### 3. Build user metadata |
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.
I'd add <tip> with more explaination of the concept of "User metadata"
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.
(tip for power users)
|
|
||
| The SDK provides `handleTaskStatusUpdate` to parse A2A `TaskStatusUpdate` and extract structured information: | ||
| When you stream A2A task events, `handleTaskStatusUpdate` maps status updates into actionable UI events. |
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.
We need to cover more thoroughly are opinion on chat interface and streaming.
Eg. why task, why status update, why TaskStatusUpdate actually is used for each token streaming.
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.
(should be a tip for power users)
|
|
||
| - **Service extensions** (LLM, embeddings, MCP, OAuth, secrets): Agent asks for a demand and it is client's responsibility to fulfill the demand. Think of a Dependency Injection where the client is injecting the dependency. | ||
| - **UI extensions** (forms, citations, trajectory visualization): Extends basic A2A messaging with a structure that simplifies working with GUIs. | ||
| ### 1. Handle agent card demands |
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.
I'd start with construction of the A2A clientsdk.
|
|
||
| All API calls return `ApiResult<T>`. Use `unwrapResult` if you want exceptions, and then handle errors with `isHttpError`, `isNetworkError`, `isParseError`, and `isValidationError`. | ||
|
|
||
| ## Extension Helpers at a Glance |
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.
I'd omit this section from here. It makes this unnecessarily complex.
| import { createAuthenticatedFetch } from "agentstack-sdk"; | ||
|
|
||
| async function getAgentClient(baseUrl: string, providerId: string, token?: string) { | ||
| const fetchImpl = token ? createAuthenticatedFetch(token) : fetch; |
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.
Lets explain why createAuthenticatedFetch and that's basically the only reason behind custom factory.
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.
And I believe sending the token is required now.
|
|
||
| ## 2. Resolve agent card demands | ||
|
|
||
| Once you have the client, read the agent card and resolve its demands. |
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.
Point demands to extensions page. It seems very out of context.
|
|
||
| The SDK helps you work with this extension system by providing **typing and parsing** for extensions. Instead of manually parsing extension URIs and metadata, the SDK gives you type-safe functions to extract data from agent cards. | ||
| - A2A extensions and helpers that map agent demands to client fulfillments and UI metadata. |
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.
I would VERY briefly explain concept of demands and fulfillments hre.
| @@ -0,0 +1,56 @@ | |||
| --- | |||
| title: Message Building | |||
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.
A2A Message Building.
|
@PetrBulanek please test the documentation via some coding Agent. basically prompt it to build simple client and as a an input tell him about this docs. Dont provide too much details. Then look into trajectory of the agent if it misses something to figure out some inaccuracies. |
|
|
||
| const api = buildApiClient({ | ||
| baseUrl: "https://your-agentstack-instance.com", | ||
| fetch: createAuthenticatedFetch("token-value"), |
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.
I'd briefly explain where the token-value comes from, as it can be either accessToken or token from createContextToken, if I'm correct. Possibly with a link to more detailed explanation.
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.
I guess I'm not correct :) For ApiClient it's always access token.
|
|
||
| This guide shows how to integrate `@a2a-js/sdk` with the AgentStack SDK helpers. It mirrors the flow used in `agentstack-ui`. | ||
|
|
||
| ## 1. Create an A2A client |
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.
I'd prepend a step explaining how the context token is created, with a link to the "Permissions and Tokens" page, since it is required to create the agent client.
Signed-off-by: jenna-winkler <[email protected]>
|
@jenna-winkler Thanks for the edits! 👍 Are you planning any further updates? Alternatively, can I/should I incorporate the review comments from the guys? |
|
@PetrBulanek yes I’m all set, go ahead and incorporate the review comments from the guys! |
Summary
Notes:
Linked Issues
Closes: #1835
Documentation
If this PR adds new feature or changes existing. Make sure documentation is adjusted accordingly. If the docs is not needed, please explain why.