An ai collaborative coding agent system and method based on multi-environment cloud containers

CN122903103APending Publication Date: 2026-10-13CSDN CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610958833.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-30
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

[0004]现有AI协作编码代理方法通过主控代理拆解自然语言指令、编排器按任务类型分配架构代理、编码代理等代理至多环境云容器的独立沙箱中并行执行代码编写与验证,并经由结构化反馈循环迭代优化后由编排器汇总合并部署,实现了多代理协同完成端到端开发任务的基本流程;然而,当多个代理在并发场景下进行AI协作编码时,多个代理在容器化沙箱中执行编译、测试运行、包管理等各类工具调用,每次工具调用的资源需求各不相同,例如编译任务消耗大量CPU(Central Processing Unit,中央处理器)、测试套件执行占用大量内存等,而现有技术在多环境云容器的资源管理层面通常采用静态资源配额策略,例如为每个代理容器分配固定的CPU、内存和存储资源,可能在进行不同阶段的编码任务时因资源管理失配而降低云容器集群的整体资源利用率和代理任务执行效率,例如,在轻量级推理和简单文件读写操作期间,分配给对应代理容器的存储资源处于闲置浪费状态,而在代理执行重型编译任务期间,固定的资源配额往往远低于实际资源需求等,最终导致AI协作编码的资源利用率和代理任务执行效率低的技术问题

Benefits of technology

1、通过实施AI编码代理资源需求波动特征分析,以分析结果决策有无必要启动代理容器资源弹性分配,如果没必要,则继续按照当前代理容器的资源配置执行代理工具调用,有助于在多环境云容器的并行协作编码场景下,仅在代理实际资源供需出现失配时才触发资源调整流程,从而避免因频繁触发资源弹性分配而带来的系统调度抖动和资源调整开销,降低多环境云容器编排层的决策负载,提升多环境云容器集群在高并发多代理场景下的整体调度效率和运行稳定性;如果有必要,则启动代理容器资源弹性分配,并基于分析结果判别当前代理容器存在资源配置冗余还是当前代理容器存在资源配置不足,如果当前代理容器存在资源配置冗余,则执行目标代理动态缩容调整,有助于在保障代理任务正常执行和不触发代理容器重启或迁移的前提下,安全回收多环境云容器中因资源过度分配而产生的空闲计算资源和内存资源,从而在多代理并发协作编码的动态负载场景下有效减少多环境云容器中因静态资源配额策略导致的资源配置浪费,提升多环境云容器集群的整体资源利用率和资源分配的合理性;如果当前代理容器存在资源配置不足,则执行全局资源压力状态量化,并以量化结果决策有无必要执行目标代理资源扩容操作,有助于在多代理并发竞争多环境云容器有限资源的情况下,减少因单一代理的扩容请求过度消耗全局可用资源而导致集群资源耗尽或引发其他代理资源不足的级联故障,同时减少在多环境云容器集群资源紧张或空闲资源碎片化严重的状态下盲目执行扩容操作导致扩容失败或集群资源分配紊乱,从而保障多环境云容器集群在资源紧张场景下的整体可用性和资源分配的全局最优性,最终解决了AI协作编码的资源利用率和代理任务执行效率低的问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122903103A_ABST
    Figure CN122903103A_ABST
Patent Text Reader

Abstract

The application discloses an AI collaborative coding agent system and method based on a multi-environment cloud container, and relates to the technical field of AI collaborative coding agent software development. The method analyzes the fluctuation characteristics of AI coding agent resource requirements, and decides whether it is necessary to start the elastic allocation of agent container resources based on the analysis result. If it is not necessary, the agent tool call is continued according to the current resource configuration of the agent container. If it is necessary, the elastic allocation of agent container resources is started, and it is judged whether there is resource configuration redundancy or resource configuration deficiency in the current agent container based on the analysis result. If there is resource configuration redundancy in the current agent container, the target agent dynamic shrinkage adjustment is performed. If there is resource configuration deficiency in the current agent container, the global resource pressure state is quantified, and it is decided whether it is necessary to perform the target agent resource expansion operation based on the quantification result. The method solves the problems of insufficient resource utilization rate and agent task execution efficiency in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of AI collaborative coding agent software development technology, and in particular to an AI collaborative coding agent system and method based on multi-environment cloud containers. Background Technology

[0002] With continuous breakthroughs in large language model capabilities, AI (Artificial Intelligence)-assisted coding has evolved from simple code completion to autonomous agent models capable of undertaking complex software engineering tasks. However, existing AI collaborative coding agent methods still face technical bottlenecks when advancing towards production-grade cloud-native application development, such as difficulty in covering the entire chain of work from architecture design, front-end and back-end implementation, infrastructure as code writing to testing and deployment, and the lack of code's ability to run and verify real services. Therefore, there is a great need for a method that can support secure collaboration on multi-environment cloud container infrastructure to complete end-to-end software development tasks. Currently, platforms such as InsCode AI coding (InsCode AI Integrated Development Environment) provide an isolated and convenient cloud GPU development environment and AI-assisted programming capabilities by leveraging multi-environment cloud containers.

[0003] The main implementation process of existing AI collaborative coding agent methods is as follows: A master agent, such as the administrator agent in the AutoGen framework, decomposes acquired natural language instructions, such as developing an e-commerce order system, into multiple independently executable subtasks, such as database design, interface development, and front-end page creation. Next, an orchestrator schedules and assigns different specialized agents based on task type. For example, an architecture agent is responsible for service decomposition and API (Application Programming Interface) design, while a testing agent is responsible for automated test synthesis and execution. Each specialized agent is assigned to a containerized sandbox built on a multi-environment cloud container platform. The sandbox provides an isolated file system and Git working tree to ensure that the parallel operations of each agent do not interfere with each other. Then, each specialized agent performs code writing, file reading and writing, and other operations within its sandbox. After completing its task, it submits the results and iteratively optimizes through a structured feedback loop. For example, after running tests, the testing agent feeds back failure information to the coding agent, which then modifies the code and resubmits it. Finally, the orchestrator aggregates the outputs of all specialized agents, merges the final code, and deploys it to the target cloud environment.

[0004] Existing AI collaborative coding agent methods employ a master agent to break down natural language instructions, an orchestrator to allocate architecture agents and coding agents according to task type, and other agents to execute code writing and verification in parallel within independent sandboxes of multiple cloud containers. After iterative optimization through structured feedback loops, the orchestrator aggregates and merges the results for deployment, achieving a basic workflow for multi-agent collaborative end-to-end development tasks. However, when multiple agents perform AI collaborative coding in concurrent scenarios, each agent executes various tool calls such as compilation, test running, and package management within the containerized sandbox. The resource requirements for each tool call vary; for example, compilation tasks consume significant amounts of CPU (Central Processing Time). Units (Central Processing Units) and test suite execution consume significant amounts of memory. Existing technologies typically employ static resource quota strategies for resource management in multi-environment cloud containers. For example, they allocate fixed CPU, memory, and storage resources to each agent container. This resource management mismatch can reduce the overall resource utilization of the cloud container cluster and the efficiency of agent task execution during different stages of coding tasks. For instance, during lightweight inference and simple file read / write operations, the storage resources allocated to the corresponding agent container are idle and wasted. During the agent's execution of heavy compilation tasks, the fixed resource quota is often far lower than the actual resource requirements. Ultimately, this leads to the technical problem of low resource utilization and low agent task execution efficiency in AI collaborative coding. Summary of the Invention

[0005] This invention provides an AI collaborative coding proxy system and method based on multi-environment cloud containers, which solves the problems existing in the prior art and improves the resource utilization and proxy task execution efficiency of AI collaborative coding.

[0006] To achieve the above-mentioned objectives, the present invention provides the following technical solution: On one hand, an AI collaborative coding agent system based on multi-environment cloud containers is provided, including: an AI coding agent resource demand monitoring module, a target agent dynamic scaling-down module, and a target agent dynamic scaling-up module. The AI ​​coding agent resource demand monitoring module is used to perform AI coding agent resource demand fluctuation characteristic analysis during the AI ​​collaborative coding process, capturing the time-series data of agent resource usage of each agent container in different tool invocation stages within the multi-environment cloud containers. The analysis results determine whether it is necessary to initiate elastic allocation of agent container resources. If not, the agent tool invocation continues to be executed according to the current resource configuration of the agent container. The target agent dynamic scaling-down module... The first block is used to initiate elastic allocation of proxy container resources to reclaim idle resources of proxy containers with redundant resource configurations in multi-environment cloud containers, if necessary. Based on the analysis results, it determines whether the current proxy container has redundant resource configurations or insufficient resource configurations. If the current proxy container has redundant resource configurations, it performs dynamic scaling down adjustment of the target proxy. The second block is used to perform global resource pressure status quantification if the current proxy container has insufficient resource configurations. Based on the quantification results, it decides whether it is necessary to perform target proxy resource scaling up operation to dynamically increase CPU quotas and memory limits for proxy containers with insufficient resources in multi-environment cloud containers.

[0007] On the other hand, an AI collaborative coding proxy method based on multi-environment cloud containers is provided. This method includes: during the AI ​​collaborative coding process, implementing AI coding proxy resource demand fluctuation characteristic analysis to capture the proxy resource usage time series data of each proxy container in the multi-environment cloud container at different tool invocation stages, and using the analysis results to decide whether it is necessary to initiate elastic allocation of proxy container resources. If it is not necessary, the proxy tool invocation continues to be executed according to the current resource configuration of the proxy container. If it is necessary, elastic allocation of proxy container resources is initiated to reclaim the idle resources of proxy containers with redundant resource configurations in the multi-environment cloud container, and based on the analysis results, it is determined whether the current proxy container has redundant resource configurations or insufficient resource configurations. If the current proxy container has redundant resource configurations, the target proxy is dynamically scaled down. If the current proxy container has insufficient resource configurations, the global resource pressure status is quantified, and the quantification results determine whether it is necessary to perform target proxy resource expansion operations to dynamically increase CPU quotas and memory limits for proxy containers with insufficient resources in the multi-environment cloud container.

[0008] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following: 1. By analyzing the fluctuation characteristics of AI coding agent resource demand, the system determines whether it is necessary to initiate elastic resource allocation for agent containers. If not, the agent tool calls continue to be executed according to the current resource configuration of the agent container. This helps to trigger resource adjustment processes only when there is a mismatch between the actual supply and demand of agent resources in parallel collaborative coding scenarios of multi-environment cloud containers. This avoids system scheduling jitter and resource adjustment overhead caused by frequent triggering of elastic resource allocation, reduces the decision load of the multi-environment cloud container orchestration layer, and improves the overall scheduling efficiency and operational stability of multi-environment cloud container clusters in high-concurrency multi-agent scenarios. If necessary, elastic resource allocation for agent containers is initiated, and the system determines whether the current agent container has redundant or insufficient resource configuration based on the analysis results. If the current agent container has redundant resource configuration, the target agent is dynamically scaled down. This helps to safely reclaim resources in multi-environment cloud containers that have been over-allocated, while ensuring the normal execution of agent tasks and without triggering agent container restarts or migrations. The resulting idle computing and memory resources effectively reduce resource allocation waste caused by static resource quota policies in multi-environment cloud containers under dynamic load scenarios of multi-agent concurrent collaborative coding, thereby improving the overall resource utilization and rationality of resource allocation in multi-environment cloud container clusters. If the current agent container has insufficient resource allocation, global resource pressure status quantification is performed, and the quantification results determine whether it is necessary to perform target agent resource expansion operations. This helps to reduce the cascading failures caused by excessive consumption of global available resources by a single agent's expansion request when multiple agents are competing for limited resources in multi-environment cloud containers, thus reducing the risk of cluster resource exhaustion or other agent resource shortages. At the same time, it reduces the risk of blindly performing expansion operations in multi-environment cloud container clusters with tight resources or severe fragmentation of idle resources, which could lead to expansion failure or disordered cluster resource allocation. This ensures the overall availability and global optimality of resource allocation in multi-environment cloud container clusters under resource-scarce scenarios, ultimately solving the problems of low resource utilization and low agent task execution efficiency in AI collaborative coding.

[0009] 2. By specifically acquiring CPU-dimensional deviation, memory-dimensional deviation, and resource consumption waveform similarity, this approach helps to jointly judge the rationality of resource configuration of the agent container during the operation of AI collaborative coding agents in multi-environment cloud containers, based on both the magnitude and shape of resource consumption waveforms. Compared to the coarse-grained approach of existing technologies that typically judge whether a single resource indicator exceeds limits using only fixed thresholds, this solution effectively distinguishes between unreasonable resource configuration and abnormal agent execution behavior through dual judgment of magnitude and shape. This reduces the likelihood of misjudging abnormal agent behavior as resource configuration problems and executing incorrect resource adjustment operations. If both CPU-dimensional deviation and memory-dimensional deviation are within the preset low resource consumption threshold and the preset low resource consumption threshold, this solution can further improve performance. If the resource consumption waveform similarity is higher than the preset waveform similarity threshold, the proxy tool call will continue to be executed according to the current proxy container's resource configuration. If both the CPU dimension deviation and memory dimension deviation are between the preset low resource consumption threshold and the preset high resource consumption threshold, but the resource consumption waveform similarity is not higher than the preset waveform similarity threshold, an AI encoding proxy process anomaly prompt will be sent. If there are other situations besides the above, elastic allocation of proxy container resources is required. This helps to accurately initiate the elastic resource adjustment process for proxy containers with resource supply and demand mismatch in multi-environment cloud containers, effectively reducing accidental resource adjustments in abnormal proxy behavior scenarios, and making the triggering of elastic resource allocation more accurate and reliable.

[0010] 3. When the agent is in an idle waiting phase but the background is still performing slow log persistence writing or remote dependency package downloads, if the safe scaling-down window is determined based on the fluctuation range of CPU utilization and memory usage, scaling down may cause the agent task to be blocked or timed out due to sudden surges in disk I / O or network transmission resource demands. Therefore, an alternative solution for quantifying the risk of target agent scaling-down adjustment needs to be implemented. If the timing fluctuation range of CPU utilization is lower than the preset CPU fluctuation threshold, and the timing fluctuation range of memory usage is lower than the preset memory fluctuation threshold, then a resource margin comparison is performed; if either fluctuation range is higher than the preset fluctuation threshold, then an unstable resource demand warning for the current agent is sent, which helps to reduce the risk. This approach reduces the risk of misjudging scaling down safety based solely on low fluctuations in CPU and memory usage. It mitigates the risk of proxy task blocking or timeouts due to sudden background I / O or network transmission spikes after scaling down, improving the safety and reliability of scaling down operations in multi-environment cloud containers under multi-proxy concurrent scenarios. If other situations exist besides the above, the target proxy resource scaling down operation is executed. This helps ensure that in dynamic load scenarios with concurrent collaborative coding by multiple proxies, scaling down operations do not fail due to sudden resource demands, effectively reducing resource allocation waste caused by static resource quota policies in multi-environment cloud containers, and improving the overall resource utilization and rationality of resource allocation in multi-environment cloud container clusters. Attached Figure Description

[0011] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0012] Figure 1 This is a schematic diagram of the structure of an AI collaborative coding agent system based on multi-environment cloud containers provided in an embodiment of the present invention; Figure 2 This is an overview diagram of an AI collaborative coding agent system based on multi-environment cloud containers provided by an embodiment of the present invention; Figure 3 This is a target agent dynamic scaling adjustment logic diagram of an AI collaborative coding agent system based on multi-environment cloud containers provided in an embodiment of the present invention; Figure 4 This is a global resource pressure state quantification logic diagram of an AI collaborative coding agent system based on multi-environment cloud containers provided in an embodiment of the present invention. Detailed Implementation

[0013] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the described embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0014] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, the terms "an," "a," or "the," etc., do not indicate a quantity limitation, but rather indicate the presence of at least one. The terms "comprising," "including," or similar terms mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects.

[0015] It should be noted that the AI ​​collaborative coding agent system and method based on multi-environment cloud containers provided in this application relies on a pre-built multi-environment agent resource scheduling knowledge base. This knowledge base integrates a series of core scheduling parameters pre-approved by experts in cloud computing resource management and AI agent collaboration, such as preset resource consumption time-series curves, preset memory quantities, preset low resource consumption thresholds, preset high resource consumption thresholds, and preset waveform similarity thresholds. The knowledge base also incorporates standardized pre-processed historical operating data of multi-environment cloud containers, covering various agent role types, such as architecture agents. The knowledge base includes proxy resources for various cloud container environments, such as management, coding, testing, and operations proxies, as well as various tool call types, including compilation, testing, package management, and file read / write. It also records the execution status of these tools, including normal completion, abnormal interruption, and timeout retries, along with feedback on resource configuration adjustments, such as task execution status after scaling down and resource utilization improvement after scaling up. Furthermore, the knowledge base stores model iteration and optimization data, such as update records of long short-term memory network parameters in the preset resource demand prediction model and cluster centroid update records of typical waveforms for various tool calls in the resource demand feature archive.

[0016] Specifically, in terms of storage architecture, the multi-environment agent resource scheduling knowledge base adopts a domain-based heterogeneous storage approach: relational databases are used to store structured indicator data, such as CPU dimension deviation and memory dimension deviation; while non-relational databases are used to store unstructured data, such as CPU utilization sequences, memory usage sequences, disk I / O rate sequences, and waveform data of resource consumption time-series curves and preset resource consumption time-series curves. Cloud computing platform operation and maintenance personnel or AI collaborative coding system administrators can periodically verify and dynamically iterate and adjust various preset parameters stored in the multi-environment agent resource scheduling knowledge base based on multi-source monitoring data collected in real time during the operation of multi-environment cloud containers, such as agent resource usage time-series data reported by transparent monitoring probes, resource configuration rationality judgment results output by resource profiling services, resource adjustment execution records generated by the resource scheduling module, and feedback information on the execution performance of agent tasks after adjustment. This enables the knowledge base to continuously adapt to the differences in resource demand characteristics of different agent roles, changes in resource consumption patterns of different tool call types, differences in hardware performance of different cloud container environments, and the complex and ever-changing concurrent resource competition situation in multi-agent parallel collaboration scenarios.

[0017] Example 1, Reference Figure 1A schematic diagram of an AI collaborative coding agent system based on multi-environment cloud containers shows that the system includes: an AI coding agent resource demand monitoring module, a target agent dynamic scaling-down module, and a target agent dynamic scaling-up module. The AI ​​coding agent resource demand monitoring module is used to analyze the fluctuation characteristics of AI coding agent resource demand during AI collaborative coding by capturing the time-series data of agent resource usage at different tool invocation stages for each agent container in the multi-environment cloud containers. The analysis results determine whether it is necessary to initiate elastic allocation of agent container resources. If not, the agent tool invocation continues to be executed according to the current resource configuration of the agent container. By monitoring the AI ​​coding agent resource demand, the system effectively reduces the continuous mismatch between resource configuration and actual agent demand caused by the inability to perceive the dynamic changes in agent resource demand at different tool invocation stages in existing technologies. It also reduces system scheduling jitter and resource adjustment overhead caused by frequent triggering of elastic resource allocation, and lowers the decision load of the multi-environment cloud container orchestration layer.

[0018] The target agent dynamic scaling-down module is used to initiate elastic allocation of agent container resources, if necessary, to reclaim idle resources of agent containers with redundant resource configurations in multi-environment cloud containers. Based on the analysis results, it determines whether the current agent container has redundant resource configurations or insufficient resource configurations. If the current agent container has redundant resource configurations, it performs target agent dynamic scaling-down adjustment to safely reclaim idle resources of agent containers in multi-environment cloud containers without triggering agent process restarts or migrations. Target agent dynamic scaling-down helps to safely reclaim idle memory and CPU resources in multi-environment cloud containers caused by excessive resource allocation when it is determined that the current agent container has redundant resource configurations, without triggering agent container restarts or migrations or affecting the normal execution of agent tasks.

[0019] The target agent dynamic scaling module is used to perform a global resource pressure quantification at the multi-environment cloud container cluster level to comprehensively assess the global resource supply capacity and resource fragmentation degree if the current agent container has insufficient resource configuration. Based on the quantification results, it decides whether it is necessary to perform a target agent resource scaling operation to dynamically increase the CPU quota and memory limit for the agent container with insufficient resources in the multi-environment cloud container. Through target agent dynamic scaling, it helps to perform scaling operations when the current agent container is determined to have insufficient resource configuration, and when the amount of idle resources is sufficient for scaling, it reduces the cluster resource exhaustion or cascading failures caused by the excessive consumption of global available resources by the scaling request of a single agent. It ensures that the resource scaling operation of the multi-environment cloud container cluster in the process of multi-agent parallel collaborative coding is always executed in an orderly manner within the range that the overall resource supply capacity of the cluster can bear.

[0020] In this embodiment, the AI ​​coding agent resource demand monitoring module, the target agent dynamic scaling-down module, and the target agent dynamic scaling-up module help to form a complete, closed-loop, multi-environment cloud container AI collaborative coding agent resource elastic scheduling system. This ensures that multiple agents always operate under container resource configurations that adapt to the resource requirements of their current tool invocation stage during parallel collaborative coding, thereby guaranteeing the overall operating efficiency and global optimality of resource allocation of the multi-environment cloud container cluster in high-dynamic load scenarios of multi-agent parallel collaboration. Specifically, the AI ​​coding agent resource demand monitoring module accurately judges the rationality of the current resource configuration of each agent container. When the judgment result is that there is resource configuration redundancy, the target agent dynamic scaling-down module is triggered to release the reclaimed idle resources back to the global resource pool of the multi-environment cloud container, thereby increasing the total amount of available resources in the global resource pool. When the judgment result is that there is insufficient resource configuration, the target agent dynamic scaling-up module is triggered to ensure that the scaling-up operation is only executed in an orderly manner within the range that the overall resource supply capacity of the cluster can bear.

[0021] refer to Figure 2 The overall overview diagram of an AI collaborative coding agent system based on multi-environment cloud containers shows that: The system analyzes the fluctuation characteristics of AI coding agent resource requirements and obtains CPU dimension deviation, memory dimension deviation, and resource consumption waveform similarity. If both CPU dimension deviation and memory dimension deviation are between a preset low resource consumption threshold and a preset high resource consumption threshold, and the resource consumption waveform similarity is higher than a preset waveform similarity threshold, then the agent tool call continues to be executed according to the current agent container's resource configuration. If both CPU dimension deviation and memory dimension deviation are between a preset low resource consumption threshold and a preset high resource consumption threshold, but the resource consumption waveform similarity is not higher than a preset waveform similarity threshold, then an AI coding agent process exception prompt is sent. In other cases, elastic allocation of agent container resources is required. When the CPU dimension deviation is lower than the preset low resource consumption threshold, or the memory dimension deviation is lower than the preset low resource consumption threshold, dynamic scaling down of the target agent is executed.

[0022] Preferably, the specific process of AI coding agent resource demand fluctuation characteristic analysis is as follows: Step A1, during the resource demand fluctuation analysis period, collect agent resource usage time-series data during each agent tool call process, including CPU utilization rate sequence, memory usage sequence, disk I / O rate sequence, and network transmission rate sequence; the CPU utilization rate sequence represents the sequence of CPU utilization rates arranged in chronological order; the CPU utilization rate is represented by dividing the CPU time increment between the current sampling time and the previous sampling time by the sampling interval duration, and then multiplying the result of the division by 100%; the memory usage sequence represents the sequence of the total physical memory actually occupied by all processes in the current agent container at each moment arranged in chronological order; the disk I / O rate sequence represents the sequence of disk I / O rates arranged in chronological order. The sequence of sampling points is as follows: Disk I / O rate is represented by dividing the increase in disk read / write bytes between the current and previous sampling times by the sampling interval; Network transmission rate sequence is represented by arranging network transmission rates in chronological order; Network transmission rate is represented by dividing the increase in network send / receive bytes between the current and previous sampling times by the sampling interval; Agent resources use time-series data to represent the numerical sequence of multi-dimensional resource consumption indicators collected by the transparent monitoring probe over time during the lifecycle of each agent executing a complete tool call, such as compilation, test execution, or package management. For example, taking an agent executing a Maven compilation task as an example, during the complete lifecycle of this compilation task, the transparent monitoring probe samples at a period of 100ms, and at each sampling time... Record the CPU utilization sequence of the compilation task proxy container respectively. The dataset consists of four sequences: memory usage [1.2GB, 1.8GB, 2.5GB, 3.1GB, 2.9GB, ...], disk I / O rate [0MB / s, 15MB / s, 42MB / s, 38MB / s, 5MB / s, ...], and network transmission rate, where n represents the total number of samples. Aligning these four sequences by sampling time constitutes the proxy resource usage time-series data for this compilation task. The transparent monitoring probe captures all system calls and external command execution requests issued by the proxy process to the operating system, identifying compilation commands such as `javac` and `go build`, test execution commands such as `mvntest` and `pytest`, and package management commands such as `npm install` and `pip`. The transparent monitoring probe tracks the start and completion events of various tools, including install, file read / write operations, and other tool calls. It aligns CPU usage sequences, memory usage sequences, disk I / O rate sequences, and network transmission rate sequences with the same sampling timestamp and associates them with tool call type identifiers, such as agent role identifiers, task context identifiers, and session IDs. This information is then encapsulated into a complete agent resource usage time sequence record. For example, using JSON format for structured storage, a complete agent resource usage time sequence record includes the following fields: a unique identifier for this tool call, a tool call type identifier, an agent role identifier, a task context identifier, a start event timestamp, a completion event timestamp, and timestamp-aligned agent resource usage time sequence data.

[0023] Step A2: Based on the proxy resource usage time-series data, determine whether the current proxy container's resource configuration is reasonable by performing the following multi-dimensional comparisons: Obtain the CPU dimension deviation (to quantify the deviation of CPU utilization from the reasonable range of CPU consumption under the current proxy's currently executed tool call type), the memory dimension deviation (to quantify the deviation of memory usage from the reasonable range of memory consumption under the current proxy's currently executed tool call type), and the resource consumption waveform similarity (to quantify the morphological similarity between the actual resource consumption waveform of the current tool call and the preset resource consumption time-series curve of the current tool call type). The specific acquisition process is as follows: The result of the arithmetic average of the CPU utilization of the preset number of CPU sampling points before the current time is marked as the measured CPU utilization value to avoid interference from the instantaneous peak of resource usage at a single sampling time in the deviation calculation; the difference between the measured CPU utilization value and the preset average CPU utilization is calculated, and then the result of the difference calculation is proportionally calculated to the preset standard deviation of CPU utilization. The calculated results are labeled as CPU dimension deviation; the preset CPU usage mean is represented by the average CPU usage in the CPU usage sequence when the corresponding tool is called through the corresponding agent in the historical time period; the preset CPU usage standard deviation is represented by the standard deviation of CPU usage in the CPU usage sequence when the corresponding tool is called through the corresponding agent in the historical time period; the result of the arithmetic mean of memory usage for the preset number of memory sampling points before the current time is labeled as the measured memory usage value; the difference between the measured memory usage value and the preset memory usage mean is calculated, and the result of the difference calculation is proportional to the preset memory usage standard deviation, and labeled as memory dimension deviation; the preset memory usage mean is represented by the average memory usage in the memory usage sequence when the corresponding tool is called through the corresponding agent in the historical time period; the preset memory usage standard deviation is represented by the standard deviation of memory usage in the memory usage sequence when the corresponding tool is called through the corresponding agent in the historical time period.

[0024] Specifically, the process for obtaining the resource consumption waveform similarity is as follows: Based on the segmented aggregation approximation algorithm, the CPU utilization sequence and memory usage sequence of the current tool call from the start time to the current sampling time are respectively subjected to dimensionality reduction processing to obtain the resource consumption time series curve of the current tool call; dimensionality reduction processing means dividing the CPU utilization sequence and memory usage sequence into K equal-length intervals of a preset number, calculating the arithmetic mean of CPU utilization in each interval to obtain the CPU dimensionality reduction sequence, calculating the arithmetic mean of memory usage in each interval to obtain the memory dimensionality reduction sequence, and then normalizing the CPU dimensionality reduction sequence and the memory dimensionality reduction sequence respectively to form a two-dimensional sequence of length K in a preset joint order. For example, the CPU dimensionality reduction sequence is represented as follows. The memory-reduced dimensionality sequence is represented as A two-dimensional sequence of length K, arranged in a preset joint order, is represented as follows: Here, c_i represents the i-th element in the CPU dimensionality reduction sequence, m_i represents the i-th element in the memory dimensionality reduction sequence, i=1,2,3,...,K. This two-dimensional sequence is determined as the resource consumption time-series curve of the current tool call. The preset number of intervals and the preset joint order are both preset by preset personnel. Based on the dynamic time warping algorithm, the similarity calculation is performed on the resource consumption time-series curve and the preset resource consumption time-series curve to obtain the resource consumption waveform similarity. The result of the resource consumption waveform similarity is a value between 0 and 1. The closer the value is to 1, the more similar the two curves are. The preset resource consumption time-series curve is represented by the centroid curve obtained by clustering the resource consumption time-series data based on K-Means and other clustering algorithms corresponding to the historical time period. The centroid curve is a two-dimensional sequence.

[0025] If both the CPU and memory deviations are between the preset low resource consumption threshold and the preset high resource consumption threshold, including both endpoints, and the resource consumption waveform similarity is higher than the preset waveform similarity threshold, then the current proxy container's resource configuration is determined to be reasonable. The current memory and CPU quotas are maintained, and proxy tool calls continue to be executed according to the current proxy container's resource configuration. The preset low resource consumption threshold is determined by the low quantile of the CPU and memory deviations for this tool call type within a historical time period, preferably the 25th percentile. The preset high resource consumption threshold is determined by the resource consumption of this tool call type within a historical time period under reasonable resource configuration conditions. The high quantiles of CPU dimension deviation and memory dimension deviation are determined, preferably the 75th percentile. The preset waveform similarity threshold is represented by the average value of resource consumption waveform similarity over a historical time period. If both CPU dimension deviation and memory dimension deviation are between the preset low resource consumption threshold and the preset high resource consumption threshold, but the resource consumption waveform similarity is not higher than the preset waveform similarity threshold, it indicates that there is an anomaly in the current tool call execution mode, such as the proxy behavior deviating from expectations, abnormal interruption or suspension during tool call execution, etc., and an abnormal prompt for the AI ​​encoding proxy process is sent. If there are other situations besides the above, elastic allocation of proxy container resources should be adopted.

[0026] In this embodiment, by analyzing the fluctuation characteristics of AI coding agent resource requirements, it is helpful to accurately perceive and scientifically determine the resource configuration status of each agent container in a multi-environment cloud container cluster in complex and dynamic multi-agent concurrent collaborative coding scenarios. This reduces the agent task failure rate and the number of invalid resource adjustment operations caused by resource configuration mismatch, reduces the idle waste of computing and memory resources in multi-environment cloud container clusters due to static quota policies, improves the overall resource utilization and task execution efficiency of multi-environment cloud container clusters, and ensures that multiple agents always run under container resource configurations that adapt to the resource requirements of their current tool invocation stage during parallel collaborative coding.

[0027] refer to Figure 3 A logic diagram for dynamic scaling down of a target agent in an AI collaborative coding agent system based on multi-environment cloud containers is presented. It shows that dynamic scaling down of the target agent occurs when both CPU and memory deviations meet the third and fourth conditions of elastic allocation, respectively. Global resource pressure state quantification is then performed. Similarly, if both CPU and memory deviations meet the first and second conditions of elastic allocation, dynamic scaling down of the target agent is also performed. If none of the above conditions are met, it is determined whether the absolute value of the CPU deviation is greater than the memory deviation. If the absolute value of the deviation is positive, the CPU dimension deviation status is used as the judgment basis; otherwise, the memory dimension deviation status is used as the judgment basis. Target agent dynamic scaling down adjustment means that the risk of target agent scaling down adjustment is quantified based on the target memory limit and target CPU quota, and scaling down security is checked. If the CPU utilization time-series fluctuation is lower than the preset CPU fluctuation threshold, and the memory usage time-series fluctuation is lower than the preset memory fluctuation threshold, then resource margin comparison is performed. If either fluctuation exceeds the preset fluctuation threshold, then an unstable resource demand prompt for the current agent is sent. If there are other situations besides the above, then the target agent resource scaling down operation is executed. Preferably, the specific process of elastic resource allocation for the proxy container is as follows: When the CPU dimension deviation and memory dimension deviation meet the first condition for elastic allocation, and the CPU dimension deviation and memory dimension deviation meet the second condition for elastic allocation, it is determined that the current proxy container has resource configuration redundancy, and then the target proxy is dynamically scaled down. The first condition for elastic allocation indicates that the CPU dimension deviation is lower than a preset low resource consumption threshold, or the memory dimension deviation is lower than a preset low resource consumption threshold; the second condition for elastic allocation indicates that both the CPU dimension deviation and memory dimension deviation are not higher than a preset high resource consumption threshold. The preset high resource consumption threshold is used to define whether the resource consumption of the current proxy container in the CPU and memory dimensions is within the upper limit of the normal range. When the CPU dimension deviation and memory dimension deviation meet the third condition for elastic allocation, and the CPU dimension deviation and memory dimension deviation meet the fourth condition for elastic allocation, it is determined that the current proxy container has insufficient resource configuration and needs to be scaled up. Then, global resource pressure state quantification is performed. The third condition for elastic allocation indicates that the CPU dimension deviation is higher than a preset high resource consumption threshold, or the memory dimension deviation is higher than a preset high resource consumption threshold. The fourth condition indicates that both the CPU dimension deviation and the memory dimension deviation are not lower than the preset low resource consumption threshold. The preset low resource consumption threshold is used to define whether the current proxy container's resource consumption in the CPU and memory dimensions is within the lower bound of the normal range. If the above condition is not met, it is determined whether the absolute value of the CPU dimension deviation is greater than the absolute value of the memory dimension deviation. If so, the state of the CPU dimension deviation is used as the judgment criterion; otherwise, the state of the memory dimension deviation is used. Using the state of the CPU dimension deviation as the judgment criterion means that if the CPU dimension deviation is higher than the preset high resource consumption threshold, global resource pressure state quantification is performed; if the CPU dimension deviation is lower than the preset low resource consumption threshold, dynamic scaling down adjustment of the target proxy is performed. It should be noted that during the elastic allocation of proxy container resources, resource consumption waveform similarity is no longer considered, because resource consumption waveform similarity is only used to identify abnormal proxy behavior and unreasonable resource configuration. When the process enters the elastic allocation of proxy container resources, the situation where the deviations are all in the middle range has been excluded, and there is no need to reconsider resource consumption waveform similarity. The preset low resource consumption threshold is less than the preset high resource consumption threshold.

[0028] Specifically, the dynamic scaling down adjustment process for the target agent is as follows: Step B1: Calculate the difference between the current target agent's preset memory limit and its current memory usage. The preset memory limit represents the upper limit of memory resources allowed for the agent container, set by the multi-environment cloud container orchestration layer when the agent container is created or during the last resource adjustment. This is achieved by calling the agent container runtime API, such as Docker's `docker inspect` command or the `ContainerStatus` method of the CRI interface. Multiply the result of the difference calculation with a preset safety factor to obtain the target agent's reclaimable memory capacity. Next, calculate the difference between the current target agent's preset CPU quota and its current CPU utilization. The preset CPU quota represents the upper limit of CPU time quota allowed for the agent container, set by the multi-environment cloud container orchestration layer when the agent container is created or during the last resource adjustment. This is obtained by calling the container runtime API. Multiply the result of the difference calculation with a preset safety factor to obtain the target agent's reclaimable CPU quota. The preset safety factor is a value between 0 and 1, pre-set by the administrator, indicating that the scaling down operation only reclaims a portion of the currently idle resources. Resources are reserved with a safety margin of at least a certain percentage of the current actual usage to prevent performance degradation or task failure due to fluctuations in resource demand after scaling down. Since memory and CPU use the same safety margin reservation strategy, they share the same preset safety factor. The safety margin reservation strategy means that when performing dynamic scaling down of the target agent, the resource quota of the agent container is not directly reduced to be equal to the current actual usage. Instead, the target resource quota after scaling down is still higher than the current actual usage by a certain percentage, which reserves sufficient buffer space for possible instantaneous fluctuations in resource demand after scaling down. For example, when the preset safety factor is 0.8, it means that the dynamic scaling down of the target agent only reclaims 80% of the currently idle resources and reserves 20% of the idle resources as a safety margin.

[0029] Step B2: Calculate the difference between the target agent's preset memory limit and the target agent's reclaimable memory capacity to obtain the target memory limit; calculate the difference between the target agent's preset CPU quota and the target agent's reclaimable CPU quota to obtain the target CPU quota; quantify the risk of target agent scaling down based on the target memory limit and target CPU quota, specifically as follows: Step C1: Obtain the target agent's running status parameters at the current moment, including the CPU utilization time-series fluctuation amplitude and memory usage time-series fluctuation amplitude of the current agent process; the CPU utilization time-series fluctuation amplitude is represented by the result obtained by calculating the standard deviation of CPU utilization in the CPU utilization sequence, used to characterize the stability of the current resource demand; the memory usage time-series fluctuation amplitude is represented by the result obtained by calculating the standard deviation of memory usage... The result is represented by the standard deviation of the memory usage in the sequence; in step C2, the time-series fluctuation of CPU utilization is summed with the simulated CPU utilization to obtain the predicted peak CPU demand based on the current fluctuation range; the time-series fluctuation of memory usage is summed with the simulated memory usage to obtain the predicted peak memory demand based on the current fluctuation range; the predicted peak CPU demand is multiplied by a preset safety multiple to obtain the CPU safety demand threshold; the predicted peak memory demand is multiplied by a preset safety multiple to obtain the memory safety demand threshold; the preset safety multiple is a value greater than 1, representing the safety margin that the target resource quota should still retain in the worst case after the simulated target agent resource scaling down operation, to prevent the agent task from failing due to resource demand fluctuations, and is set in advance by preset personnel.

[0030] Step C3 involves performing a scaling-down safety check, as follows: If the CPU utilization fluctuation is lower than a preset CPU fluctuation threshold, and the memory usage fluctuation is lower than a preset memory fluctuation threshold, it indicates that the agent's current resource demand is stable, and the risk of resource shortage caused by the scaling-down operation is low. A resource adequacy comparison is then performed. The preset CPU fluctuation threshold is represented by the average of the CPU utilization fluctuation over a historical time period, and the preset memory fluctuation threshold is represented by the average of the memory usage fluctuation over a historical time period. If either fluctuation exceeds the corresponding preset fluctuation threshold, the current resource demand is determined to be unstable, the target agent resource scaling-down operation is not performed, and a message indicating unstable current agent resource demand is sent. The resource adequacy comparison indicates that if the target memory limit is lower than the memory safety requirement threshold or the target CPU quota is lower than the CPU safety requirement threshold, the target agent resource scaling-down operation is determined to have a risk of resource shortage in the worst-case scenario. The corresponding target memory limit, target CPU quota, etc., are then uploaded to the AI ​​collaborative coding agent resource management center. The current target proxy resource scaling-down operation is marked as high-risk and its execution is delayed until resource demand fluctuations subside. If other situations exist besides the above, it is determined that the target proxy resource scaling-down operation still has sufficient resource margin in the worst-case scenario, and the target proxy resource scaling-down operation is executed. The target proxy resource scaling-down operation means that the AI ​​collaborative coding proxy resource management center sends memory scaling-down adjustment instructions and CPU scaling-down adjustment instructions to the resource adjustment execution unit of the target proxy container. The memory scaling-down adjustment instruction carries the target proxy container identifier and the target memory limit control signal. This memory scaling-down adjustment instruction adjusts the target proxy container's memory limit from the current preset memory limit to the target memory limit through the dynamic resource adjustment interface of the target proxy container runtime layer. The CPU scaling-down adjustment instruction carries the target proxy container identifier and the CPU quota scaling-down target value control signal. The CPU scaling-down adjustment instruction adjusts the target proxy container's CPU quota from the current preset CPU quota to the target CPU quota through the dynamic resource adjustment interface of the proxy container runtime layer.

[0031] In this embodiment, by dynamically scaling down the target agent, quantifying the risk of scaling down the target agent, and performing target agent resource scaling down operations, it helps to reduce the blocking of agent tasks due to excessive scaling down or improper timing of scaling down; reduce the negative impact of scaling down operations on the normal execution of agent tasks and the failure rate of agent tasks due to improper resource reclamation; reduce the waste of idle resources in multi-environment cloud containers that are locked for a long time due to static resource quota policies and cannot be reused by other agents; improve the security of idle resource reclamation in multi-environment cloud container clusters and the total amount of available resources in the global resource pool, providing more abundant resource supply for other resource-scarce agents; and realize safe and efficient idle resource reclamation in multi-environment cloud container clusters under resource configuration redundancy scenarios during multi-agent parallel collaborative coding.

[0032] refer to Figure 4 A global resource pressure status quantification logic diagram for an AI collaborative coding agent system based on multi-environment cloud containers shows that: global resource pressure status quantification is performed, and the results of cluster resource status division and future resource supply trend prediction are obtained. If the cluster resource status is sufficient, the future resource supply trend is predicted to be sufficient or balanced, and the current total number of idle CPU cores and total idle memory capacity meet the expansion requirements, then the target agent resource expansion operation is executed. If the cluster resource status is strained, the future resource supply trend is predicted to be sufficient, and the current total number of idle CPU cores and total idle memory capacity meet the expansion requirements, then the target agent's ranking in the global scheduling priority needs to be lowered by a preset level to ensure that resources are prioritized for critical task agents. If other situations exist besides the above, a resource shortage warning is sent.

[0033] Preferably, the specific process for quantifying the global resource pressure status is as follows: Step D1, based on the cloud container cluster resource management API, such as Kubernetes Metrics Server or a custom resource monitoring service, obtain the total number of CPU cores, total memory capacity, total number of allocated CPU cores, and total allocated memory capacity of the entire cluster; subtract the total number of allocated CPU cores from the total number of CPU cores to obtain the total number of idle CPU cores; subtract the total number of allocated memory capacity from the total memory capacity to obtain the total amount of idle memory capacity; Step D2, obtain the overall cluster resource pressure index; determine the ratio of the total number of allocated CPU cores to the total number of CPU cores as the CPU pressure index; determine the ratio of the total allocated memory capacity to the total memory capacity as the memory pressure index; determine whether the CPU pressure index is greater than the memory pressure index. If so, determine the CPU pressure index as the overall cluster resource pressure index; otherwise, determine the memory pressure index as the overall cluster resource pressure index. The overall resource pressure index of the cluster is determined. This index characterizes the overall strain on cluster resources. Based on the overall resource pressure index, the cluster resource status is classified as follows: First, it is determined whether the overall resource pressure index is lower than a preset first pressure threshold. If so, the cluster status is classified as sufficient. Second, if the overall resource pressure index is not lower than the preset first pressure threshold but is lower than a preset second pressure threshold, the cluster status is classified as strained. The preset first pressure threshold is less than the preset second pressure threshold, where the preset first pressure threshold is represented by the average value of the overall resource pressure index over a historical time period, and the preset second pressure threshold is pre-set by preset personnel. Third, if the overall resource pressure index is not lower than the preset second pressure threshold, the cluster status is classified as congested.

[0034] Step D3: Input the tool call sequence and agent resource usage time series data into a preset resource demand prediction model, such as a Long Short-Term Memory (LSTM) network, to predict the predicted CPU and memory requirements for all pending tool calls to be executed by the current target agent within a preset future time window. The tool call sequence represents the type identifier sequence of all tool calls executed by the current target agent from startup to the current time in chronological order. The predicted CPU requirements of all agents are summed to obtain the total predicted CPU requirement for the cluster in the future. The predicted memory requirements of all agents are summed to obtain the total predicted memory requirement for the cluster in the future. The total predicted CPU requirement is compared with the current total number of idle CPU cores, and the total predicted memory requirement for the cluster in the future is compared with the current total amount of idle memory, generating a prediction of future resource supply trends. The specific process is as follows: If the total predicted CPU requirement is less than a preset CPU secondary threshold and the total predicted memory requirement is less than a preset memory secondary threshold, then the total predicted CPU requirement is further compared with a preset CPU primary threshold. The system compares the total predicted memory demand with the preset first-level memory threshold. If both the total predicted CPU demand and the total predicted memory demand are less than the preset first-level CPU threshold, it indicates that the predicted demand in both dimensions is within the ample range, and the trend is predicted as an ample resource supply. The preset first-level CPU threshold is represented by the average total predicted CPU demand over a historical period, and the preset first-level memory threshold is represented by the average total predicted memory demand over a historical period. If both the total predicted CPU demand and the total predicted memory demand are less than the preset second-level CPU threshold and the preset second-level memory threshold, but the total predicted CPU demand is not less than the preset first-level CPU threshold and the total predicted memory demand is not less than the preset first-level memory threshold, the trend is predicted as a balanced resource supply. The preset second-level CPU threshold and the preset second-level memory threshold are both set in advance by preset personnel. If either the total predicted CPU demand is not less than the preset second-level CPU threshold or the total predicted memory demand is not less than the preset second-level memory threshold, the trend is predicted as a tight resource supply.

[0035] Based on the cluster resource status classification and the prediction of future resource supply trends, the following comprehensive judgment is performed: If the cluster resource status is sufficient, and the future resource supply trend is predicted to be sufficient or balanced, and the current total number of idle CPU cores and total amount of idle memory meet the expansion requirements, then the expansion request is deemed acceptable, and the target agent resource expansion operation is executed; if the cluster resource status is strained, and the future resource supply trend is predicted to be sufficient, and the current total number of idle CPU cores and total amount of idle memory meet the expansion requirements, then the expansion request is deemed acceptable, but the target agent's ranking in the global scheduling priority must be lowered by a preset level to ensure resource priority. Prioritize critical task agents; if any other conditions exist besides the above, the expansion request is deemed unacceptable, the current expansion request record is uploaded to the AI ​​collaborative coding agent resource management center, and a resource shortage warning is sent. Expansion requirement conditions indicate that the total number of idle CPU cores exceeds the preset CPU requirement threshold, and the total amount of idle memory exceeds the preset memory requirement threshold. The preset CPU and memory requirement thresholds are pre-set by designated personnel. Global scheduling priority indicates the order in which the AI ​​collaborative coding agent resource management center allocates resources to each agent container in the cluster. This order is determined by the AI ​​collaborative coding agent resource management center based on agent role type and task urgency. Dynamic maintenance ensures that higher-priority agents receive priority resource allocation under global resource scarcity when executing target agent resource expansion operations. The target agent resource expansion operation involves the AI ​​collaborative coding agent resource management center sending CPU and memory expansion adjustment instructions to the target agent container's resource adjustment execution unit. The CPU expansion adjustment instruction carries a control signal with the target agent container identifier and a target CPU quota expansion value, adjusting the target agent container's CPU quota from its current value to the target value through the dynamic resource adjustment interface of the agent container's runtime layer. The target CPU quota expansion value is calculated by summing the current CPU quota with the CPU increment. The CPU increment is obtained by calculating the difference between a preset CPU safety threshold and the current measured CPU usage. The preset CPU safety threshold is set in advance by a preset user. The memory expansion adjustment instruction represents a control signal carrying the target proxy container identifier and the memory limit expansion target value. This instruction adjusts the memory limit of the target proxy container from the current value to the memory limit expansion target value through the dynamic resource adjustment interface of the container runtime layer. The memory limit expansion target value is obtained by summing the current memory limit and the memory increment. The memory increment is obtained by calculating the difference between a preset memory safety threshold and the current measured memory usage. The preset memory safety threshold is set in advance by a preset user.

[0036] It should be noted that the preset resource demand prediction model used in this embodiment is specifically a Long Short-Term Memory (LSTM) network. In another optional embodiment, a gated recurrent unit (GRU) model, a Transformer model, etc., can also be used. The specific training process of the preset resource demand prediction model is as follows: First, extract the tool call sequence and corresponding agent resource usage time series data recorded by each agent role in the historical operation from the multi-environment agent resource scheduling knowledge base, and use them as training samples. Label each training sample with the peak CPU demand and peak memory demand of the next tool call that actually occurs within the subsequent preset time window as prediction labels. Divide all collected training samples into training set, validation set, and test set according to a preset ratio, wherein the preset time window and preset ratio are set in advance by preset personnel. Next, concatenate the tool call type encoding and resource consumption time series data to form a complete model input feature vector. The model uses mean squared error as the loss function and uses an adaptive moment estimation optimizer for parameter updates. The initial learning rate is set to a preset initial value, which is set in advance by preset personnel. Then, input the samples in the training set into the LSM network model in batches. The model calculates the peak CPU demand of each sample according to the current parameters. The model calculates the loss value by substituting the predicted value of the required quantity and peak memory demand into the loss function, and then using the backpropagation algorithm to calculate the gradient of the loss value with respect to the parameters of each network layer. The Adam optimizer is then used to update the model parameters based on the gradient. After each training epoch, the model is evaluated using a validation set, and the average loss value and prediction accuracy on the validation set are calculated. Training is terminated early when the average loss value on the validation set no longer decreases for a preset number of epochs to prevent overfitting. The preset number of epochs is determined in advance by a pre-defined team. Finally, test set samples are input into the trained model to obtain the model's performance on the test set. The CPU prediction error and memory prediction error are calculated. If the CPU prediction error is lower than the preset CPU prediction error threshold and the memory prediction error is lower than the preset memory prediction error threshold, the model is deemed to meet the deployment requirements. If the model accuracy does not meet the requirements, the network structure parameters, such as the number of LSTM hidden layer units, Dropout rate, and learning rate, are adjusted and the above training process is re-executed until the model accuracy meets the deployment requirements. The preset CPU prediction error threshold is represented by the average value of the CPU prediction error over a historical time period, and the preset memory prediction error threshold is represented by the average value of the memory prediction error over a historical time period.

[0037] In this embodiment, by quantifying the global resource pressure status, expansion operations are only permitted when the current amount of idle resources meets the expansion requirements. This reduces the expansion failure rate and overall cluster stability risks caused by conflicts between expansion operations and the global resource status of the cluster. It also improves the accuracy, success rate, and global rationality of resource allocation for expansion operations in multi-environment cloud container clusters under multi-agent parallel collaborative coding scenarios. This ensures that expansion operations are always executed in an orderly manner within the overall resource supply capacity of the cluster, even when resources are scarce or fragmented. This guarantees the overall stability, availability, and global optimization of resource scheduling of multi-environment cloud container clusters during multi-agent parallel collaborative coding processes.

[0038] Example 2, as an alternative to the target agent scaling-down adjustment risk quantification in Example 1, when the agent is in an idle waiting phase but the background is still performing slow log persistence writing or remote dependency package downloads, if the safe scaling-down window is determined based on the fluctuation range of CPU utilization and memory usage, the agent task may be blocked or timed out due to a sudden surge in disk I / O or network transmission resource demands after scaling-down. Therefore, it is necessary to perform target agent scaling-down adjustment risk quantification. The specific process is as follows: Obtain the agent scaling-down timing discrimination parameters, including disk I / O fluctuation coefficient, network transmission fluctuation coefficient, and disk I / O regression. The slope and network transmission rate regression slope are calculated. The ratio of the standard deviation to the mean of the disk I / O rate in the disk I / O rate sequence is determined as the disk I / O fluctuation coefficient. The ratio of the mean to the standard deviation of the network transmission rate in the network transmission rate sequence is determined as the network transmission fluctuation coefficient. Linear regression analysis is performed on the disk I / O rate sequence and the network transmission rate sequence using the least squares method to obtain the disk I / O regression slope and the network transmission rate regression slope. The least squares method estimates the regression parameters by minimizing the sum of squared vertical distances from each data point to the regression line, where the regression slope represents the trend direction of the rate change over time. The rate of change is expressed as follows: a positive regression slope indicates an upward trend, while a negative slope indicates a downward trend. The timing of proxy scaling down is determined based on the proxy scaling down timing parameters. The specific process is as follows: It is determined whether the proxy scaling down timing parameters meet the safe scaling down conditions. If they do, it indicates that background I / O and network operations have converged to a safe level, and the scaling down operation will not cause the proxy task to be blocked or timed out due to background resource contention. In this case, the target proxy resource scaling down operation is executed. Otherwise, the current target proxy resource scaling down operation is marked as high-risk and its execution is delayed until resource demand fluctuations subside. The resource demand fluctuations subside... This means that if the proxy scaling-up timing judgment parameters meet the safe scaling-up conditions during the monitoring period, the target proxy resource scaling-up operation will be executed; otherwise, an unstable resource demand prompt will be sent. The safe scaling-up conditions indicate that the disk I / O fluctuation coefficient is lower than the preset disk I / O fluctuation threshold, the network transmission fluctuation coefficient is lower than the preset network transmission fluctuation threshold, and both the disk I / O rate regression slope and the network transmission regression slope are non-positive values. The preset disk I / O fluctuation threshold is represented by the average value of the disk I / O fluctuation coefficient over a historical period, and the preset network transmission fluctuation threshold is represented by the average value of the network transmission fluctuation coefficient over a historical period.

[0039] In this embodiment, quantifying the risk of target agent scaling down helps reduce misjudgments caused by focusing only on CPU and memory usage while ignoring the active state of background I / O or network transmission. It also reduces the risk of agent tasks being blocked or timed out when scaling down is performed while background I / O or network transmission is still active. This improves the security and accuracy of scaling down timing judgment in multi-environment cloud container clusters in multi-agent parallel collaborative coding scenarios. It ensures that scaling down operations are only performed when disk I / O and network transmission are in a low-fluctuation and convergent state, thereby effectively avoiding agent task anomalies caused by background resource competition and ensuring the security and reliability of scaling down operations in multi-environment cloud containers during multi-agent parallel collaborative coding.

[0040] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. The scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. An AI collaborative coding agent system based on multi-environment cloud containers, characterized in that, This includes an AI coding agent resource demand monitoring module, a target agent dynamic scaling down module, and a target agent dynamic scaling up module: The AI ​​coding agent resource demand monitoring module is used to perform AI coding agent resource demand fluctuation characteristic analysis during the AI ​​collaborative coding process. This analysis captures the time series data of agent resource usage of each agent container in different tool call stages in a multi-environment cloud container. The analysis results determine whether it is necessary to start elastic allocation of agent container resources. If it is not necessary, the agent tool call will continue to be executed according to the current resource configuration of the agent container. The target agent dynamic scaling-down module is used to initiate elastic allocation of agent container resources to reclaim idle resources of agent containers with redundant resource configurations in multi-environment cloud containers if necessary, and to determine whether the current agent container has redundant resource configurations or insufficient resource configurations based on the analysis results. If the current agent container has redundant resource configurations, the target agent dynamic scaling-down adjustment is performed. The target agent dynamic expansion module is used to perform global resource pressure status quantification if the current agent container has insufficient resource configuration, and decide whether it is necessary to perform target agent resource expansion operation to dynamically increase CPU quota and memory limit for agent containers with insufficient resources in multi-environment cloud containers based on the quantification results.

2. The AI ​​collaborative coding proxy system based on multi-environment cloud containers according to claim 1, characterized in that, The specific process for analyzing the fluctuation characteristics of AI coding agent resource demand is as follows: During the resource demand fluctuation analysis period, time-series data of agent resource usage during each agent tool call are collected, including CPU utilization sequence, memory usage sequence, disk I / O rate sequence and network transmission rate sequence. Based on the time-series data of proxy resource usage, the following multi-dimensional comparison is performed to determine whether the current proxy container's resource configuration is reasonable: The CPU dimension deviation, memory dimension deviation, and resource consumption waveform similarity are obtained. The specific acquisition process is as follows: The result of the arithmetic average of the CPU utilization of the preset number of CPUs at the current moment is marked as the measured value of CPU utilization. This is to avoid the interference of the instantaneous peak of resource at a single sampling moment on the deviation calculation. The difference between the measured CPU utilization and the preset average CPU utilization is calculated, and the result of the difference calculation is then compared with the preset standard deviation of CPU utilization. This result is marked as the CPU dimension deviation. The result of the arithmetic average of the memory usage of the preset memory amount at the current moment is marked as the measured value of memory usage. The difference between the measured memory usage and the preset average memory usage is calculated, and the result of the difference calculation is then compared with the preset standard deviation of memory usage. This result is marked as the memory dimension deviation. The specific process for obtaining the resource consumption waveform similarity is as follows: The CPU utilization sequence and memory usage sequence of the current tool call from the start time to the current sampling time are reduced in dimensionality based on the segmented aggregation approximation algorithm to obtain the resource consumption time series curve of the current tool call. The resource consumption time series curve is similar to the preset resource consumption time series curve based on the dynamic time warping algorithm to obtain the resource consumption waveform similarity. If both the CPU dimension deviation and the memory dimension deviation are between the preset low resource consumption threshold and the preset high resource consumption threshold, and the resource consumption waveform similarity is higher than the preset waveform similarity threshold, then the current proxy container's resource configuration is determined to be reasonable, the current memory limit and CPU quota remain unchanged, and the proxy tool call continues to be executed according to the current proxy container's resource configuration. If both the CPU dimension deviation and the memory dimension deviation are between the preset low resource consumption threshold and the preset high resource consumption threshold, but the resource consumption waveform similarity is not higher than the preset waveform similarity threshold, an abnormal prompt will be sent for the AI ​​encoding agent process.

3. The AI ​​collaborative coding proxy system based on multi-environment cloud containers according to claim 2, characterized in that, The specific process of elastically allocating proxy container resources is as follows: When the CPU dimension deviation and memory dimension deviation meet the first condition for elastic allocation, and the CPU dimension deviation and memory dimension deviation meet the second condition for elastic allocation, it is determined that the current proxy container has resource configuration redundancy, and then the target proxy is dynamically scaled down. The first condition for elastic allocation indicates that the deviation in the CPU dimension is lower than the preset low resource consumption threshold, or the deviation in the memory dimension is lower than the preset low resource consumption threshold. The second condition for elastic allocation indicates that both the CPU dimension deviation and the memory dimension deviation are not higher than the preset high resource consumption threshold. When the CPU dimension deviation and memory dimension deviation meet the third condition for elastic allocation, and the CPU dimension deviation and memory dimension deviation meet the fourth condition for elastic allocation, it is determined that the current proxy container has insufficient resource configuration and needs to be expanded and adjusted. Then, global resource pressure status quantification is performed. The third condition for elastic allocation indicates that the deviation in the CPU dimension is higher than the preset high resource consumption threshold, or the deviation in the memory dimension is higher than the preset high resource consumption threshold. The fourth condition for elastic allocation indicates that both the CPU dimension deviation and the memory dimension deviation are not lower than the preset low resource consumption threshold. If the above conditions are not met, then it is determined whether the absolute value of the CPU dimension deviation is greater than the absolute value of the memory dimension deviation. If so, the state of the CPU dimension deviation is used as the basis for judgment; otherwise, the state of the memory dimension deviation is used as the basis for judgment. The specific process of dynamically scaling down and adjusting the target proxy is as follows: Calculate the difference between the current target agent's preset memory limit and the current memory usage; The result of the difference operation is multiplied by the preset safety coefficient to obtain the target agent's reclaimable memory capacity. Calculate the difference between the preset CPU quota of the current target agent and the current CPU utilization rate; The result of the difference operation is multiplied by the preset safety coefficient to obtain the target agent's reclaimable CPU quota. The target memory limit is obtained by calculating the difference between the target agent's preset memory limit and the target agent's reclaimable memory capacity. The target CPU quota is obtained by calculating the difference between the target agent's preset CPU quota and the target agent's reclaimable CPU quota. Risk quantification of target agent scaling down adjustment based on target memory limit and target CPU quota.

4. The AI ​​collaborative coding proxy system based on multi-environment cloud containers according to claim 3, characterized in that, The specific process for quantifying the risk of target proxy scaling down adjustment is as follows: Obtain the target agent's running status parameters at the current moment, including the timing fluctuations of CPU utilization and memory usage of the current agent process; The CPU utilization time-series fluctuation amplitude is represented by the result obtained by calculating the standard deviation of the CPU utilization in the CPU utilization sequence. The time-series fluctuation amplitude of memory usage is represented by the standard deviation of memory usage in the memory usage sequence. The CPU utilization time-series fluctuation amplitude is summed with the simulated CPU utilization to obtain the predicted peak CPU demand based on the current fluctuation amplitude. The peak memory demand is predicted by summing the time-series fluctuation of memory usage with the simulated memory usage. The predicted peak CPU demand is multiplied by a preset safety factor to obtain the CPU safety demand threshold. The predicted peak memory demand is multiplied by a preset safety factor to obtain the memory safety demand threshold. Conduct a safety test for volume reduction.

5. The AI ​​collaborative coding proxy system based on multi-environment cloud containers according to claim 4, characterized in that, The specific process for the volume reduction safety test is as follows: If the timing fluctuation of CPU utilization is lower than the preset CPU fluctuation threshold, and the timing fluctuation of memory usage is lower than the preset memory fluctuation threshold, a resource margin comparison is performed. If any fluctuation exceeds the preset fluctuation threshold, the target proxy resource scaling down operation will not be performed, and an unstable proxy resource demand prompt will be sent. The resource adequacy comparison means that if the target memory limit is lower than the memory security requirement threshold or the target CPU quota is lower than the CPU security requirement threshold, the corresponding target memory limit, target CPU quota, etc. will be uploaded to the AI ​​collaborative coding agent resource management center, and the current target agent resource scaling down operation will be marked as high-risk and delayed until the resource demand fluctuations subside. If any other situation exists besides the above, then perform a target proxy resource scaling-down operation; The target agent resource scaling-down operation means that the AI ​​collaborative coding agent resource management center sends memory scaling-down and CPU scaling-down instructions to the resource adjustment execution unit of the target agent container. The memory shrinkage adjustment instruction represents a control signal carrying the target proxy container identifier and the target memory limit. This memory shrinkage adjustment instruction adjusts the memory limit of the target proxy container from the current preset memory limit to the target memory limit through the dynamic resource adjustment interface of the target proxy container runtime layer. The CPU scaling down adjustment instruction represents a control signal carrying the target proxy container identifier and the target value of CPU quota scaling down. The CPU scaling down adjustment instruction adjusts the CPU quota of the target proxy container from the current preset CPU quota to the target CPU quota through the dynamic resource adjustment interface of the proxy container runtime layer.

6. The AI ​​collaborative coding proxy system based on multi-environment cloud containers according to claim 3, characterized in that, The specific process of quantifying the global resource pressure status is as follows: The cloud container cluster resource management API can be used to obtain the total number of CPU cores, total memory capacity, total number of allocated CPU cores, and total number of allocated memory capacity for the entire cluster. Subtracting the total number of allocated CPU cores from the total number of CPU cores yields the total number of free CPU cores. Subtracting the total allocated memory capacity from the total total memory capacity yields the total free memory capacity. Obtain the overall resource pressure index of the cluster; The ratio of the total number of allocated CPU cores to the total number of CPU cores is defined as the CPU stress index. The ratio of the total allocated memory capacity to the total memory capacity is defined as the memory pressure index. Determine if the CPU stress index is greater than the memory stress index. If so, the CPU stress index is determined as the overall resource stress index of the cluster; otherwise, the memory stress index is determined as the overall resource stress index of the cluster. Based on the overall cluster resource pressure index, the cluster resource status is divided, and the specific division process is as follows: Determine whether the overall resource pressure index of the cluster is lower than the preset first pressure threshold. If so, determine the cluster status as sufficient. If the overall resource pressure index of the cluster is not lower than the preset first pressure threshold but is lower than the preset second pressure threshold, the cluster status will be determined to be tense. If the overall resource pressure index of the cluster is not lower than the preset second pressure threshold, the cluster status will be determined as a congested state. Input the tool call sequence and agent resource usage timing data into the preset resource demand prediction model to predict the CPU and memory demand required by the current target agent for all pending tool calls within a preset time window in the future. The total predicted CPU demand of the cluster is obtained by summing up the predicted CPU demand of all agents. The total predicted memory demand of the cluster is obtained by summing up the predicted memory demand of all agents. By comparing the total predicted CPU demand with the current total number of idle CPU cores, and by comparing the total predicted future memory demand of the cluster with the current total amount of idle memory, a prediction of future resource supply trends is generated.

7. The AI ​​collaborative coding proxy system based on multi-environment cloud containers according to claim 6, characterized in that, The specific process for generating predictions of future resource supply trends is as follows: If the total predicted CPU demand is less than the preset CPU level 1 threshold and the total predicted memory demand is less than the preset memory level 1 threshold, then the trend is predicted to be an abundance of resources. If the total predicted CPU demand is not less than the preset CPU Level 1 threshold but less than the preset CPU Level 2 threshold, and the total predicted memory demand is not less than the preset memory Level 1 threshold but less than the preset memory Level 2 threshold, then the trend is predicted to be a balance between resource supply and demand. If the total predicted CPU demand is not less than the preset CPU secondary threshold or the total predicted memory demand is not less than the preset memory secondary threshold, then the trend is predicted to be a tight supply of resources. Based on the cluster resource status classification and the prediction of future resource supply trends, the following comprehensive judgment is made: If the cluster resources are in a sufficient state, and the future resource supply trend is predicted to be sufficient or balanced, and the current total number of idle CPU cores and total amount of idle memory meet the expansion requirements, then the expansion request is deemed acceptable, and the target proxy resource expansion operation is executed. If the cluster resources are in a state of strain, and the future resource supply trend is predicted to be a trend of abundant resource supply, and the current total number of idle CPU cores and total amount of idle memory capacity meet the expansion requirements, then the expansion request is deemed to be acceptable. If any other situation exists besides the above, the expansion request is deemed unacceptable. The current expansion request record is then uploaded to the AI ​​Collaborative Coding Agent Resource Management Center, and a resource shortage warning is sent.

8. The AI ​​collaborative coding proxy system based on multi-environment cloud containers according to claim 7, characterized in that, The target agent resource expansion operation means that the AI ​​collaborative coding agent resource management center sends CPU expansion adjustment instructions and memory expansion adjustment instructions to the resource adjustment execution unit of the target agent container; The CPU expansion adjustment instruction represents a control signal carrying the target proxy container identifier and the CPU quota expansion target value. It adjusts the CPU quota of the target proxy container from the current value to the CPU quota expansion target value through the dynamic resource adjustment interface of the proxy container runtime layer. The memory expansion adjustment instruction represents a control signal carrying the target proxy container identifier and the target memory limit expansion value. This instruction adjusts the memory limit of the target proxy container from its current value to the target memory limit expansion value through the dynamic resource adjustment interface of the container runtime layer.

9. The AI ​​collaborative coding proxy system based on multi-environment cloud containers according to claim 8, characterized in that, The risk quantification of target proxy scaling down and adjustment includes: Obtain the parameters for determining the timing of proxy scaling down, including disk I / O fluctuation coefficient, network transmission fluctuation coefficient, disk I / O regression slope, and network transmission regression slope; The ratio of the mean to the standard deviation of disk I / O rates in the disk I / O rate sequence is determined as the disk I / O fluctuation coefficient. The ratio of the mean to the standard deviation of the network transmission rate in the network transmission rate sequence is determined as the network transmission fluctuation coefficient. Linear regression analysis was performed on the disk I / O rate sequence and the network transmission rate sequence based on the least squares method to obtain the disk I / O regression slope and the network transmission regression slope. The proxy scaling-down timing is determined based on the proxy scaling-down timing discrimination parameters. The specific process is as follows: Determine whether the parameters for determining the timing of proxy scaling down meet the safe scaling down conditions. If they do, execute the target proxy resource scaling down operation. Otherwise, mark the current target proxy resource scaling down operation as high-risk and delay its execution until the resource demand fluctuations subside before attempting it again.

10. An AI collaborative coding agent method based on multi-environment cloud containers, the method comprising: During the AI ​​collaborative coding process, AI coding proxy resource demand fluctuation characteristic analysis is implemented to capture the proxy resource usage time series data of each proxy container in different tool call stages in multi-environment cloud containers. The analysis results determine whether it is necessary to start elastic allocation of proxy container resources. If it is not necessary, the proxy tool call will continue to be executed according to the current resource configuration of the proxy container. If necessary, initiate elastic allocation of proxy container resources to reclaim idle resources of proxy containers with redundant resource configurations in multi-environment cloud containers, and determine whether the current proxy container has redundant resource configurations or insufficient resource configurations based on the analysis results. If the current proxy container has redundant resource configurations, perform dynamic scaling down adjustment of the target proxy. If the current agent container has insufficient resource configuration, perform global resource pressure status quantification, and use the quantification results to decide whether it is necessary to perform a target agent resource expansion operation to dynamically increase the CPU quota and memory limit for the agent container with insufficient resources in a multi-environment cloud container.