WebHost.Systems WebHost.Systems/docs/skills/01_AGENT_MANAGEMENT.md
An agent is a logical AI service owned by a single user. It has a selected runtime provider, configuration, and an optional active deployment. Agents are the top-level organizat…

01 — Agent Management

Purpose: How to create, configure, update, disable, and delete agents. Covers the agent status state machine, provider configuration, and RLS isolation rules.

What Is an Agent?

An agent is a logical AI service owned by a single user. It has a selected runtime provider, configuration, and an optional active deployment. Agents are the top-level organizational unit in WebHost.Systems.

Agent Fields

FieldTypeRequiredDescription
namestringYesUnique per user
descriptionstringNoHuman-readable description
frameworkstringYesInformational (e.g., "langchain", "custom")
runtime_providerenumYescloudflare or agentcore
env_var_keysstring[]NoSecret key names (values in Vault)
provider_configJSONBNoRuntime-specific configuration
statusenumAutoManaged by the platform

Status State Machine

                    deploy success
  created -----> deploying ---------> active
     |               |                  |
     |          deploy fail         disable()
     |               |                  |
     |               v                  v
     |             error            disabled
     |               |                  |
     +---------------+--- re-deploy ---+
StatusMeaningInvocations Allowed
createdAgent exists but never deployedNo
deployingDeployment in progressNo
activeActive deployment readyYes
errorLast deployment failedNo
disabledManually disabled by userNo

Invariant: Only active agents accept invocations.

CRUD Operations

Create Agent

curl -X POST "$SUPABASE_URL/rest/v1/rpc/create_agent" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-agent",
    "framework": "custom",
    "runtime_provider": "cloudflare",
    "env_var_keys": ["OPENAI_API_KEY"]
  }'

Update Agent

curl -X POST "$SUPABASE_URL/rest/v1/rpc/update_agent" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{ "agent_id": "<uuid>", "description": "Updated description" }'

List Agents

curl "$SUPABASE_URL/rest/v1/agents?select=*" \
  -H "Authorization: Bearer $TOKEN"

RLS ensures only the authenticated user's agents are returned.

Disable Agent

curl -X POST "$SUPABASE_URL/rest/v1/rpc/disable_agent" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{ "agent_id": "<uuid>" }'

Sets status to disabled. All invocations will be rejected until re-enabled.

Delete Agent (Soft)

curl -X POST "$SUPABASE_URL/rest/v1/rpc/delete_agent" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{ "agent_id": "<uuid>" }'

Soft-deletes the agent. Provider resources should be revoked where possible.

Provider Config

The provider_config JSONB field holds runtime-specific settings:

Cloudflare:

{
  "worker_name": "agent-<uuid>",
  "durable_object_namespace": "sessions",
  "route_pattern": "agents.example.com/<uuid>/*"
}

AgentCore:

{
  "runtime_id": "arn:aws:bedrock-agentcore:...",
  "container_port": 8080,
  "idle_timeout_seconds": 300,
  "network_mode": "egress_only"
}

RLS Isolation

Every query against the agents table is filtered by:

auth.uid() = user_id
  • Users can only see, update, and delete their own agents.

  • The user_id field is set automatically from auth.uid() on creation.

  • No admin bypass exists in MVP.

Checklist

  • [ ] Agent name is unique within the user's namespace

  • [ ] runtime_provider matches the user's tier (AgentCore requires paid tier)

  • [ ] Secret key names in env_var_keys have corresponding Vault entries

  • [ ] Status transitions follow the state machine (no skipping states)

  • [ ] RLS policy is active on the agents table

  • [ ] Soft-delete revokes provider resources where feasible

Open in the interactive atlas