Skip to content

Agent/Session Management

Cylestio Perimeter supports both automatic and manual management of Agent IDs and Session IDs. By default, it automatically generates unique Agent and Session IDs for each conversation. However, you can override this behavior at any time by explicitly specifying your own Agent ID or Session ID via HTTP headers.

  • Automatic Session Detection: Sessions are automatically detected based on message history and conversation patterns
  • Automatic Agent Identification: Agents are automatically identified using prompt hashing
  • Manual Overrides: Custom session and agent IDs can be provided via HTTP headers
  • Consistent Tracking: All events maintain consistent session and agent identifiers throughout the conversation

Override automatic behavior by providing custom IDs via HTTP headers:

HeaderPurposeExample Value
x-cylestio-session-idSet custom session identifieruser-123-conversation-1
x-cylestio-agent-idSet custom agent identifiermath-tutor-v2

Custom Agent ID Only:

Terminal window
curl -X POST "http://localhost:3000/v1/messages" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-H "x-cylestio-agent-id: math-tutor-v2" \
-d '{
"model": "claude-3-sonnet-20240229",
"system": "You are a math tutor.",
"messages": [
{"role": "user", "content": "What is 2+2?"}
],
"max_tokens": 100
}'

Custom Both IDs:

Terminal window
curl -X POST "http://localhost:3000/v1/messages" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-H "x-cylestio-session-id: user-123-lesson-1" \
-H "x-cylestio-agent-id: math-tutor-v2" \
-d '{
"model": "claude-3-sonnet-20240229",
"system": "You are a math tutor.",
"messages": [
{"role": "user", "content": "What is 2+2?"}
],
"max_tokens": 100
}'
from anthropic import Anthropic
client = Anthropic(
base_url=base_url,
default_headers={
"x-cylestio-agent-id": "math-agent",
"x-cylestio-session-id": "math-agent-session-2",
},
)
message = client.messages.create(
model="claude-3-sonnet-20240229",
max_tokens=1024,
system="You are a math tutor.",
messages=[{"role": "user", "content": "Hello, Claude!"}],
)

Note: OpenAI SDK example is coming soon.