SKILL.md
agent-contracts Backend Runtime
Use this skill when you are implementing an AI agent as a backend service (HTTP API, jobs, or SSE streaming).
Target Shape
- Input:
RequestContext(sessionid, action, params, message, image, resumesession) - Output:
response.responsetype+response.responsedata(+ optionalresponse.response_message) - State slices:
request,response,_internal+ domain slices (e.g.,ticket,orders,workflow)
Recommended Workflow
- Start from
examples/05backendruntime.py. - Define your domain slices and register them:
NodeRegistry.addvalidslice("your_slice"). - Implement nodes with
NodeContract(keepreads/writesminimal). - Build graph with
buildgraphfrom_registry(...)and compile. - Wrap with
AgentRuntimefor request/response execution. - If you need progressive updates, use
StreamingRuntimeand emit SSE viaStreamEvent.to_sse().
Guardrails
- Prefer
response.response_typefor flow termination and client branching. - Avoid writing to
request(discouraged). - Keep large blobs out of state slices; sanitize before LLM routing (see
GenericSupervisor).
References (load only when needed)
docs/getting_started.mddocs/core_concepts.mddocs/cli.mddocs/skills/official/agent-contracts-backend-runtime/references/patterns.md