Discover and Select Agents¶
Query visible agent catalog cards in the current workspace, check each entry’s object kind, status, and available actions, and record the agent ID and source workspace ID needed for downstream calls.
Task flow¶
Workspace client
│
▼
Page through agent catalog cards
│
▼
Check kind (agent), status, and actions
│
▼
Save agent ID and source workspace ID
Prerequisites¶
Complete the endpoint, personal access token, and workspace setup in Use the SDK.
Query agent catalog cards¶
Run the example below to fetch up to 20 catalog cards in the current workspace and print each entry’s kind, source workspace ID, agent ID, name, status, and available actions. Pass an offset query option to read subsequent pages until you reach total or receive an empty page.
import os
import moi_product_sdk as sdk
client = sdk.new_with_personal_access_token(
os.environ["PRODUCT_API_BASE_URL"],
os.environ["PRODUCT_API_KEY"],
)
workspace_id = os.environ["WORKSPACE_ID"]
page = client.agents(workspace_id).list_agent_catalog_cards(
sdk.with_query_param("limit", "20"),
sdk.with_query_param("offset", "0"),
)
print("total:", page.total, "limit:", page.limit, "offset:", page.offset)
for card in page.items:
print(
card.kind,
card.workspace_id,
card.id,
card.name,
card.status,
list(card.actions),
)
package main
import (
"context"
"fmt"
"log"
"os"
sdk "github.com/matrixorigin/matrixflow/sdk/go-sdk"
)
func main() {
client, err := sdk.NewWithPersonalAccessToken(
os.Getenv("PRODUCT_API_BASE_URL"),
os.Getenv("PRODUCT_API_KEY"),
)
if err != nil {
log.Fatal(err)
}
defer client.Close()
page, err := client.Agents(os.Getenv("WORKSPACE_ID")).ListAgentCatalogCards(
context.Background(),
sdk.WithQueryParam("limit", "20"),
sdk.WithQueryParam("offset", "0"),
)
if err != nil {
log.Fatal(err)
}
fmt.Println("total:", page.GetTotal(), "limit:", page.GetLimit(), "offset:", page.GetOffset())
for _, card := range page.GetItems() {
fmt.Println(
card.GetKind(),
card.GetWorkspaceId(),
card.GetId(),
card.GetName(),
card.GetStatus(),
card.GetActions(),
)
}
}
The catalog can include both individual agents (agent) and teams, as well as system-provided entries. For single-agent invocation and version maintenance, choose an entry whose kind is agent and record both its id and workspace_id.