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.
Key Features
Section titled “Key Features”- 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
Overriding Agent and Session IDs
Section titled “Overriding Agent and Session IDs”Override automatic behavior by providing custom IDs via HTTP headers:
Available Headers
Section titled “Available Headers”| Header | Purpose | Example Value |
|---|---|---|
x-cylestio-session-id | Set custom session identifier | user-123-conversation-1 |
x-cylestio-agent-id | Set custom agent identifier | math-tutor-v2 |
Usage Examples
Section titled “Usage Examples”Custom Agent ID Only:
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:
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 }'Using APIs
Section titled “Using APIs”Anthropic SDK
Section titled “Anthropic SDK”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.