Context Management in Agentic Software Engineering: A Lifecycle Model and Design Patterns

S. A. Chernyshev

Abstract


The article examines the changing role of context in software engineering associated with the transition from traditional code writing to agentic development based on large language models. It is shown that, in such systems, a significant part of the control logic is transferred from source code to instructions, specifications, project rules, external memory, constraints, information about available tools, and intermediate results of the agent’s work. Therefore, context is proposed to be considered not as a one-time prompt, but as a maintainable engineering artifact that affects the behavior of the system being developed. The paper analyzes existing approaches to the use of context in LLM-based and agentic systems, including external knowledge sources, tool interfaces, project instructions, runtime rules, agent skills, and memory mechanisms. Based on this analysis, a context lifecycle model is proposed, including formation, verification and evaluation, distribution and reuse, usage monitoring, and maintenance. In addition, the paper introduces the structure of context K = (S, A, I, V, Q, P), which makes it possible to define the scope, conditions of application, content, verifiable constraints, quality criteria, and provenance of a contextual artifact. The article also describes contextual design patterns aimed at improving the reusability, verifiability, safety, and controllability of context in agentic development.

The model was validated experimentally in 240 runs of coding agents built on two LLMs: the strong cloud-based deepseek-v4.1-flash and the weak local qwen3.6-35b-a3b-mtp. The runs used the author’s own open-source project with a simulated API drift, designed under the single-carrier scheme, in which drift conventions are underivable from the repository and the context under test is their only carrier. After applying the proposed approach, this context increased the success rate of both the strong (0.50 → 0.93) and the weak agent (0.45 → 0.88). As for the applicability boundary, without hooks (a harness mechanism for intercepting and handling events) context compensates only for the agent’s knowledge deficit and in no way for its lack of execution reliability. In other words, instructions such as “NEVER” or “DO NOT” may be ignored by the agent altogether, whereas a hook fires deterministically at the right moment (running tests, checking whether the agent should be given access to a particular directory, and much more).

Finally, the study proposes extending the author’s previously developed classification of design patterns for multi-agent systems by adding a group of context design patterns aimed at improving the reusability, verifiability, security, and manageability of context in agent-based software development.


Full Text:

PDF (Russian)

References


Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Lewis, M., Yih, W.-t., Rocktäschel, T., Riedel, S. and Kiela, D. (2020) “Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks”, Advances in Neural Information Processing Systems (NeurIPS 2020), 33, pp. 9459–9474.

Yao, S., Zhao, J., Yu, D., Du, N., Shafran, I., Narasimhan, K.R. and Cao, Y. (2023) “ReAct: Synergizing reasoning and acting in language models”, 11th International Conference on Learning Representations (ICLR 2023). doi: 10.48550/arXiv.2210.03629.

Schick, T., Dwivedi-Yu, J., Dessì, R., Raileanu, R., Lomeli, M., Hambro, E., Zettlemoyer, L., Cancedda, N. and Scialom, T. (2023) “Toolformer: Language models can teach themselves to use tools”, Advances in Neural Information Processing Systems, 36, pp. 68539-68551. doi: 10.52202/075280-2997.

Jimenez, C.E., Yang, J., Wettig, A., Yao, S., Pei, K., Press, O. and Narasimhan, K.R. (2024) “SWE-bench: Can language models resolve real-world GitHub issues?”, 12th International Conference on Learning Representations (ICLR 2024). doi: 10.48550/arXiv.2310.06770.

Yang, J., Jimenez, C.E., Wettig, A., Lieret, K., Yao, S., Narasimhan, K.R. and Press, O. (2024) “SWE-agent: Agent-computer interfaces enable automated software engineering”, Advances in Neural Information Processing Systems, 37, pp. 50528–50652. doi: 10.52202/079017-1601.

Lulla, J.L., Mohsenimofidi, S., Galster, M., Zhang, J.M., Baltes, S. and Treude, C. (2026) “On the impact of AGENTS.md files on the efficiency of AI coding agents”, in Proceedings of Journal Ahead Workshop (JAWs) 2026 (ICSE JAWs 2026). New York: ACM, 5 p. arXiv:2601.20404, doi: 10.48550/arXiv.2601.20404.

Gloaguen, T., Mündler, N., Mueller, M.N., Raychev, V. and Vechev, M. (2026) “Evaluating AGENTS.md: Are repository-level context files helpful for coding agents?”, in ICLR 2026 Workshop on Memory for LLM-Based Agentic Systems, doi: 10.48550/arXiv.2602.11988.

Mohsenimofidi, S., Galster, M., Treude, C. and Baltes, S. (2026) “Context engineering for AI agents in open-source software”, in Proceedings of the 23rd International Conference on Mining Software Repositories (MSR ’26), Rio de Janeiro, Brazil, 13–14 April 2026. New York: ACM, 5 p. arXiv:2510.21413. doi: 10.48550/arXiv.2510.21413.

Sharma, R.K. (2026) “ContextCov: Deriving and enforcing executable constraints from agent instruction files”, arXiv:2603.00822, doi: 10.48550/arXiv.2603.00822.

Wang, H., Poskitt, C.M. and Sun, J. (2026) “AgentSpec: Customizable runtime enforcement for safe and reliable LLM agents”, in Proceedings of the 2026 IEEE/ACM 48th International Conference on Software Engineering (ICSE ’26), Rio de Janeiro, Brazil, 12–18 April 2026. New York: ACM, 12 p. arXiv:2503.18666. doi: 10.48550/arXiv.2503.18666.

Han, T., Zhang, Y., Song, W., Fang, C., Chen, Z., Sun, Y. and Hu, L. (2026) “SWE-Skills-Bench: Do agent skills actually help in real-world software engineering?”, arXiv:2603.15401, doi: 10.48550/arXiv.2603.15401.

Zhong, W., Guo, L., Gao, Q., Ye, H. and Wang, Y. (2024) “MemoryBank: Enhancing large language models with long-term memory”, Proceedings of the AAAI Conference on Artificial Intelligence, 38(17), pp. 19724–19731. doi: 10.1609/aaai.v38i17.29946.

Qian, C., Liu, W., Liu, H., Chen, N., Dang, Y., Li, J., Yang, C., Chen, W., Su, Y., Cong, X., Xu, J., Li, D., Liu, Z. and Sun, M. (2024) “ChatDev: Communicative agents for software development”, in Ku, L.-W., Martins, A. and Srikumar, V. (eds.) Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), Bangkok, Thailand, 11–16 August 2024. Stroudsburg, PA: Association for Computational Linguistics, pp. 15174–15186. doi: 10.18653/v1/2024.acl-long.810.

Chernyshev S.A. Classification of common design patterns for multi-agent systems. Software & Systems, 2022, vol. 35, no. 4, pp. 670–679 (in Russ.). DOI: 10.15827/0236-235X.140.670-679.

Chernyshev, S.A. (2022) Common Software Design Patterns for Multi-Agent Systems. St. Petersburg, 155 p. (in Russ.)


Refbacks

  • There are currently no refbacks.


Abava  Кибербезопасность ИТ-КОНГРЕСС ВМК МГУ 2026 СНЭ

ISSN: 2307-8162