Adding Context
CodeArts Agent supports incorporating context to improve Q&A accuracy. Context helps agent understand the background and intent of your question better to generate more practical and valuable answers.
A variety of context types are currently supported, including files, folders, symbols, Git changes, terminal output, problems, and knowledge bases. All contexts can be flexibly combined and seamlessly associated with your input to build richer and more accurate Q&A scenarios.
Constraints
| Category | Description |
|---|---|
| Quantity |
|
| Size | The context size must not exceed four times the context window of the currently used model. For example, if DeepSeek-V3.2 (which supports a context window of 160K tokens) is used and your context is in a file, the file size should be kept within 640K (160K × 4) tokens. For details about the context length supported by each model, see Table 2. |
Adding Context
- Log in to CodeArts Agent IDE as instructed in Quick Start.
- At the bottom of the input box on the chat panel, choose Built-in > Ask to switch to the intelligent Q&A mode. The selected model is displayed on the right. You can select a model as required from the drop-down list.
If the chat panel of CodeArts Agent is not displayed, click
(Expand AI Sidebar) in the upper right corner of the top menu bar to open it. - Add a context.
- Method 1: Enter # in the input box and select the required context type from the displayed menu.
- Method 2: Click
in the input box, choose Add Context, and select the required context from the displayed menu.
- Context usage example
For example, when you open a project and need to fix a bug in the login function, CodeArts Agent can help you quickly locate and rectify the fault based on the context.
- File: src/auth/login.js file (View the login logic.)
- Folder: src/components (View the existing structure.)
- Git: View the latest related commits and learn the change history.
- Problems: View error logs and learn about specific error information.
- Terminal: View the test output and details about the test failure.
- Rules: View security specifications for bug fixing.
Supported Context Types
CodeArts Agent supports multiple context types, which can be flexibly combined. Your input can also be combined with the context to form a complete requirement expression. Multiple context types are supported, including files, folders, symbols, Git changes, terminal outputs, problems, and knowledge bases.
Context Compression
CodeArts Agent provides a context window (as shown in Figure 1) to display the token usage in the current chat, helping you view the context usage and avoid affecting the chat continuity.
When your development proceeds around a topic, the chat content accumulates and the context window is about to overflow. You can compress the current context. CodeArts Agent automatically summarizes the context, reducing the usage cost and improving the response efficiency.
When you want to discuss a new topic or start a new task, you are advised to start a new chat. This can effectively avoid interference from irrelevant historical records, so that CodeArts Agent can more accurately understand and respond to your requirements.
| Mode | Model | Context Limit | Context Compression Mode |
|---|---|---|---|
| Intelligent Q&A | GLM-5.1 | 198.0K tokens |
|
| Agent Custom agent | GLM-5.1 GLM-5.2 | 198.0K tokens | Automatic compression: When the total token count of the current and historical chats exceeds 90% of the limit, the context is automatically compressed. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
