Adding Context
CodeArts Agent supports incorporating context to improve Q&A accuracy. Context helps the agent better understand the background and intent of your question 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 | A maximum of 20 contexts can be added at a time. |
| Size | The context size must not exceed four times the context window of the currently used model. For example, if GLM-5.2 (which supports a context window of 1.05M tokens) is used and your context is in a file, the file size should be kept within 4.2M (1.05M × 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.
- Add 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 to display the context usage (token usage) of the current chat in real time, 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 |
|---|---|---|---|
| Ask | GLM-5.1 | 202.8K tokens |
|
| GLM-5.2 | 1.05M tokens | ||
| Agent Custom agent | GLM-5.1 | 202.8K tokens | Automatic compression: When the total token count of the current and historical chats exceeds 80% of the limit, the context is automatically compressed. |
| GLM-5.2 | 1.05M tokens | ||
| Custom models | Default value: 200.0K tokens On the custom model configuration page, you can adjust the context length as needed. For details, see Adding Custom Models. |
What is your overall rating for this page?
Thank 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