HTTP Server
Python, TypeScript, Go, C#, and Java expose host-native agent HTTP servers. Rust provides the shared bind, request, and route policy helpers; the optional ish-server binary is a Control Plane server, not the same agent HTTP adapter. The host servers use the shared Rust policy and expose /health, /run, /stream, /events, and /approvals/* endpoints.
- Python
- TypeScript
- Rust
- Go
- C#
- Java
import asyncio
from ish import Agent, OpenAICompatibleModel
from ish.integrations.server import HTTPServer
agent = Agent(
name="api_agent",
model=OpenAICompatibleModel(model="gpt-4o-mini"),
instructions="Serve agent requests over HTTP.",
)
async def main() -> None:
server = HTTPServer(agent=agent, host="127.0.0.1", port=8000, auth_token="dev-token")
await server.serve_forever()
asyncio.run(main())
import { Agent, AgentHttpServer, HttpServerPolicy, IshClient } from "ish-harness";
const client = new IshClient();
const policy = new HttpServerPolicy(client);
policy.validateBind("127.0.0.1", true);
const agent = new Agent({
name: "api_agent",
model: { provider: "openai_chat", name: "gpt-4o-mini" },
instructions: "Serve agent requests over HTTP.",
});
const server = new AgentHttpServer(
client,
{
name: "api_agent",
run: (prompt) => agent.run(prompt),
},
{ host: "127.0.0.1", port: 8000, authToken: "dev-token" },
);
await server.listen();
console.log("HTTP server listening on 127.0.0.1:8000");
use ish_harness::data_plane::protocols::{
plan_http_route, validate_http_request, validate_http_server_bind,
};
use ish_server::spawn_studio_server;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Shared Rust bind & request policy for custom Axum/Hyper servers:
validate_http_server_bind("127.0.0.1", true)?;
let _route = plan_http_route("POST", "/run");
let _ = validate_http_request;
// Or spawn the built-in Axum Control Plane API server:
let handle = spawn_studio_server("127.0.0.1", 8080, "./data/traces/traces.db", ".")?;
println!("Server running on port {}", handle.port());
Ok(())
}
package main
import (
"context"
"fmt"
"time"
ish "github.com/ish-harness/ish-harness/sdks/go"
)
type adapter struct {
agent *ish.Agent
}
func (a adapter) Run(ctx context.Context, prompt string) (any, error) {
return a.agent.Run(ctx, prompt)
}
func (a adapter) Stream(ctx context.Context, prompt string, onEvent ish.StreamEventHandler) (map[string]any, error) {
return a.agent.Stream(ctx, prompt, onEvent)
}
func main() {
client, err := ish.NewClient()
if err != nil {
panic(err)
}
defer client.Close()
agent := ish.NewAgent(client, ish.AgentRunRequest{
Model: &ish.AgentModel{Provider: "openai_chat", Name: "gpt-4o-mini"},
SystemPrompt: ish.StringPtr("Serve agent requests over HTTP."),
})
server, err := ish.NewAgentHttpServer(
client,
adapter{agent: agent},
"127.0.0.1",
8000,
ish.StringPtr("dev-token"),
1<<20,
15*time.Second,
)
if err != nil {
panic(err)
}
server.Start()
defer server.Close()
fmt.Printf("HTTP server listening at http://%s\n", server.Addr())
}
using System;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using Ish.Harness; // AgentHttpServer is in the optional Ish.Harness.AspNetCore project
using var client = new IshClient();
var policy = new HttpServerPolicy(client);
var adapter = new HttpAgentAdapter
{
Name = "api_agent",
RunAsync = (prompt, ct) =>
{
var result = client.Run(new AgentRunRequest
{
Model = new AgentModel { Provider = "openai_chat", Name = "gpt-4o-mini" },
SystemPrompt = "Serve agent requests over HTTP.",
UserPrompt = prompt
}, ct);
return ValueTask.FromResult(JsonNode.Parse(result.GetRawText()));
}
};
await using var server = new AgentHttpServer(
client,
adapter,
host: "127.0.0.1",
port: 8000,
authToken: "dev-token");
await server.StartAsync();
Console.WriteLine("HTTP server listening on 127.0.0.1:8000");
import com.fasterxml.jackson.databind.JsonNode;
import io.github.ishharness.AgentHttpServer;
import io.github.ishharness.HttpAgentAdapter;
import io.github.ishharness.HttpServerPolicy;
import io.github.ishharness.IshClient;
import java.nio.file.Path;
public class ServerExample {
public static void main(String[] args) throws Exception {
try (var client = new IshClient(Path.of(System.getenv("ISH_NATIVE_LIBRARY")))) {
var policy = new HttpServerPolicy(client);
var adapter =
new HttpAgentAdapter(
"api_agent",
prompt ->
client.runAgent(
new IshClient.AgentRequest(
"gpt-4o-mini",
"Serve agent requests over HTTP.",
prompt)
.provider("openai_chat")));
try (var server = new AgentHttpServer(client, adapter, "127.0.0.1", 8000, "dev-token")) {
server.start();
System.out.println("HTTP server listening on port " + server.port());
}
}
}
}
Deployment notes
- Non-loopback binds (
0.0.0.0or external interfaces) require a bearer authentication token —HttpServerPolicy/validate_http_server_bindrejects non-loopback binds whenauthTokenis missing or blank. - Put TLS termination and rate limiting at a reverse proxy or API gateway.
- Set bounded request-body sizes and timeouts. Rust normalizes the request-read timeout to 15 seconds by default and a 100 ms minimum for every SDK adapter. It also defaults approval-webhook delivery to 5 seconds and clamps finite webhook timeouts to 100 ms–30 seconds. Host transports enforce request-read deadlines; transport-specific behavior after a timeout can differ.
- In C#,
AgentHttpServerlives in the optionalIsh.Harness.AspNetCoreproject (sdks/csharp/aspnet/Ish.AspNetCore.csproj) using Kestrel. - Validate
auth_tokenhandling before public exposure.
Approval webhooks
All five SDK HTTP servers support an optional approval webhook_url (TypeScript webhookUrl) and public_base_url. Rust builds the canonical approval notification and delivers it with bounded timeout and concurrency. A 202 approval_required response includes resume_url, constructed from the configured public base URL and approval snapshot identifier, so the approval can be resumed through the server API.