At the core of Cortex’s intelligence is its chain of thought reasoning process. This approach enables SWAI agents to break down complex problems into manageable steps, making decisions that feel natural and well-considered.
Step-by-step processing
Decomposes complex tasks into logical sequences of thought
Transparent reasoning
Makes the agent’s decision process understandable to users
Self-reflection
Evaluates its own reasoning for continuous improvement
Context integration
Incorporates relevant memories and environmental factors
Let’s see how Cortex processes a signal and makes decisions through a step-by-step example:
Initial Signal
First, let’s look at the input signal from Synapse:
Copy
{ timestamp: 1714531200, description: "User replied to a tweet", priority: 4, labels: ["user", "twitter", "engagement"], metadata: { userId: "1234567890", tweetId: "987654321", replyContent: "Great point! I completely agree." }}
Decision Making Process
Cortex starts the decision-making process by analyzing the input:
Copy
{ id: 'm7t0j9rqhkob10o', role: 'user', content: [ { type: 'text', text: '<stateValue>thinking</stateValue><context><event>{ timestamp: 1714531200, description: "User replied to a tweet", priority: 4, labels: ["user", "twitter", "engagement"], metadata: { userId: "1234567890", tweetId: "987654321", replyContent: "Great point! I completely agree." }}</event><userInfo></userInfo></context><goal>You are the decision making part of a brain. \n' + ' \n' + ' You decide if you want to do something with the event or ignore it. \n' + ' \n' + ' Take into account the context of the event, the previous events and the current state of the brain. \n' + '\n' + ' Make sure you have all the user information you need before you make a decision.\n' + ' \n' + ' The event format is like this: \n' + ' interface Signal {\n' + ' timestamp: number; // When the event occurred\n' + ' description: string; // Human-readable event description\n' + ' priority: number; // Importance level (1-5)\n' + ' labels: string[]; // Event categories\n' + ' metadata: object; // Additional context\n' + ' }</goal>\n' + '\n' + 'How would you achieve the goal? Think step-by-step.' } ], providerMetadata: undefined, timestamp: 1741003504694, episodeId: 'episode-m7t0j04tprrwj2t'}
Initial Analysis
Cortex analyzes the data and creates an initial plan:
Copy
{ id: 'm7t0jfojyitmfib', role: 'assistant', content: [ { type: 'text', text: 'To achieve the goal of deciding whether to act on the event or ignore it, I would follow these steps:\n' + '\n' + '1. **Analyze the Event**: \n' + ' - Review the event details provided:\n' + ' - **Timestamp**: 1714531200 (indicates when the event occurred).\n' + ' - **Description**: "User replied to a tweet" (indicates the nature of the event).\n' + ' - **Priority**: 4 (suggests this is a relatively important event).\n' + ' - **Labels**: ["user", "twitter", "engagement"] (indicates the context and type of interaction).\n' + ' - **Metadata**: Contains userId "1234567890", tweetId "987654321", and replyContent "Great point! I completely agree."\n' + '\n' + '2. **Consider User Information**: \n' + ' - Check if there is any relevant user information available. In this case, the `userInfo` is empty, which means I have no additional context about the user (e.g., their preferences, past interactions, or engagement history).\n' + '\n' + '3. **Evaluate Previous Events**: \n' + " - Since there is no information about previous events, I cannot assess any patterns or trends in the user's behavior or engagement. This limits my ability to make a fully informed decision.\n" + '\n' + '4. **Assess Current State of the Brain**: \n' + ' - The current state is "thinking," which suggests that I am in a reflective mode, considering options rather than acting impulsively.\n' + '\n' + '5. **Determine Action Based on Context**:\n' + ' - Given the high priority (4) of the event and the engagement nature (replying to a tweet), it indicates that the user is actively participating in discussions. This could be an opportunity to foster further engagement.\n' + ' - However, the lack of user information and previous context makes it difficult to tailor a response or action effectively.\n' + '\n' + '6. **Make a Decision**:\n' + ' - Since the event is of high priority and involves user engagement, I would decide to take action. Possible actions could include:\n' + ' - Acknowledging the reply (e.g., liking or retweeting the reply).\n' + ' - Responding to the user to encourage further interaction.\n' + ' - Logging the event for future reference to build a profile of user engagement.\n' + '\n' + '7. **Implement the Decision**:\n' + ' - Execute the chosen action based on the decision made in the previous step.\n' + '\n' + 'In summary, despite the lack of user information and previous context, the high priority and engagement nature of the event warrant a response to encourage further interaction.', providerMetadata: undefined } ], providerMetadata: undefined, timestamp: 1741003512356, episodeId: 'episode-m7t0j04tprrwj2t'}
With the new user information, Cortex updates its analysis.
Note how the fetched data is now added into the thought process:
Copy
{ id: 'm7t0jlzsty44388', role: 'assistant', content: [ { type: 'text', text: 'To achieve the goal of deciding whether to act on the event or ignore it, I would follow these steps:\n' + '\n' + '1. **Analyze the Event**: \n' + ' - The event indicates that the user (ID: 1234567890) replied to a tweet with the content "Great point! I completely agree."\n' + ' - The event has a timestamp of 1714531200, a description, a priority level of 4, and is categorized under the labels "user," "twitter," and "engagement."\n' + '\n' + '2. **Evaluate the User Information**:\n' + ' - The user has 100 followers and is following 100 accounts, indicating a balanced engagement level.\n' + ' - The bio, location, website, profile picture, and cover picture provide additional context about the user, but they are not directly relevant to the decision-making process for this event.\n' + '\n' + '3. **Consider the Priority Level**:\n' + ' - The event has a priority level of 4, which suggests it is relatively important. This indicates that the reply could be significant for engagement or interaction on Twitter.\n' + '\n' + '4. **Contextualize the Event**:\n' + ' - I would consider the nature of the reply. The user is expressing agreement, which could foster positive engagement and potentially lead to further interaction.\n' + ' - I would also reflect on any previous events related to this user or similar interactions to gauge the overall engagement pattern.\n' + '\n' + '5. **Determine the Current State of the Brain**:\n' + ' - Assess whether the current state of the brain is focused on engagement, content creation, or other priorities. If the focus is on increasing engagement or building community, this event aligns well with those goals.\n' + '\n' + '6. **Make a Decision**:\n' + ' - Given the high priority of the event, the positive nature of the reply, and the current focus on engagement, I would decide to act on this event.\n' + ' - Possible actions could include:\n' + ' - Acknowledging the reply with a like or a follow-up tweet.\n' + ' - Engaging further with the user to encourage more interaction.\n' + ' - Analyzing the engagement metrics to understand the impact of such replies on overall engagement.\n' + '\n' + '7. **Implement the Decision**:\n' + ' - Execute the chosen action based on the decision made in the previous step.\n' + '\n' + 'By following these steps, I can effectively evaluate the event and make an informed decision on whether to act on it or ignore it.', providerMetadata: undefined } ], providerMetadata: undefined, timestamp: 1741003520536, episodeId: 'episode-m7t0j04tprrwj2t'}
This is a simplified example of the reasoning process.
In production, Cortex processes much more complex signals with additional context, historical data, and personality traits stored on-chain.
The decision-making pipeline includes multiple reasoning steps, state evaluations, and priority calculations before determining the appropriate action.
This activates the Kinesis module so it can parse the decision and act on it.
Assistant
Responses are generated using AI and may contain mistakes.