# Stop letting AI agents ship 'shell script' Python

> Source: <https://dev.to/renato_marinho/stop-letting-ai-agents-ship-shell-script-python-4pk9>
> Published: 2026-09-15 04:54:22+00:00

If you have ever tasked an LLM with generating a Python utility, you have likely encountered a specific brand of technical debt. The code usually works—on the first run, in a vacuum. But look closer, and you will find a collection of anti-patterns that make maintaining it a nightmare.

The agent writes functions without type hints. It uses `os.path` instead of `pathlib`. It falls into the classic trap of mutable default arguments (`def func(x=[])`). More dangerously, it often employs bare `except:` blocks that swallow critical system signals like `KeyboardInterrupt`, or worse, performs synchronous I/O inside an asynchronous loop, effectively neutralizing any concurrency benefits.

This isn't just bad style; it is architectural decay. Untyped Python behaves like a shell script masquerading as an application. Without strict typing via Pydantic or Mypy, the risk of runtime failures increases exponentially as complexity grows. When an agent treats Python like Java—using manual loops instead of comprehensions or string concatenation instead of f-strings—it imposes a readability tax on every human engineer who inherits that code.

To solve this, we needed more than just a better prompt. We needed a validation layer that acts as a gatekeeper for code quality before it ever reaches a repository.

In building Vinkius, I noticed a recurring friction point: developers spend significant time wiring up specialized tools for agents, only to realize those tools lack the necessary rigor to ensure the output is production-ready. Most existing MCP implementations focus on connectivity—how to get an agent to talk to an API—but they rarely address correctness or adherence to language-specific idioms.

When we developed the [Python Excellence Prover](https://vinkius.com/en/ai-agent-connect/python-excellence-prover), our goal wasn't to teach the AI how to write code—most modern models are already proficient at basic syntax. Instead, the tool is designed to force the agent to prove its logic against five distinct decision pivots: typesafe boundaries, removal of workarounds, robust error handling, clean architecture (specifically dependency injection and service layers), and performance optimization (ensuring async/await compliance).

The Python Excellence Prover operates by forcing the agent through a series of structured reflections. It doesn't just check if the code runs; it checks if it complies with modern PEP standards and high-performance requirements.

Untyped Python is fragile. An agent might define `def process_order(data, user, amount):`, leaving downstream developers guessing whether `amount` is an integer representing cents or a float representing dollars. The Prover enforces Pydantic `BaseModel` for external data ingestion and `@dataclass` for internal DTOs. By requiring strict type hints (PEP 484), we move errors from production runtimes to static analysis stages.

A core component here is preventing 'Type Erosion.' In many agentic workflows, data loses its structure as it passes through various transformations. Using Pydantic ensures that if an API returns unexpected JSON, the failure happens at the boundary with a clear error message, rather than causing a silent logic error deep in your business logic.

The Prover targets common 'lazy' patterns that bypass Python's strengths:

`os.path` with `pathlib` for object-oriented path handling.`%` formatting or concatenation.`with` statements) instead of manual `.close()` calls.
Please note: These aren't aesthetic preferences; they prevent resource leaks and improve maintainability under load.
A frequent failure mode in AI-generated code is 'Error Swallowing.' An agent generates `try: perform_action() except Exception: pass`. This is catastrophic in production environments because it hides everything from simple validation errors to massive infrastructure outages.

The Prover mandates specific exception hierarchies and structured logging (via libraries like `structlog` or `loguru`) instead of standard `print()` statements. This allows SRE teams to actually debug issues rather than staring at empty logs after a failed deployment.

Entertaining 'God Classes' or heavy reliance on global mutable state makes testing nearly impossible. The Prover encourages protocol-based dependency injection and clear separations between Repositories and Services using `abc.ABC`. This keeps modules decoupled and prevents the dreaded circular import issue that frequently plagues growing Python projects.

The transition from synchronous programming to `asyncio` introduces new ways for things to break perfectly well while performing terribly poorly. Specifically, running blocking synchronous I/O (like using `requests` instead of `httpx`) inside an async function stalls the entire event loop.

The tool verifies that all I/O follows non-blocking patterns: using `aiofiles` for file operations, `asyncpg` for database interactions, and ensuring large datasets are handled via generators rather than being materialized into memory entirely (

mwhich avoids OOM kills during peak loads).

You cannot simply give an AI agent write access to your codebase or your cloud environment and hope for the best. Security cannot be an afterthought when automation enters the mix.

이 모든 서버는 제가 개발한 오픈 소스 프레임워크인 [MCPFusion](https://github.com/vinkius-labs/mcpfusion)을 기반으로 구축되었습니다(Apache 2.0). 이 덕분에 모든 도구들이 일관된 방식으로 동작하며 예측 가능한 인터페이스를 제공합니다.

고성능 파이썬 코드를 검증하는 것만큼 중요한 것은 그 과정의 보안입니다. Vinkius에서 실행되는 모든 MCP 서버는 격리된 V8 샌드박스 내에서 구동됩니다로써 데이터 유출 방지(DLP), SSRF 예방 및 HMAC 감사 체인을 포함한 8가지 기본 거버넌스 정책을 적용받습니다.\

Vinkius의 아키텍처 핵심은 단일 게이트웨이를 통한 연결입니다 subscriptions 후 하나의 토큰만 생성하면 Claude나 Cursor 같은 어떤 MCP 클라이언트에서도 즉시 사용할 수 있습니다. 개별 공급자마다 OAuth 콜백을 설정하거나 인증 정보를 분산 관리해야 하는 번거로움을 제거하기 위해 설계되었습니다. 이것이 엔지니어가 에이전트를 실무에 투입할 때 마주치는 가장 큰 허들 중 하나이기 때문입니다.

\lebr>By centralizing these highly specialized validators within Vinkius, we transform them from experimental scripts into reliable components of an automated engineering pipeline.

*MCPs are the music of AI Agents. We built the catalog. Discover [Vinkius MCP Catalog](https://vinkius.com).*
