Skip to content

Commit 71144ef

Browse files
committed
updated the flow
1 parent 15d5ddb commit 71144ef

File tree

4 files changed

+161
-76
lines changed

4 files changed

+161
-76
lines changed

docs/developer/agents/agentIntroduction.md

Lines changed: 159 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ sidebar_label: Introduction
55

66
# Agent Introduction
77

8-
Codebolt is an extremely powerful platform for AI-driven code editing and generation. The core strength of Codebolt lies in its agent-based architecture, where specialized AI agents handle different aspects of software development, from code generation to testing and deployment.
8+
Codebolt is an extremely powerful AI driven coding system. Think of Codebolt as the Selenium of code editors. Just like Selenium or Playwright lets you control an entire browser. Similarly, Codebolt allows agents to control the entire code editor. Codebolt has been built from ground up for the AI-Egentic era.
9+
10+
Unlike other editors like cursor where they have a single agent that is the core of the application, CodeBolt takes a different approach where it allows you to write your own agents and the agent logics.
911

1012
## What is a Codebolt Agent?
1113

12-
A Codebolt Agent is a custom AI-powered application that connects to the Codebolt platform to execute specific development tasks. Think of agents as specialized developers with unique skills - one might excel at React component generation, another at API development, and yet another at testing automation.
14+
Codebolt agents are intelligent AI assistants that leverage Codebolt's APIs to interact with your code editor. They analyze user requirements, communicate with large language models (LLMs), and execute actions like code editing, file manipulation, and task automation within your development environment.
1315

14-
### Key Characteristics
16+
## What is it different?
1517

16-
- **Specialized**: Each agent focuses on specific development tasks or domains
17-
- **Autonomous**: Agents can make decisions and take actions using LLM reasoning
18-
- **Connected**: Agents integrate seamlessly with the Codebolt application
19-
- **Extensible**: Agents can use tools and call other agents for complex workflows
20-
- **Reusable**: Once created, agents can be shared and used across projects
18+
Codebolt agents are fundamentally different from other agents like in cursors or trae. Other code editors provide you with an option to create a custom code agent only by changing the core prompt or by selecting the available tools. On the contrary, a code bolt agent provides you with actual editor APIs for you or the AI to interact with the editor. Code bolt agents are code based agents where you can write custom codes which might include any process, any workflows along with agentic AI logics. While we also support a very simple cursor style agent creation called as [remix agents](/docs/developer/agents/remixAgents) but the real power of code bolt comes with custom code-based agents.
2119

2220
## How Agents Work
2321

@@ -32,14 +30,20 @@ Codebolt agents operate through an agentic process flow that combines:
3230

3331
## Agent Architecture
3432

33+
This is a very high level architecture of Codebolt and Agent Interaction. The Codebolt Application handles the orchestration of the agents based on the user chat and provides services for agents to use.
34+
3535
```mermaid
3636
graph TB
3737
subgraph "Codebolt Application"
3838
A[Codebolt Editor]
3939
B[Agent Orchestrator]
40-
C[Universal Agent Router]
41-
D[Tool Registry]
42-
E[File System]
40+
C[Service Manager]
41+
42+
subgraph "Agent Services"
43+
K[LLM Providers]
44+
M[MCP Services]
45+
E[File System]
46+
end
4347
end
4448
4549
subgraph "Agent Runtime"
@@ -49,62 +53,168 @@ graph TB
4953
I[System Prompts]
5054
J[Task Instructions]
5155
end
52-
53-
subgraph "External Services"
54-
K[LLM Providers]
55-
L[External APIs]
56-
M[Tool Services]
57-
end
58-
5956
A --> B
60-
B --> C
61-
C --> F
57+
A --> C
6258
F --> G
6359
G --> H
6460
H --> I
6561
H --> J
6662
67-
G <--> A
68-
G <--> D
69-
G <--> E
63+
G <--> C
64+
65+
C <--> E
66+
C --> K
67+
C --> M
68+
B --> F
69+
```
70+
71+
72+
73+
## Agent Flow
74+
75+
The following sequence diagram illustrates the complete flow of how a user request is processed through Codebolt and agents:
76+
77+
```mermaid
78+
sequenceDiagram
79+
80+
81+
participant User
82+
box Codebolt Editor
83+
participant Codebolt as Editor UI
84+
participant LLM as LLM Service
85+
participant Tools as MCP Services
86+
participant ServiceMgr as Service Manager
87+
end
88+
participant Agent as Custom Agent
89+
90+
User->>Codebolt: Send request/message
91+
Note over User,Codebolt: User types a request in chat
92+
93+
Codebolt->>Agent: Start agent & forward message
94+
Note over Codebolt,Agent: Agent Orchestrator routes to appropriate agent
7095
71-
H --> K
72-
H --> L
73-
H --> M
96+
97+
Agent->>ServiceMgr: Send LLM request with context
98+
Note over Agent,ServiceMgr: Agent calls LLM service via Service Manager
99+
100+
ServiceMgr->>LLM: Route to LLM provider
101+
Note over ServiceMgr,LLM: Service Manager handles LLM routing
102+
103+
LLM->>ServiceMgr: Return response with tool calls
104+
ServiceMgr->>Agent: Forward LLM response
105+
Note over ServiceMgr,Agent: LLM suggests actions and tools to use
106+
107+
loop Till LLM suggests to stop
108+
Agent->>ServiceMgr: Request tool execution
109+
Note over Agent,ServiceMgr: Agent calls specific tools via Service Manager
110+
111+
ServiceMgr->>Tools: Execute tool/service
112+
Note over ServiceMgr,Tools: File, code, MCP services, etc.
113+
114+
Tools->>ServiceMgr: Return tool result
115+
ServiceMgr->>Agent: Send tool result back
116+
74117
75-
F --> B
118+
Agent->>ServiceMgr: Send tool results for next LLM call
119+
Note over Agent,ServiceMgr: Agent reports tool execution results
120+
121+
ServiceMgr->>LLM: Send results to LLM
122+
LLM->>ServiceMgr: Return next steps or completion
123+
ServiceMgr->>Agent: Forward LLM response
124+
end
125+
126+
Agent->>Codebolt: Task Completed, Send completion message
127+
Codebolt->>User: Display final result
128+
76129
```
77130

78-
## Agent Connection Flow
131+
But again you are not limited to this flow. You can write your own agent logic and use the CodeboltJS library to interact with the editor.
132+
133+
## Sample Agent Flow Code
79134

80-
Codebolt agents connect to the platform using the **CodeboltJS library**, which provides a comprehensive set of functions for:
135+
Here's a complete example of how an agent handles a user request using the **CodeboltJS library**:
81136

82-
### 1. Communication Layer
83137
```javascript
84-
// WebSocket connection for real-time communication
85-
codebolt.chat.onActionMessage().on("userMessage", async (req, response) => {
86-
// Handle user messages and respond
138+
// Main agent entry point - handles incoming user messages
139+
codebolt.onMessage((userMessage)=> {
140+
try {
141+
// 1. Extract context
142+
const projectContext = await codebolt.project.getContext();
143+
144+
// 2. Get available tools for the agent
145+
const tools = await codebolt.tools.listToolsFromToolBoxes(["codebolt", "filesystem"]);
146+
147+
// 3. Prepare conversation with system context
148+
const messages = [
149+
{
150+
role: "system",
151+
content: "You are a helpful coding assistant. Analyze the user request and use available tools to complete the task."
152+
},
153+
{
154+
role: "user",
155+
content: `${userMessage}\n\nProject context: ${JSON.stringify(projectContext)}`
156+
}
157+
];
158+
159+
// 4. Start conversation loop with LLM
160+
let isTaskComplete = false;
161+
let conversationHistory = [...messages];
162+
163+
while (!isTaskComplete) {
164+
// Send request to LLM with available tools
165+
const llmResponse = await codebolt.llm.chat(conversationHistory, tools);
166+
167+
// 5. Process LLM response and execute tool calls
168+
if (llmResponse.tool_calls && llmResponse.tool_calls.length > 0) {
169+
// Execute each tool call requested by LLM
170+
for (const toolCall of llmResponse.tool_calls) {
171+
const toolResult = await codebolt.tools.executeToolCall(toolCall);
172+
173+
// Add tool result to conversation
174+
conversationHistory.push({
175+
role: "tool",
176+
tool_call_id: toolCall.id,
177+
content: JSON.stringify(toolResult)
178+
});
179+
}
180+
181+
// Get LLM's next response after tool execution
182+
const followUpResponse = await codebolt.llm.chat(conversationHistory, tools);
183+
184+
// Check if LLM indicates task is complete
185+
if (followUpResponse.content.includes("task completed") ||
186+
!followUpResponse.tool_calls) {
187+
isTaskComplete = true;
188+
189+
// 6. Send final response to user
190+
return followUpResponse.content;
191+
}
192+
} else {
193+
// No tool calls needed, task is complete
194+
isTaskComplete = true;
195+
return llmResponse.content;
196+
}
197+
}
198+
199+
} catch (error) {
200+
console.error('Error in agent:', error);
201+
}
87202
});
88203
```
89204

90-
### 2. Tool Integration
91-
```javascript
92-
// Access to platform tools and external services
93-
const tools = await codebolt.tools.listToolsFromToolBoxes(["codebolt", "custom"]);
94-
```
205+
### Code Explanation:
95206

96-
### 3. File System Access
97-
```javascript
98-
// Read, write, and manipulate project files
99-
const fileContent = await codebolt.fs.readFile("./src/component.js");
100-
await codebolt.fs.writeFile("./src/newComponent.js", generatedCode);
101-
```
207+
1. **Message Handling**: The agent listens for user messages via WebSocket connection
208+
2. **Context Gathering**: Retrieves project context and available tools
209+
3. **LLM Communication**: Sends user request with context to the LLM service
210+
4. **Tool Execution Loop**:
211+
- LLM responds with tool calls (file operations, code analysis, etc.)
212+
- Agent executes each tool via Codebolt's service manager
213+
- Results are sent back to LLM for next steps
214+
5. **Task Completion**: Loop continues until LLM indicates the task is finished
215+
6. **User Response**: Final result is sent back to the user through Codebolt UI
102216

103-
### 4. LLM Integration
104-
```javascript
105-
// Interact with various LLM providers
106-
const response = await codebolt.llm.chat(messages, tools);
107-
```
217+
This example demonstrates the complete agent flow from the sequence diagram above, showing how agents use the **CodeboltJS library** to:
108218

109219
## Agent Types and Use Cases
110220

docs/developer/tools/index.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/user/application/3_onboarding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Now on the same page select a model provided by list of models from the selected
7070

7171
After clicking on "Create Project in workspace" this screen will pop-up
7272

73-
Here we can see [Template](./4_Templates/template.md) and [My Templates](./4_Templates/myTemplates.md) <br/>
73+
Here we can see [Template](./5_Templates/template.md) and [My Templates](./5_Templates/myTemplates.md) <br/>
7474
Just give a name to you project or you can keep a random name and click "Create Project"
7575

7676
![Onboarding Project Creation](../../../static/onboarding/6.png)

docs/user/application/module/settings/ApplicationSettings/DefaultSettings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Default Settings
22
- In the **Default Settings**, you can set up the application's **LLM** and select a **Model**.
3-
The Default Provider and model you select during [onboarding](/docs/user/onboarding#first-time-users) you update it here. <br/>
3+
The Default Provider and model you select during [onboarding](/docs/user/application/onboarding#first-time-users) you update it here. <br/>
44
Also you can update Embedding provider and model.
55

66
![Default Settings](../../../../../../static/settings/appSettings/1.png)

0 commit comments

Comments
 (0)