Files
moloapp/tests/example/agent/adk/studio_test.cpp
T
retoorandClaude Sonnet 5.5 33e6ab0d54 feat(clients): adk: agents, tools, runner with hard caps, multi-agent graph, MCP and A2A clients, Studio export, Garden, AP2, triggers
DirectModel over GoogleClient with thought-signature replay, discovery check
script, live verified against the real model (function calling, transfer, MCP).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 04:34:22 +02:00

41 lines
2.4 KiB
C++

// Routes: POST /agent/adk/export, /agent/adk/import, /agent/adk/ap2/validate
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
GoogleRig none(false);
Fixture f(none.client);
auto post = [&](const std::string& path, const std::string& body) {
return f.client->post(path, body, "application/json");
};
auto ex = post("/agent/adk/export", "{\"template\":\"invoice_processing\"}");
check(ex.status == 200 && contains(ex.body, "\"agent_class\":\"LlmAgent\"") &&
contains(ex.body, "invoice_processing"),
"export returns the definition");
check(contains(ex.body, "\"yaml\":"), "export includes yaml");
check(post("/agent/adk/export", "{\"template\":\"nope\"}").status == 422, "unknown template is 422");
std::string def = "{\"agent_class\":\"SequentialAgent\",\"name\":\"flow\",\"sub_agents\":["
"{\"name\":\"a\",\"model\":\"m\",\"instruction\":\"x\",\"tools\":[{\"name\":\"word_count\"}]}]}";
auto im = post("/agent/adk/import", def);
check(im.status == 200 && contains(im.body, "\"word_count\""), "import round-trips a known tool");
check(post("/agent/adk/import", "{\"name\":\"a\",\"tools\":[{\"name\":\"ghost\"}]}").status == 422,
"unknown tool is 422");
check(post("/agent/adk/import", "{\"name\":\"a\",\"agent_class\":\"Evil\"}").status == 422, "bad class is 422");
check(post("/agent/adk/import", "oops").status == 422, "bad json is 422");
std::string intent = "{\"id\":\"i1\",\"description\":\"sleeve\",\"max_amount_minor\":5000,\"currency\":\"EUR\"}";
std::string cart = "{\"id\":\"c1\",\"intent_id\":\"i1\",\"merchant\":\"m\",\"items\":["
"{\"sku\":\"s\",\"quantity\":2,\"unit_amount_minor\":1500}],\"total_minor\":3000,\"currency\":\"EUR\"}";
check(post("/agent/adk/ap2/validate", "{\"intent\":" + intent + ",\"cart\":" + cart + "}").status == 200,
"valid mandate chain is 200");
std::string bad_cart = cart.substr(0, cart.find("3000,")) + "9999," + cart.substr(cart.find("3000,") + 5);
check(post("/agent/adk/ap2/validate", "{\"intent\":" + intent + ",\"cart\":" + bad_cart + "}").status == 422,
"cart total mismatch is 422");
check(post("/agent/adk/ap2/validate", "{}").status == 422, "missing intent is 422");
check(f.client->get("/agent/adk/export").status == 405, "get export is 405");
check(none.mock->send_count() == 0, "none of these routes call Google");
return finish("agent/adk studio");
}