stream_prompt() starts a prompt and invokes your callback as events arrive.
sdk.stream_prompt("Explain closures in one sentence.", [](const autohand::SdkEvent& event) {
if (event.type == "message_update") {
std::cout << event.text_delta();
}
});message_update: token or text delta.message_end: final message content.tool_start: a tool started.tool_update: streaming tool output.tool_end: a tool completed.permission_request: host approval is required.error: agent or transport error.
sdk.stream_prompt("Run the relevant tests.", [&](const autohand::SdkEvent& event) {
if (event.type == "permission_request") {
sdk.permission_response(event.request_id(), "allow_once");
}
});Production hosts should route permission requests to a human, policy engine, or trusted automation boundary.
Use Agent and Run when you want streaming and a final result:
auto run = agent.send("Summarize this repository.");
run.stream([](const autohand::SdkEvent& event) {
std::cout << event.type << "\n";
});
auto result = run.wait();
std::cout << result.text << "\n";