Skip to content

InvokeAgentRuntimeCommand

Source: src/AWS/BedrockAgentCore/InvokeAgentRuntimeCommand.ts

Runs a shell command inside an agent hosted in an AgentCore Runtime and streams back the command output.

Bind a Runtime inside a function runtime to execute commands in the hosted agent’s sandbox (requests with the same runtimeSessionId land on the same sandbox). Provide AgentCore.InvokeAgentRuntimeCommandHttp on the Function effect to implement the binding.

// init
const invokeCommand = yield* AgentCore.InvokeAgentRuntimeCommand(runtime);
return {
fetch: Effect.gen(function* () {
// runtime
const response = yield* invokeCommand({
runtimeSessionId: "session-0000000000000000000000000000000001",
body: { command: "echo hello" },
});
const chunks = yield* Stream.runCollect(response.stream);
return HttpServerResponse.json({ chunks: Array.from(chunks) });
}),
};