Portal Community

Context Window Structure

An Octopus context window is a structured list of messages, each with a role and content. The LLM processes them in order:

// Example context window for one agent turn:
[
  {
    "role": "system",
    "content": "You are Aria, the HR specialist for Acme Corp. Your domain is..."
    // ← SystemPrompt from AgentComposite
  },
  {
    "role": "system",
    "content": "[Procedure: vendor_onboarding]\nTo onboard a vendor, follow these steps: ..."
    // ← Matched procedure from procedural memory
  },
  {
    "role": "context",    // treated as system in most LLM APIs
    "content": "[Retrieved Knowledge]\nSource: HR Policy 2025.pdf\n..."
    // ← Semantic memory retrieval results
  },
  {
    "role": "context",
    "content": "[Past Conversation Context]\n2025-03-14: User asked about leave balance..."
    // ← Episodic memory snippets
  },
  {
    "role": "user",
    "content": "Hi, can you help me add a new supplier?"
    // ← Turn 1 of message history
  },
  {
    "role": "assistant",
    "content": "Of course! To add a new supplier, I'll need the supplier name..."
    // ← Turn 1 response (from history)
  },
  {
    "role": "user",
    "content": "Onboard TechCorp as a new vendor, contact is procurement@techcorp.com, contract CTR-2025-001"
    // ← Current user message (turn 2)
  }
]

Role Mapping per LLM Provider

Octopus RoleAnthropic ClaudeOpenAI/Azure
systemsystemsystem
contextuser (injected as context block)system
useruseruser
assistantassistantassistant
tooltool_resulttool
Anthropic Context Blocks

Anthropic Claude does not support multiple system messages in the same call. Octopus handles this by merging all system-role content into a single system message for Anthropic providers, separated by \n---\n dividers.

Context Window Size Per Provider

ProviderModelContext WindowRecommended Working Budget
Anthropicclaude-sonnet-4-6200,000 tokens150,000 tokens
Anthropicclaude-opus-4200,000 tokens150,000 tokens
OpenAIgpt-4o128,000 tokens100,000 tokens
Azure OpenAIgpt-4o128,000 tokens100,000 tokens
Ollamallama3:70b8,192 tokens6,000 tokens